SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Problem in calling functions from function library

    Hello Experts,

    I have a problem which is more a coding issue. Please let me know if we can call functions associated with QTP with function names stored in variables?
    For Example
    Variable 'Var' has value at runtime "Function1" so with 'Call Var' command I want to run 'Call Function1'

    At the moment QTP is concidering Var itself as function name which is not a function ( and just a variable) and throwing an error.

    Please let me know if there is a solution

    Thanks

    Sachin

  2. #2
    Senior Member
    Join Date
    Sep 2007
    Posts
    114
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in calling functions from function library

    Can you try:
    Call &var
    -Soumya

  3. #3
    Senior Member
    Join Date
    Mar 2009
    Posts
    184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in calling functions from function library

    That wont work. Have not seen that since my dBaseII days!

    Try this:

    x="Test1()"

    msgbox eval(x)


    Public Function Test1()
    test1="This is test1"
    End Function

    Public Function Test2()
    test2="This is test2"
    End Function

    Or this:

    For i=1 to 2
    msgbox eval("Test" & trim(cstr(i)) & "()")
    Next

    Public Function Test1()
    test1="This is test1"
    End Function

    Public Function Test2()
    test2="This is test2"
    End Function

  4. #4
    Moderator
    Join Date
    Oct 2010
    Location
    Norway
    Posts
    3,265
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Problem in calling functions from function library

    This as well...

    x="Test1()"

    Execute x
    Rajkumar

  5. #5
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Problem in calling functions from function library

    There are 3 ways to do it. You can use Eval or Execute or ExecuteGlobal. Look in QTP help for the same

  6. #6
    Member
    Join Date
    Aug 2008
    Posts
    150
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in calling functions from function library

    Also

    GetRef

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Problem in calling functions from function library

    Thanks guys. EVal does the trick for me. Thanks again for your help.

    Regards
    Sachin

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:21 AM.

Copyright BetaSoft Inc.