SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    Senior Member
    Join Date
    Jun 1999
    Location
    Fremont, CA, USA
    Posts
    355
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to execute a string as a function?

    Is there a way within 4Test to execute a string as a function? Something simular to the JavaScript 'Eval' method?

    For example, if I where to get from a datafile the string 'GetFromDB("RandomFName")', how can I actually execute that as a function?



    ------------------
    David Genrich
    david@e2Open.com
    david_kim@usa.net

  2. #2
    Member
    Join Date
    Sep 2001
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to execute a string as a function?

    You need to use the @ operator which is as close as you get the eval function in Java Script. Its also similar to pointers in c. Try this:
    ==================
    string sFunctionCall = "GetFromDB('RandomFName')"

    @(sFunctionCall)
    ==================
    This or something similar to that should work.

    ------------------

  3. #3
    Senior Member
    Join Date
    Jun 1999
    Location
    Fremont, CA, USA
    Posts
    355
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to execute a string as a function?

    That is what I thought too. I had tried that without success. I get an error back *** Error: Variable GetProgramDir() is not defined

    Here is the testcase I am using to test with:

    ------------------
    David Genrich
    david@e2Open.com
    david_kim@usa.net

  4. #4
    Member
    Join Date
    Sep 2001
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to execute a string as a function?

    Ok you made me fire up Silk :- ). I checkded this code and it works.
    This one should work

    ------------------

  5. #5
    Senior Member
    Join Date
    Jun 1999
    Location
    Fremont, CA, USA
    Posts
    355
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to execute a string as a function?

    Thank you very much Joe. That did work. It was a subtle diffrence.

    For the example I was using, the correct syntax is:

    The diffrence is that the parentheses for the function are on the outside of the @(sFunction) call. Which means to handle a string such as 'GetFromDB("RandomFName")', I need to parse out 'GetFromDB' and then call it as @(GetFromDB)("RandomFName").

    Intersting....


    ------------------
    David Genrich
    david@e2Open.com
    david_kim@usa.net

  6. #6
    Junior Member
    Join Date
    Dec 2001
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to execute a string as a function?



    read this http://www.sqa-test.com/mr_cluey/function.html

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin 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 04:06 PM.

Copyright BetaSoft Inc.