Macros are not true variables, but with the help of certain DADiSP functions, can be made to work as scalar variables. Use the DEFMACRO function to "assign" a scalar value to a macro. In turn, the EVAL function will return the value of the macro.
It is important to note that DADiSP processes command input in two phases: formulas are first expanded, parsed and "compiled," and then evaluated. The EVAL function defers macro expansion until the evaluation phase, so that current and correct values are available.
The following example is a macro, MyExtract, that defines a macro "variable", N_PTS, and then attempts to use it to extract points from a specified Window:
MyExtract(WIN) DEFMACRO("N_PTS",25,1);EXTRACT(WIN, 1, N_PTS)
If the macro N_PTS had not been defined in the Worksheet, executing MyExtract(W1) would result in an error message: N_PTS: Unknown Variable. The reason for the error message is that DADiSP expands the macro body of MyExtract first, prior to evaluating it. During the expansion phase, it looks to substitute the value of N_PTS into the EXTRACT statement, and it discovers that N_PTS is undefined. If the macro N_PTS had already been defined (e.g., with a value of 75), that pre-defined value would be used for the number of points in the EXTRACT statement. To remedy the situation, use the EVAL statement, to force DADiSP to wait until the evaluation stage to substitute the value for N_PTS:
MyExtract(WIN) DEFMACRO("N_PTS",25,1);EXTRACT(WIN, 1, EVAL("N_PTS"))