A macro can consist of any combination of PWB functions, literal text, and calls to previously defined macros. You can define up to 1,024 macros at one time.
Anything inside quotation marks is literal text. Within literal text, quotation marks are represented by a backslash followed by quotation marks (\ ") and a backslash is represented by two consecutive backslashes (\ \). Only literal text is case sensitive; PWB ignores the case of everything else.
The following macro “comments out” a line of MASM source code:
comment:=begline "; "
comment:alt+c
The first line names the macro (comment); the macro commands follow the assignment operator (:=). The begline editor function moves the cursor to the beginning of the current line. The text inside quotation marks (the MASM comment delimiter) is then inserted. The second line assigns a keystroke (ALT+C) to the macro.
Summary: Macros can extend over one line.
If a macro definition takes up more space than you have on one line (about 250 characters in PWB), you can use the backslash (\) to continue the definition on the next line. Consider, for instance, the following macro, which comments out a line of C source code:
comment:=begline "/* " endline " */"
It could be written as
comment:=begline \
"/* " endline \
" */"
Notice the extra space before each backslash. If you want a space between the end of one line and the beginning of the next, you must precede the backslash with two spaces.
Summary: You can pass arguments to PWB macros.
You can use the arg function to pass arguments to functions. For example, the following macro passes the argument 15 to the plines function (which scrolls text down):
movedown:=arg "15" plines
Because arg precedes the literal text, the text isn't written to the screen. Instead, it is passed as an argument to the next function, plines. The macro scrolls the current text down 15 lines.
Arguments can also use regular-expression syntax (regular expressions are documented in online help):
endword:=arg arg "([ .,;:()[\\]]!$)" psearch cancel
The arg arg sequence directs the psearch function to treat the text argument as a regular-expression search pattern. This search pattern tells PWB to search for the next space, period, comma, semicolon, colon, parentheses, and square brackets. (Note that a backslash must precede any character that has a special meaning in regular expressions—in this case, the right bracket.)
A macro can invoke other macros:
lcomment:= "/* "
rcomment:= " */"
commentout:=begline lcomment endline rcomment
commentout:ctrl+o
The commentout macro invokes the previously defined macros lcomment and rcomment.
In addition to standard PWB functions, PWB macros can invoke user-defined macro functions. See Section 9.6, “Returning Values with Macro Functions.”