Working with macro variables

From m204wiki
Revision as of 02:44, 7 October 2022 by Ekern (talk | contribs) (Created page with "__TOC__ <span class="f_Para">Macro variables are placeholders for Debugger command arguments within Debugger macros, as well as placeholders for Client function arguments. Dis...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Macro variables are placeholders for Debugger command arguments within Debugger macros, as well as placeholders for Client function arguments. Distinguished by names that begin with a single ampersand (&) character, macro variables can be set to a variety of types of values.

As an example, you could have a macro set some breakpoints, run to each of them, and use a macro variable to note the value of the program's %variable at each break. This would let you note the values at different points in program execution:  

breaks  run  set &val1 = %i  run  set &val2 = %i  echo &val1  echo &val2 

Macro variables are either system-supplied (predefined) or user-defined.

Predefined macro variables

The system &argstring variable is described in Passing a command argument to a macro.

User-defined macro variables

To define a macro variable or change its value, you use the set command. As shown below, the types of values to which you can set the variable include constants, User Language variables, fields, and $list elements, and other macro variables and functions.

These command examples also show that multiple blanks may surround names and values:

 

SET &a2 = %a(2)    set &i=%i  SET  &g =  %G  set &s=%s  set &l =   %L  set &lc = $listcnt(%g)  set &l1 = $listinf(%g,1)  set &l2 = $listinf(%g,2)  set &global = g.JACK  set &sl = %sl:item(1)  set &num   = 1  set &string = "a"   set &a = &&prompt("g'day mate!") set &f  = f.name  set &f3 = f.name(3)  set &a2 = -1  set &xx = &asa   

If you want to review the values of macro variables you have defined, you can issue the varDump command, for example from the Command Line tool. Other commands useful for working with macro variables include setM204Data, assert, continueIf, and toggle.