Previous
Previous
 
Next
Next

Passing Arguments as Text with Ampersand Substitution

It is very common to pass a simple text argument to a program. However, there are some situations in which you might want to write more general programs or pass a more complicated text argument, such as an argument that is all of the data in an analytic workspace object or the results of an expression. In these cases, you can pass the argument using a substitution expression. Passing an argument in this way is called ampersand substitution.

For the following types of arguments, you must always use an ampersand to make the appropriate substitution:

When you use ampersand substitution to pass the names of workspace objects to a program (rather than their values), the program has access to the objects themselves because the names are known to the program which is useful when the program must manipulate the objects in several operations.


Note:

You cannot compile and save any program line that contains an ampersand. Instead, the line is evaluated at run time, which can reduce the speed of your programs. Therefore, to maximize performance, avoid using ampersand substitution when another technique is available.

For an example of using ampersand substitution to pass multiple dimension values, see Example: Using Ampersand Substitution with LIMIT. For an example of using ampersand substitution to pass the text of an expression, see Example: Passing the Text of an Expression. For an example of using ampersand substitution to pass object names and keywords, see Example: Passing Workspace Object Names and Keywords.


See Also:

"Substitution Expressions" for more information about ampersand substitution.