runtime check if a function is linked - a definitive solution ? - xharbour

This is a discussion on runtime check if a function is linked - a definitive solution ? - xharbour ; At the end of March I asked in this newsgroup if it was possible to check if a function was present (linked) in an exe during run-time. The answer was to use TYPE() and check if the result is UI ...

+ Reply to Thread
Results 1 to 5 of 5

runtime check if a function is linked - a definitive solution ?

  1. Default runtime check if a function is linked - a definitive solution ?


    At the end of March I asked in this newsgroup if it was possible to
    check if a function was present (linked) in an exe during run-time.

    The answer was to use TYPE() and check if the result is UI or U....

    I did this yesterday on my notebook and it worked... now on my dev pc it
    doesn't work.... I allways get UI....

    So I created this little piece of code, studying the HB_ExecFromArray code:

    HB_FUNC( ISLINKED )
    {
    char * szString = hb_parc( 1 ) ;

    if ( hb_dynsymFindName( szString ) )
    hb_retl( TRUE ) ;
    else
    hb_retl( FALSE ) ;

    }


    Now you can use
    IsLinked( "FUNC" )

    You CAN'T use IsLinked("FUNC()") so IsLinked IS NOT a direct replacement
    to TYPE...


    Francesco

  2. Default Re: runtime check if a function is linked - a definitive solution ?

    On 11 Nov, 11:54, FP <mc8647__nnoossppa...@mclink.it> wrote:
    > At the end of March I asked in this newsgroup if it was possible to
    > check if a function was present (linked) in an exe during run-time.
    >
    > The answer was to use TYPE() and check if the result is UI or U....
    >
    > I did this yesterday on my notebook and it worked... now on my dev pc it
    > doesn't work.... I allways get UI....
    >
    > So I created this little piece of code, studying the HB_ExecFromArray code:
    >
    > HB_FUNC( ISLINKED )
    > {
    >    char * szString = hb_parc( 1 ) ;
    >
    >    if ( hb_dynsymFindName( szString ) )
    >       hb_retl( TRUE ) ;
    >    else
    >       hb_retl( FALSE ) ;
    >
    > }
    >
    > Now you can use
    > IsLinked( "FUNC" )
    >
    > You CAN'T use IsLinked("FUNC()") so IsLinked IS NOT a direct replacement
    > to TYPE...
    >
    > Francesco


    Hi Francesco,
    sometime ago i wrote something of similar in this post
    http://groups.google.com/group/comp....8042d5cca53e60
    and worked fine here, but i received some disagree by Patrick because
    of Type() "replacement" and "supefrluous" function creation. So be
    aware...
    Maurizio

  3. Default Re: runtime check if a function is linked - a definitive solution?

    My routine doesn't compile a code-block... it checks the internal symbol
    table.

    Francesco

  4. Default Re: runtime check if a function is linked - a definitive solution ?

    On Nov 11, 3:54 am, FP <mc8647__nnoossppa...@mclink.it> wrote:
    > At the end of March I asked in this newsgroup if it was
    > possible to check if a function was present (linked) in
    > an exe during run-time.
    >
    > The answer was to use TYPE() and check if the result
    > is UI or U....
    >
    > I did this yesterday on my notebook and it worked...
    > now on my dev pc it doesn't work.... I allways get UI....


    Variance in the xHarbour version?

    > So I created this little piece of code, studying the
    > HB_ExecFromArray code:
    >
    > HB_FUNC( ISLINKED )
    > {
    >    char * szString = hb_parc( 1 ) ;
    >
    >    if ( hb_dynsymFindName( szString ) )
    >       hb_retl( TRUE ) ;
    >    else
    >       hb_retl( FALSE ) ;
    >
    > }
    >
    > Now you can use
    > IsLinked( "FUNC" )
    >
    > You CAN'T use IsLinked("FUNC()") so IsLinked IS
    > NOT a direct replacement to TYPE...


    You could scan the parameter passed to IsLinked and strip the parens
    before evaluating? Say if the false condition triggers, then see if
    you can strip...

    Two questions:
    How does this behave if the function is in a DLL (and is the DLL
    loaded)?
    Did you have a question... were you not happy with your solution...
    because it looks pretty sweet!

    David A. Smith

  5. Default Re: runtime check if a function is linked - a definitive solution?

    >> The answer was to use TYPE() and check if the result
    >> is UI or U....
    >>
    >> I did this yesterday on my notebook and it worked...
    >> now on my dev pc it doesn't work.... I allways get UI....

    >
    > Variance in the xHarbour version?


    No, not to my knowledge.


    > You could scan the parameter passed to IsLinked and strip the parens
    > before evaluating? Say if the false condition triggers, then see if
    > you can strip...


    This is an exercise for the reader :-)

    > Two questions:
    > How does this behave if the function is in a DLL (and is the DLL
    > loaded)?


    Don't know but I'm interested. I actually never created an xharbour DLL
    but I should do it in the near future... and I will need this kind of
    function... I will check...
    If you know how to create the DLL with usage samples... you are welcome..

    > Did you have a question... were you not happy with your solution...
    > because it looks pretty sweet!


    I'm asking if this can be considered a definitive solution that is
    acceptable by everybody and without side-effects.

    Francesco

+ Reply to Thread