SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Jun 2001
    Location
    Mountain View, CA
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    In Silk Test how to returne value form funcrion.

    Hi,
    Please, help.

    In Silk script I'm calling some function, and want to return a value from this function, without using global variables.

    Any idea how to do that?

    Example:

    testcase Test()
    Calculate()
    print(i3)

    // here is function()
    Calculate()
    Integer i1,i2,i3
    i1 = 2
    i2 = 3
    i3 = i1+i2



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

  2. #2
    Member
    Join Date
    Jun 2001
    Location
    Berkeley, CA, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: In Silk Test how to returne value form funcrion.

    You can use the out keyword to pass a value back through the argument list:

    INTEGER Calculate (out INTEGER i2, out INTEGER i3)

    INTEGER i1 = 2
    i2 = 3
    i3 = i1 + 12

    return i1

    The testcase looks like this

    testcase Test()
    INTEGER iOne, iTwo, iThree
    iOne = Calculate(iTwo, iThree)
    Print(iThree)


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

  3. #3
    Junior Member
    Join Date
    Jun 2001
    Location
    Mountain View, CA
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: In Silk Test how to returne value form funcrion.

    Thanks, guys It work...

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

  4. #4
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: In Silk Test how to returne value form funcrion.

    Or the other way of getting a value back from a function is to declare the datatype to be returned before the function name, and then use the 'return' command at the end of your function to return the appropriate value, for example:
    Have a look at both Function Declaration and Return in the language reference, these explain things more clearly.

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

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: In Silk Test how to returne value form funcrion.

    If you are keen about it. You can also return values from the argument you pass in your function.

    integer myFunc(out int iVar)
    iVar+=3.1415
    return 0

    int x=0
    y=myFunc(x)

    y=0//this can be your error variable. 0 been flawless.
    x=3.1415

    Depending what you want to do, of course.

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

 

 

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 02:34 AM.

Copyright BetaSoft Inc.