Dollar-sign expansion using parameters
Parameters can be used in dollar-sign expansions. The variable must then contain formal parameters, such as $1, $2, $3 etc. When expanding the variable, the parameters should be stated in a comma separated list.
Example:
Set MUL=’$1*$2’;
Set X=$(MUL(3,7)); // returns '3*7' in X
Let X=$(MUL(3,7)); // returns 21 in X
If the number of formal parameters exceeds the number of actual parameters only the formal parameters corresponding to actual parameters will be expanded. If the number of actual parameters exceeds the number of formal parameters the superfluous actual parameters will be ignored.
Example:
Set MUL=’$1*$2’;
Set X=$(MUL); // returns '$1*$2' in X
Set X=$(MUL(10)); // returns '10*$2' in X
Let X=$(MUL(5,7,8)); // returns 35 in X
The parameter $0 returns the number of parameters actually passed by a call.
Example:
set MUL='$1*$2 $0 par';
set X=$(MUL(3,7)); // returns '3*7 2 par' in X
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!