Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing variables

Status
Not open for further replies.

Matta25

Technical User
Jan 6, 2004
82
US
i have a script that calls a different procedure up then this procedure will retun to the main procedure. how do you pass a variable from the procedure back to the main procedure?
thanks.
 
Here's an example that shows how to do this:

proc main
string sName = "foo"
mangle(&sName)
usermsg "sName = %s" sName
endproc

proc mangle
param string name
usermsg "passed value = %s" name
name = "bar"
endproc

For any values that are passed to the procedure (regardless of if they are passed by value or reference), you need to have a corresponding param declaration at the beginning of the procedure.

The & in the argument for the procedure call means that sName is being passed by reference and not by value, which means that the procedure can modify this value and it will be reflected in the calling procedure. If you ran the same script without the ampersand, the value of sName would not be modified by the procedure call.

For more information, check out the ASPECT help discussion of the call and param commands, as well as the Parameter Variables link near the bottom of the param discussion.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top