hello,
I am trying to the following:
Let>VAREXPLICIT=1
Let>var=123
GoSub>PRO,var
SRT>PRO
Let>pro_var=%PRO_Var_1%
END>PRO
I am trying to get the value of 'var' i.e. 123 inside the PRO subroutine. For which I tried to use %%PRO_Var_1%%, which returned the same thing.
I want to know the variable name and value inside the PRO subroutine.
Objective is: Want to get the variable name and its value of the argument that I send to the subroutine.
I am in very much need for the solution. Please someone help me.
Thanks
yuvaraj.
call by reference - help required urgent
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The variable name is always PRO_Var_1 and the value is the value of PRO_Var_1
I suppose if you wanted to know the name of the original variable you could pass it as a literal string in a second parm:
I suppose if you wanted to know the name of the original variable you could pass it as a literal string in a second parm:
Code: Select all
Let>VAREXPLICIT=1
Let>var=123
GoSub>PRO,%var%,var
SRT>PRO
Let>pro_var_value=%PRO_Var_1%
Let>pro_var_name=%PRO_Var_2%
END>PRO
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks for the information.
So, it means there no way I can get it the following way
So, it means there no way I can get it the following way
Code: Select all
Let>VAREXPLICIT=1
Let>var=123
GoSub>PRO,var
SRT>PRO
Let>pro_var_value=%PRO_Var_1%
........
END>PRO
VAREXPLICIT 0 required
Hi yuvaraj,
VAREXPLICIT 0 is required to call by reference. Here is how to do it if you want your main script to be VAREXPLICIT 1.
Usually in a self contained subroutine you don't care about the name of the variable in the main script. Was your subroutine going to modify the value of var and you wanted to pass it back? Another way to do that is:
Gale
VAREXPLICIT 0 is required to call by reference. Here is how to do it if you want your main script to be VAREXPLICIT 1.
Code: Select all
Let>VAREXPLICIT=1
Let>var=123
GoSub>PRO,var
SRT>PRO
Let>VAREXPLICIT=0
Let>pro_var_name=PRO_Var_1
Let>pro_var_value=%PRO_Var_1%
Let>VAREXPLICIT=1
MDL>pro_var_name:%pro_var_name%
MDL>pro_var_value:%pro_var_value%
END>PRO
Code: Select all
Let>VAREXPLICIT=1
Let>var=123
GoSub>PRO,%var%
Let>var=%pro_var_value%
SRT>PRO
Let>pro_var_value=%PRO_Var_1%+1
END>PRO