SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Return command for functions

    Is there a return command for functions in Silk Performer. I would like to return to the calling function if a certain scenario occurs. Is there a command to do this?

    Thanks

  2. #2
    Senior Member
    Join Date
    Dec 2006
    Posts
    1,838
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions

    return ?

  3. #3
    Member
    Join Date
    Jan 2008
    Location
    Chennai, TamilNadu, India
    Posts
    78
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions

    SP has RETURN statement but it will it terminates the transaction from which the function was called and not only the function itself.

    But you can get an indirect solution...
    We are having "EXIT" command to come out of a loop. So we can do like as follows,

    function Sample()
    var
    i : number;
    begin
    for i := 1 to 1 do
    ...
    ...
    ...
    if (yourscenario=True) then
    Exit;
    end;
    ...
    ...
    ...

    end;
    end Sample;

    Here we are defining a dummy loop which encloses the entire function and if the scenario is true then the exit statement will be executed. It will come out of the loop as and so the function.

    Hope this will help you!
    Regards,
    N.Karthikeyan

  4. #4
    Senior Member
    Join Date
    Dec 2006
    Posts
    1,838
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions

    one more choice,

    write the handler function and raise the event based on outcome like if verification failed move back to the calling function. You need have if else block.

  5. #5
    Member
    Join Date
    Feb 2008
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions



    //function calling in the transactions or other function

    transaction TMain
    x : number;

    begin

    x :=display(); //function calling


    end TMain;




    // function definition
    dclfun
    function display

    var
    i : number;
    j: number;
    begin

    i:=10;
    j:= i;
    display := j;
    // Now i am returning the j value to function name ( in C language as like return j

    end display;

  6. #6
    Member
    Join Date
    Jan 2008
    Location
    Chennai, TamilNadu, India
    Posts
    78
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions

    @ Rama, i guess you misunderstood the question here! he is asking about get the control out of the function with respective of the scenario but not about the returning some values from function...

    PS: in your example, i guess you missed declaring the return type of the function! [img]/images/graemlins/smile.gif[/img]
    Regards,
    N.Karthikeyan

  7. #7
    Member
    Join Date
    Feb 2008
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions

    What you want exactly.Please send me clear picture.

  8. #8
    Member
    Join Date
    Jan 2008
    Location
    Chennai, TamilNadu, India
    Posts
    78
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions

    See Steve's post man...

    he means returning the control from the function...
    and not returning some values from the function...

    Your script is pointing to the Second one... got it?
    Regards,
    N.Karthikeyan

  9. #9
    Member
    Join Date
    Feb 2008
    Posts
    30
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return command for functions



    benchmark BenchmarkName

    use "kernel.bdh"

    // Definition of global variables: string, number, float, boolean, array
    var

    j: number;
    i: number;

    dclevent

    handler Handler1 <EVENT_RAISE_ERROR>


    begin

    i:= 1;
    print("event handler block");


    end Handler1;


    dclfunc

    function fun1:number

    begin

    i:=0;
    j:= 50;

    if i=0 then
    print(" Abort from the function");
    fun1 := j;
    RepMessage("Data successfully transferred", SEVERITY_ERROR);

    end;


    if i<>1 then

    print(" Execute sequentially");
    j:= 20;
    end;


    end fun1;



    dcluser
    user
    VirtUser
    transactions

    TLogic : 1; // Transactions


    // Transactions Section
    dcltrans
    transaction TLogic

    var
    k : number;
    begin

    Print("Before Function calling in the Transaction");

    k:= fun1();


    Print("k value"+ string(k));

    Print("After Function calling in the Transaction");



    // Insert here the initial statements
    end TLogic;

 

 

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 10.00%
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:07 PM.

Copyright BetaSoft Inc.