WPCI 2VB ZzNxxx U^x  @X@Courier 10 Pitchx  @X@#|x2 EGG?#d6X@KU^@# X` hp x (#%'0*,.8135@8:cnt) FileManagerDlg FileManagerDlg DownArrow type("1") //opens the highlighted document PrintFullDoc ExitDlg Type("nn") //"No" to save and "No" to exit WordPerfect cnt:=cnt+1 ENDWHILE00*0*0* AND Show Me An Example...  AND is an operator that evaluates two expressions, usually in a conditional statement. Conditional statements can be created with commands such as IF, REPEAT, and WHILE. This operator performs a logical AND that evaluates a conditional statement as true only if both the expressions are true. Parameters:P P h None(# See Also:P P h DIV(# h hhhP P h IF(# h hhhP P h NOT(# h hhhP P h OR(# h hhhP P h REPEAT(# h hhhP P h WHILE(# h hhhP P h XOR(#   0*0*0* For Example... This macro counts keystrokes until the user presses CtrlEnter. STATUSPROMPT("Press Ctrl+Enter to quit") cnt:=0 REPEAT LOOK(info) IF((info<>0) AND (info<>8097)) cnt:=cnt+1 Type(NTOC(info)) ENDIF UNTIL(info=8097) STATUSPROMPT("") PAUSESET(EndFieldKey) PROMPT("You pressed "+cnt+" keystrokes. Press F9 to continue") PAUSE 0*0*0* ASSERT Show Me An Example...  ASSERT causes a macro to respond as if one of three conditions exists. This command can assert (or cause) an Error, a Cancel, or a Not Found condition. Each of these conditions can be used to end a macro or redirect macro flow. To redirect the flow of a macro to a specific LABEL, you can use ONCANCEL, ONERROR, or ONNOTFOUND. A macro will stop if it has not encountered one of these commands before the corresponding condition has been asserted. ASSERT will have no effect if a CANCEL, ERROR, or NOTFOUND command has been used before the ASSERT command to disable detection of these conditions. Syntax:8hP P h ASSERT(Condition)(# Parameters:P P h Condition(# h hhhP P h Specifies the condition to assert. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+h.Numeric87h00:h=Description(# h hhhP P h Typeh"hXX%h(h((+h.Equivalent(# h hhhP P h (# h hhhP P h CancelCondition!p((+h.0h1h``4h7h00:h=Asserts a Cancel (# h hhhP P h ErrorCondition!p((+h.1h1h``4h7h00:h=Asserts an Error (# h hhhP P h NotFoundCondition! .2h1h``4h7h00:h=Asserts a Not Found(# h hhhP P h (# See Also:P P h NotFound(# h hhhP P h CANCEL(# h hhhP P h ERROR(# h hhhP P h LABEL(# h hhhP P h NOTFOUND(# h hhhP P h ONCANCEL(# h hhhP P h ONERROR(# h hhhP P h ONNOTFOUND(#   !0*0*0* For Example... This macro prompts the user to highlight text in a document, and the macro assigns it to a variable. Display(On!) ONERROR(error) LABEL(Begin) BlockKey PROMPT("Highlight the text to assign to a variable and press Enter") PAUSE x:=?BlockedText IF (x="") ASSERT(ErrorCondition!) ENDIF h hhhP P //the user must place more code here to make(#P QUIThhP P h //this macro more functional(# LABEL(Error) BEEP DisplayRewrite PROMPT("You must select text to assign it to a variable") PAUSE GO(Begin) 0*0*0* ASSIGN Show Me An Example...  ASSIGN places a value in a WordPerfect variable. The values can be a numeric expression, measurement expression, character expression, or other variables. Consider the following examples: h ASSIGN (PERIOD; "Renaissance")(# This ASSIGN statement assigns the word "Renaissance" to variable PERIOD. Note the quotation marks around the character expression. h ASSIGN (SUM; NUMBER+19)(# This ASSIGN statement assigns 19 plus the value of the variable NUMBER to the variable SUM. For example, if variable NUMBER is 10, variable SUM will be assigned the value of 29. Syntax:8hP P h ASSIGN (Variable; Expression)(# h hhhP P h or(# h hhhP P h Variable=Expression(# h hhhP P h or(# h hhhP P h Variable:=Expression(# Parameters:P P h Variable(# h hhhP P h Any variable less than 29 characters in length can be used in this parameter.(# h hhhP P h Expression(# h hhhP P h All expressions, including variables, can be used in this parameter.(# See Also:P P h DISCARD(# h hhhP P h GLOBAL(# h hhhP P h INDIRECT(# h hhhP P h LOCAL(# h hhhP P h PERSIST(# h hhhP P h PERSISTALL(# h hhhP P h SHELLASSIGN(# h hhhP P h SHELLVARIABLE(#   `" 0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH 0*0*0* BEEP Show Me An Example...  The computer beeps when this command is executed. BEEP is often used to prompt the user when a macro pauses or displays a message. Syntax:8hP P h BEEP(# Parameters:P P h None(# See Also:P P h ONCANCEL(# h hhhP P h ONERROR(# h hhhP P h ONNOTFOUND(# h hhhP P h PAUSE(# h hhhP P h PROMPT(#    0*0*0* For Example... This macro beeps if the current document is blank and displays a message. DISPLAY(Off!) IF(?DocBlank) h BEEP(# h DISPLAY(On!)(# h PROMPT("The document is blank. Press Tab to continue")(# h PAUSEKEY(TabKey)(# h DISPLAY(Off!)(# h QUIT(# ENDIF( 0*0*0* BREAK Show Me An Example...  BREAK breaks out of loops or statements created with SWITCH, FORNEXT, REPEAT, or WHILE commands. At the point this command is encountered, the macro is redirected to the end of the loop or statement, and resumes execution. For example, if this command breaks out of a WHILE loop, the macro is redirected to the command immediately following the ENDWHILE command and continues from that point. Syntax:8hP P h BREAK(# Parameters:P P h None(# See Also:P P h SWITCH(# h hhhP P h FORNEXT(# h hhhP P h FOREACH(# h hhhP P h NEXT(# h hhhP P h REPEAT(# h hhhP P h WHILE(#   0*0*0* For Example... This macro counts from one to ten and breaks out of the loop when it reaches the number seven. DISPLAY(Off!) FORNEXT(x;1;9;1) h Type(x)(# h IF(x=7)(# h hBREAK(# h ENDIF(# ENDFOR0*0*0* CALL Show Me An Example...  The CALL command redirects macro execution to the LABEL command specified in the Label parameter. The macro executes from that point until it encounters a RETURN command. Macro execution then returns to the command immediately following the CALL command and resumes from that point. This command is useful for repeating a subroutine from any location in the macro. Syntax:8hP P h CALL(Label)(# Parameters:P P h Label(# h hhhP P h Any combination of text can specify the label. The label name used here must correspond to a LABEL command in the same macro.(# See Also:P P h LABEL(# h hhhP P h RETURN(#   h0*0*0* For Example... This macro searches for a period (.) followed by two spaces and capitalizes the first letter of the next sentence. DISPLAY(Off!) PosDocTop CALL(Convert) ONNOTFOUND(NotFnd) LABEL(Begin) SearchString(". ") SearchNext CALL(Convert) GO(Begin) LABEL(Convert) BlockOn(CharMode!) PosCharNext ConvertCaseUppercase BlockOff RETURN LABEL(NotFnd) DISPLAY(On!) PROMPT("It's finished. Press ENTER to continue.") PAUSE PosDocTop0*0*0* CANCEL Show Me An Example...  CANCEL determines whether to ignore a Cancel condition while a macro is running. A Cancel condition is created by pressing the Cancel key or by using the ASSERT(CancelCondition!) command. By default, a Cancel condition is not ignored and will affect macro execution. A Cancel will generally stop a macro, but it can also be used to redirect execution using ONCANCEL. If an ONCANCEL command is encountered in the macro before a Cancel occurs, the macro is redirected to the LABEL specified in ONCANCEL. Pressing Ctrl+Break always terminates a macro even if CANCEL(Off!) is used. Syntax:8hP P h CANCEL(State)(# Parameters:P P h State(# h hhhP P h Specifies whether to ignore cancel conditions. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+Numeric8``4h7h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h Off!h"hXX%h(h((+0h.h1h``4h7h00:Ignore Cancel conditions(#0 h hhhP P h On!h"hXX%h(h((+1h.h1h``4h7h00:Do not ignore Cancel conditions(#0 h hhhP P h (# See Also:P P h ASSERT(# h hhhP P h LABEL(# h hhhP P h ONCANCEL(#   X0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) HRt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCH0*0*0* CASEOF Show Me An Example...  CASEOF creates individual cases against which a single SWITCH expression is compared. Each CASEOF can contain one or more expressions which, when evaluated individually, may be true, or in other words, provide a match for the SWITCH expression. For example, SWITCH(Year) h CASEOF 1776:(# h hGO(Independence)(# h CASEOF 1988;1992:(# h hGO(Elections)(# ENDSWITCH h h(# The first CASEOF is true, or a match, if the SWITCH expression (variable Year) contains the number 1776. The second CASEOF is a match if variable Year contains either 1988 or 1992. In other words, if a CASEOF contains more than one expression, the semicolon acts as an "or" rather than as an "and." Both the SWITCH and the CASEOF expressions are case sensitive (capitalization) and must match exactly. If a CASEOF match is found for the SWITCH expression, the commands immediately following that CASEOF will be executed and the macro does not evaluate any other CASEOF expression. Syntax:8hP P h CASEOF(Expression;Expression;...:)(# Parameters:P P h Expression(# h hhhP P h Specifies the expression to evaluate. All expressions are valid for this parameter.(# See Also:P P h SWITCH(# h hhhP P h CONTINUE(# h hhhP P h DEFAULT(# h hhhP P h ENDSWITCH(# h hhhP P h GO(#    0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) HRt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCH0*0*0* CHAIN Show Me An Example...  CHAIN executes the specified macro when the current macro ends. Unlike other commands, the CHAIN command does not take effect when it is encountered. Regardless of where the CHAIN command is placed in the macro, it does not execute the chained macro until the current macro has finished. If a macro contains more than one CHAIN command, only the macro specified in the last encountered CHAIN command is executed. A QUIT command at the end of the active macro overrides any pending CHAIN command and will not allow execution of the chained macro. CHAIN looks for the specified macro first in the current directory, then in the macros directories, and finally in the shared WP directory. Syntax:8hP P h CHAIN("Filename")(# Parameters:P P h Filename(# h hhhP P h A character expression specifying the macro to chain.(# See Also:P P h NEST(#   0*0*0* For Example... This macro displays a dialog box on the screen. Pending the user's response, the macro chains the correct macro. DISPLAY(Off!) DLGCREATE(x;"TITLE";DLGNoCancel!;;;30;14) h DLGCONTROL(CtrlRadioButton!;a;"Letter";StyInitial!;4;4;10;2)(# h DLGCONTROL(CtrlRadioButton!;b;"Itinerary";;4;6;10;2)(# h DLGCONTROL(CtrlRadioButton!;c;"Memo";;4;8;10;2)(# h DLGCONTROL(CtrlRadioButton!;d;"Fax";;4;10;10;2)(# DLGEND SWITCH (1) h CASEOF a : CHAIN("letter")(# h CASEOF b : CHAIN("Itin")(# h CASEOF c : CHAIN("memo")(# h CASEOF d : CHAIN("fax")(# ENDSWITCHH 0*0*0* CHAR Show Me An Example...  The CHAR, or character, command prompts the user for a keystroke. The numeric equivalent (ascii value) of the keystroke is then assigned to the variable specified in the CHAR command. As the name indicates, only one character is accepted and assigned to the variable. If the user enters more than one character or presses more than one keystroke, only the first is accepted. If more than one keystroke needs to be assigned to a variable, use GETSTRING, GETNUMBER, OR GETUNITS. Generally, the keystroke is given in response to a question posed in the optional prompt parameter of this command. The variable containing the numeric equivalent of the keystroke can be evaluated later in the macro using commands such as IF or SWITCH. The numeric equivalent of the keystroke can also be converted back to the original keystroke using NTOC. For a list of keystrokes and their numeric equivalents, see Appendix A in the Appendices section. Syntax:8hP P h CHAR(Variable;"Prompt")(# Parameters:P P h Variable(# h hhhP P h Specifies the variable to which the numeric equivalent of the keystroke will be assigned. Any variable is valid for this parameter.(# h hhhP P h Prompt (optional)(# h hhhP P h A character expression that will display as a prompt on the status line.(# See Also:P P h SWITCH(# h hhhP P h GETNUMBER(# h hhhP P h GETSTRING(# h hhhP P h IF(# h hhhP P h NTOC(#   x0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH 0*0*0* CONTINUE Show Me An Example...  CONTINUE is used in a SWITCH statement to instruct a macro, after executing one CASEOF, to continue to the next CASEOF and execute it without evaluating its expression. This command is optional and is not required as part of a SWITCH statement. Syntax:8hP P h CONTINUE(# Parameters:P P h None(# See Also:P P h SWITCH(# h hhhP P h CASEOF(# h hhhP P h ENDSWITCH(#   H 0*0*0* For Example... This macro either types a name, an address, or the entire name and address. DLGCREATE(x;"TITLE";DLGNoCancel!;;;30;14) h DLGCONTROL(CtrlRadioButton!;a;"Name";StyInitial!;4;4;10;2)(# h DLGCONTROL(CtrlRadioButton!;b;"Full Address";;4;6;10;2)(# h DLGCONTROL(CtrlRadioButton!;c;"Address only";;4;8;10;2)(# DLGEND SWITCH (1) CASEOF a : Type("John Doe") CASEOF b : Type("John Doe") Hrt h hhCONTINUE(# CASEOF c : Type("123 Anywhere") ENDSWITCH 0*0*0* CTON Show Me An Example...  CTON (character to number) converts a character or keystroke to its numeric equivalent. For a list of numeric equivalents, see Appendix A in the Appendices section. Syntax:8hP P h CTON("Character")(# Parameters:P P h Character(# h hhhP P h Any ASCII character or a variable containing an ASCII character.(# See Also:P P h NTOC(#   H 0*0*0* For Example... This macro prompts for a character and returns its ascii equivalent. GetString(x;"Enter a character:") ascii:=CTON(x) Prompt("The ASCII equivalent of "+x+" is "+ascii+".") Pause@0*0*0* DEFAULT Show Me An Example...  DEFAULT is used with the SWITCH command to specify a series of commands to execute if all CASEOF expressions are false. This command is an optional part of a SWITCH statement, but is useful for providing a default action if all other cases are false. Syntax:8hP P h DEFAULT:(# Parameters:P P h There are no parameters, but DEFAULT is always followed by macro commands to execute.(# See Also:P P h SWITCH(# h hhhP P h CASEOF(# h hhhP P h CONTINUE(# h hhhP P h ENDSWITCH(#   0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) HRt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCH0*0*0* DEFAULTUNITS Show Me An Example...  DEFAULTUNITS sets the default unit of measurement for any measurement expression that does not contain a unit of measure character (", i, u, p). Syntax:8hP P h DEFAULTUNITS(Measurement)(# Parameters:P P h Measurement(# h hhhP P h Specifies the default unit of measurement for measurement expressions. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Inches!8"hXX%h(0h((+h.h1h``4Inches as default (")(#` h hhhP P h InchesI!8"hXX%h(1h((+h.h1h``4Inches as default (i)(#` h hhhP P h Centimeters!(h((+2h.h1h``4h7Centimeters as default(# h hhhP P h Millimeters!(h((+3h.h1h``4h7Millimeters as default(# h hhhP P h Points!8"hXX%h(4h((+h.h1h``4Points as default(#` h hhhP P h WP1200ths!XX%h(5h((+h.h1h``41200ths of an inch as default(#` h hhhP P h WP42Units!XX%h(6h((+h.h1h``4WP42 units as default(#` h hhhP P h (#   8 0*0*0* For Example... This macro advances four centimeters from the top of the page regardless of the current unit of measure. DISPLAY(Off!) DefaultUnits(Centimeters!) Advance(AdvanceFromTop!;4)x!0*0*0* DISCARD Show Me An Example...  DISCARD removes variable definitions from the current macro as well as variables set with PERSIST or PERSISTALL. Variables might reside in one of three variable tables: Local, Global, and Persistent. Variables are discarded in that order. For example, to discard local, global, and persistent variables all named ABBEY, you would need to DISCARD(ABBEY) three times to remove ABBEY from all tables. This command does not specify the table from which the variable should be discarded; the command must simply be repeated enough times to clear the desired tables. This could be done easily in a WHILE loop, for example: WHILE(EXISTS(Abbey)) DISCARD(Abbey) ENDWHILE Syntax:8hP P h DISCARD(Var1;Var2;...VarN)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter.(# See Also:P P h ASSIGN(# h hhhP P h GLOBAL(# h hhhP P h LOCAL(# h hhhP P h PERSIST(# h hhhP P h PERSISTALL(#   p"0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNC#0*0*0* DISPLAY Show Me An Example...  DISPLAY determines whether to display macro execution. DISPLAY(Off!) is inserted at the beginning of recorded macros and will remain in effect until replaced with DISPLAY (On!) or deleted from the macro. Syntax:8hP P h DISPLAY(State)(# Parameters:P P h State(# h hhhP P h Specifies whether macro display is on. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(Numeric81h``4h7Description(# h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Off!h"hXX%h(0h((+h.h1h``4h7Display off(# h hhhP P h On!h"hXX%h(1h((+h.h1h``4h7Display on(# h hhhP P h (#   $0*0*0* For Example... This macro beeps if the current document is blank and displays a message. DISPLAY(Off!) IF(?DocBlank) h BEEP(# h DISPLAY(On!)(# h PROMPT("The document is blank. Press Tab to continue")(# h PAUSEKEY(TabKey)(# h DISPLAY(Off!)(# h QUIT(# ENDIF( %0*0*0* DIV Show Me An Example...  DIV is an operator that performs a division and returns the integer portion of the quotient. For example, if the quotient is 2.5, DIV returns 2. DIV must be used in an expression that can be evaluated by commands such as IF and ASSIGN. DIV is preceded and followed by expressions to divide, for example, 10 DIV 2. Parameters:P P h None(# See Also:P P h AND(# h hhhP P h ASSIGN(# h hhhP P h IF(# h hhhP P h NOT(# h hhhP P h OR(# h hhhP P h REPEAT(# h hhhP P h WHILE(# h hhhP P h XOR(#   h&0*0*0* For Example... This macro averages a series of numbers and returns the quotient value of the average. ASSIGN(Last;0) GETNUMBER(HowMany;"How many numbers do you have to average") ASSIGN(Y;0) FORNEXT(Count;1;HowMany) h GETNUMBER(INDIRECT("Number"+Count);"Enter in a number ")(# h ASSIGN(last;last+Indirect("Number"+Count))(# ENDFOR Type("The quotient of the average of ") FORNEXT(X;1;HowMany) h TYPE(Indirect("Number"+x)+"+")(# ENDFOR DeleteCharPrevious Type(" is "+last DIV howmany)0'0*0*0* DLGCONTROL Show Me An Example...  DLGCONTROL add controls such as check boxes, push buttons and radio buttons to a dialog box. This command customizes the appearance and use of a dialog box and must be used between DLGCREATE and DLGEND commands. Syntax:8hP P h DLGCONTROL(Type;Variable;"Title";Style;Horizontal Position;Vertical Position;Wide;High)(# Parameters:P P h Type(# h hhhP P h Specifies the control type to add to the dialog box. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+h.Numeric87h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+h.Equivalent(# h hhhP P h (# h hhhP P h CtrlLabel!XX%h(h((+h.0h1h``4h7h00:Not numbered and cannot be selected. Useful for adding descriptive text to a dialog. Does not require the Variable parameter.(#0 h hhhP P h CtrlOption!XX%h(h((+h.1h1h``4h7h00:A numbered menu item that can be selected. Forces an exit from a dialog box when selected. Does not require the Variable parameter.(#0 h hhhP P h CtrlPushbutton!p((+h.2h1h``4h7h00:h=A push button that forces an exit when selected. Does not require the Variable parameter.(# h hhhP P h CtrlCheckbox!(h((+h.3h1h``4h7h00:h=A numbered check box that can be selected. If the variable parameter is 0, the checkh)(0*0*0* box will not be checked. When the dialog is dismissed, the variable will return the state of the control (0=Checkbox not marked, 1=Checkbox marked).(# h hhhP P h CtrlRadiobutton!p((+h.4h1h``4h7h00:h=A numbered radio button. If the variable parameter is 0, the radio button will not be selected. When the dialog is dismissed, the variable will return the state of the control (0=Radio button not selected, 1=Radio button selected). To be in the same group, radio button controls must be consecutive. Radio buttons are mutually exclusive.(# h hhhP P h CtrlNumber!XX%h(h((+h.5h1h``4h7h00:A numbered entry field that accepts only positive numbers. The variable sets the initial value and when the dialog is dismissed, returns the value of the control.(#0h))0*0*0*Ԍh hhhP P h CtrlMeasure!(h((+h.6h1h``4h7h00:h=An entry field that accepts only measurements. The measurement is displayed in the current unit of measurement. The variable sets the initial value and when the dialog is dismissed, returns the value of the control.(# h hhhP P h CtrlText!XX%h(h((+h.7h1h``4h7h00:h=An entry field that accepts a single line of text. The line length allowed is determined by the width parameter.(# h hhhP P h CtrlFilename!(h((+h.8h1h``4h7h00:h=An entry field that accepts only ASCII characters and no spaces. The variable set the initial value and when the dialog is dismissed, returns the value of the control.(# h hhhP P h CtrlList!XX%h(h((+h.9h1h``4h7h00:h=A list box. The variable must be the name of an array that defines each item in the list. The array requirements are: Var[0]=numberh)*0*0*0* of items in list box. Var[1] Var[x]=each list box item.(# h hhhP P h CtrlDropList!(h((+h.10h1h``4h7h00:h=A drop list. Same requirements for CtrlList! above.(# h hhhP P h (# h hhhP P h Variable (optional)(# h hhhP P h Sets values to and returns values from the controls. See control type descriptions for information on how the variable works with specific controls.(# h hhhP P h Title (optional)(# h hhhP P h A character expression specifying the control title. To create a mnemonic letter in the title, precede the letter with a tilde (~).(# h hhhP P h Style (optional)(# h hhhP P h Specifies a control style. The styles can be concatenated with a plus sign (+), for example, (StyNoSpaces!+StyNoNumber!). Select an enumerated type or its numeric equivalent.(# h 8P P h h Enumerated(h((+h.Numeric87h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h StyOK!8"hXX%h(h((+h.1h1h``4h7h00:Makes a CtrlPushButton! function as the OK button. The variable will be 0 if the pushbutton dismissed the dialog.(#0 h hhhP P h StyCancel!XX%h(h((+2h.h1h``4h7Makes a CtrlPushButton! function as the Cancel button. The variable will be 1 if the pushbutton dismissed the dialog.(# h hhhP P h StySigned!XX%h(h((+4h.h1h``4h7Allows CtrlNumber! control to accept negative numbers.(# h hhhP P h StyCounter!XX%h(h((+8h.h1h``4h7Adds counter controls (up/downh)+0*0*0* arrows) to the CtrlNumber! control.(# h hhhP P h StyNoSpaces!(h((+h.16h1h``4h7h00:Prohibits spaces from being entered in the CtrlText! control. With this style, the space bar will terminate input.(#0 h hhhP P h StyNoBox!XX%h(h((+h.32h1h``4h7h00:Removes the box surrounding list or entry controls in Text Mode.(#0 h hhhP P h StyNoSort!XX%h(h((+64h.h1h``4h7Prevents items in a list control from being sorted.(# h hhhP P h StyChild!XX%h(h((+h.128``4h7h00:Makes the control a child or subcontrol of the previous nonchild control.(#0 h hhhP P h StyNoScroll!(h((+h.256``4h7h00:Turns off the scroll bar on a CtrlList! control.(#0 h hhhP P h StyNoNumber!(h((+h.512``4h7h00:Removes the number on a numbered control. A control with this style cannot be selected with a number, however mnemonics can still be used.(#0 h hhhP P h StyDancing!XX%h(h((+10241h``4h7Allows a control to display only when it can be selected.(# h hhhP P h StyNoPeriod!(h((+h.2048``4h7h00:Removes the period after a control number.(#0 h hhhP P h StyGray!8"hXX%h(h((+40961h``4h7Prevents a control from being selected.(# h hhhP P h StyMnemonic!(h((+h.8192``4h7h00:Replaces the control number with the mnemonic character specified in the title parameter. (#0 h hhhP P h StyInitial!XX%h(h((+163841h``4h7Specifies the control as the active control when a dialog ish),0*0*0* initially displayed.(# h hhhP P h StyDefault!XX%h(h((+327681h``4h7Specifies the control as the default control. Any time the cursor would normally return to the OK button, it will move to this control instead.(# h hhhP P h (# h hhhP P h Horizontal Position (optional)(# h hhhP P h A numeric expression specifying the horizontal position of the control within the dialog. The position is determined in character spaces by rows and columns with 0 being the first column, first row (upper left position).(# h hhhP P h Vertical Position (optional)(# h hhhP P h See Horizontal Position parameter above.(# h hhhP P h Width (optional)(# h hhhP P h A numeric expression specifying the width of the control in character spaces. If this parameter is not specified, the control conforms to the size of the control title.(# h hhhP P h Height (optional)(# h hhhP P h See Width parameter description above. If this parameter is not specified, the height is set to 2.(# See Also:P P h DLGCREATE(# h hhhP P h DLGEND(#   X-0*0*0* For Example... This macro displays a dialog box with all the control options. chkbox:=1 num:=31 LstAry:={"One";"Uno";"Ein"} DLGCREATE(x;"TITLE";DLGNoCancel!;;;50;20) h DLGCONTROL(CtrlLabel!;;"Descriptive Label";StyGray!;1;1;5;1)(# h DLGCONTROL(CtrlOption!;;"Option";StyNoNumber!;30;3;10;2)(# h DLGCONTROL(CtrlPushButton!;;"Push(# h hButton";StyNoNumber!;4;5;11;2)(# h DLGCONTROL(CtrlCheckBox!;chkbox;"Check(# h hBox";StyNoNumber!;30;5;9;2)(# h DLGCONTROL(CtrlRadioButton!;VarRB;"Radio(# h hButton";StyInitial!;4;3;10;2)(# h DLGCONTROL(CtrlNumber!;num;"Number";StySigned!+StyCounter!;(# h h4;7;3;2)(# h DLGCONTROL(CtrlMeasure!;meas;"Measurement";StyNoNumber!+(# h hStyNoBox!;30;7;3;2)(# h DLGCONTROL(CtrlText!;txt;"Text";StyNoNumber!;4;9;35;2)(# h DLGCONTROL(CtrlFilename!;flname;"~Filename";StyMnemonic!;(# h h4;11;12;2)(# h DLGCONTROL(CtrlList!;LstAry;"List";StyNoSort!;4;13;12;3)(# h DLGCONTROL(CtrlDropList!;LstAry;"Drop List";StyNoSort!+(# h hStyNoNumber!;25;13;12;3)(# DLGENDP.0*0*0* DLGCREATE Show Me An Example...  DLGCREATE is the opening command for creating and displaying a dialog box. The dialog box is displayed when this command is encountered. This command must be followed by at least one control defined by DLGCONTROL. Syntax:8hP P h DLGCREATE(Variable;"Title";Style;Horizontal Position;Vertical Position;Width;Height)(# Parameters:P P h Variable(# h hhhP P h Specifies the variable containing the number of the Control used to dismiss the dialog.(# h hhhP P h Control8"hXX%h(h((+h.h1Numeric800:h=Description(# h hhhP P h h hh"hXX%h(h((+h.h1Equivalent(# h hhhP P h (# h hhhP P h OKh hh"hXX%h(h((+h.h10h``4h7h00:h=Dialog dismissed with OK(# h hhhP P h Cancel8"hXX%h(h((+h.h1h``4©1h7h00:h=h@Dialog dismissed with Cancel(# h hhhP P h Userdefined control .h1h``4Xh7h00:h=h@Where "X" is the number of the control. Control numbers are determined by the order in which they are created by a DLGCONTROL command. For example, the first control defined is 1, the second defined is 2, and so forth.(# h hhhP P h (# h hhhP P h Title(# h)/0*0*0*Ԍh hhhP P h A character expression specifying the dialog title.(# h hhhP P h Style(# h hhhP P h Specifies the dialog style. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h DlgNoOK!8"hXX%h(1h((+h.h1h``4Removes OK button(#` h hhhP P h DlgNoCancel!(h((+2h.h1h``4h7Removes Cancel button(# h hhhP P h DlgNoBorder!(h((+4h.h1h``4h7Removes border(# h hhhP P h DlgNoShadow!(h((+8h.h1h``4h7Removes shadow(# h hhhP P h DlgExit!8"hXX%h(16h((+h.h1h``4Dismisses the dialog immediately after the first key or control is pressed(#` h hhhP P h DlgNoClear!XX%h(32h((+h.h1h``4Does not save or restore the screen(#` h hhhP P h DlgInactive!(h((+64h.h1h``4h7Dialog displays while macro execution continues.(# h hhhP P h (# h hhhP P h Horizontal Position (optional)(# h hhhP P h A numeric expression specifying the horizontal position of the dialog. The position is determined in character spaces by rows and columns with 0 being the first column, first row (upper left position). If no position is specified, the dialog is centered.(# h hhhP P h Vertical Position (optional)(# h hhhP P h See Horizontal Position parameter above.(# h hhhP P h Width (optional)(# h hhhP P h A numeric expression specifying the width of the dialog in character spaces. If this parameter is not specified, the control is sized to accommodate the number of controls.(# h hhhP P h Height (optional)(# h hhhP P h See Width parameter above. ``4h7h00:h=h@(# See Also:P P h DLGCONTROL(# h hhhP P h DLGEND(#   %00*0*0* For Example... This macro displays a dialog box on the screen. Pending the user's response, the macro chains the correct macro. DISPLAY(Off!) DLGCREATE(x;"TITLE";DLGNoCancel!;;;30;14) h DLGCONTROL(CtrlRadioButton!;a;"Letter";StyInitial!;4;4;10;2)(# h DLGCONTROL(CtrlRadioButton!;b;"Itinerary";;4;6;10;2)(# h DLGCONTROL(CtrlRadioButton!;c;"Memo";;4;8;10;2)(# h DLGCONTROL(CtrlRadioButton!;d;"Fax";;4;10;10;2)(# DLGEND SWITCH (1) h CASEOF a : CHAIN("letter")(# h CASEOF b : CHAIN("Itin")(# h CASEOF c : CHAIN("memo")(# h CASEOF d : CHAIN("fax")(# ENDSWITCHH 10*0*0* DLGEND Show Me An Example...  DLGEND is the closing command for creating and displaying dialog boxes. Syntax:8hP P h DLGEND(# Parameters:P P h None(# See Also:P P h DLGCONTROL(# h hhhP P h DLGCREATE(#    20*0*0* For Example... This macro displays a dialog box on the screen. Pending the user's response, the macro chains the correct macro. DISPLAY(Off!) DLGCREATE(x;"TITLE";DLGNoCancel!;;;30;14) h DLGCONTROL(CtrlRadioButton!;a;"Letter";StyInitial!;4;4;10;2)(# h DLGCONTROL(CtrlRadioButton!;b;"Itinerary";;4;6;10;2)(# h DLGCONTROL(CtrlRadioButton!;c;"Memo";;4;8;10;2)(# h DLGCONTROL(CtrlRadioButton!;d;"Fax";;4;10;10;2)(# DLGEND SWITCH (1) h CASEOF a : CHAIN("letter")(# h CASEOF b : CHAIN("Itin")(# h CASEOF c : CHAIN("memo")(# h CASEOF d : CHAIN("fax")(# ENDSWITCHH 30*0*0* DLGINPUT Show Me An Example...  DLGINPUT determines whether to suspend macro execution while a dialog box is displayed. If execution is suspended, the user must close the dialog box before the macro continues. If execution is not suspended, the macro can be programmed to make selections in the dialog box as well as close it. The default macro state is DLGINPUT(Off!). Syntax:8hP P h DLGINPUT(State)(# Parameters:P P h State(# h hhhP P h Specified whether macro execution is suspended. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Off!h"hXX%h(0h((+h.h1h``4Suspend macro execution(#` h hhhP P h On!h"hXX%h(1h((+h.h1h``4Do not suspend Macro execution(#` h hhhP P h (#   40*0*0* For Example... This macro retrieves and prints all documents in the default directory. DISPLAY(On!) DLGInput(on!) // allows keystrokes to be sent to a dialog box FileManagerDlg HardReturn DownArrow tot:=?List2 Cancelkey cnt:=1 WHILE(tot<>cnt) FileManagerDlg FileManagerDlg DownArrow type("1") //opens the highlighted document PrintFullDoc ExitDlg Type("nn") //"No" to save and "No" to exit WordPerfect cnt:=cnt+1 ENDWHILE050*0*0* ELSE Show Me An Example  ELSE is used with the IF command to specify macro commands to execute when the IF statement is false. Commands placed between the ELSE and the ENDIF commands are executed only if the value of the relational expression in the IF statement is false. If ELSE is not used within an IF statement, and if the statement is false, the macro moves to the command following ENDIF and resumes execution. Syntax:8hP P h ELSE(# Parameters:P P h None(# See Also:P P h IF(# h hhhP P h ENDIF(#   60*0*0* For Example... This macro prints the current document path and filename in a footer. IF(?Name<>"") FooterB(Create!) TYPE(?Path+?Name) SubstructureExit ELSE PROMPT("The file hasn't been saved yet. Please save and rerun the macro.") PAUSE ENDIF( 70*0*0* ENDFOR Show Me An Example...  ENDFOR is the closing command for a FORNEXTENDFOR and a FOREACHENDFOR loop. Syntax:8hP P h ENDFOR(# Parameters:P P h None(# See Also:P P h FORNEXT(# h hhhP P h FOREACH(#    80*0*0* For Example... ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILE 90*0*0* ENDFUNC Show Me An Example...  ENDFUNC is the closing command for a FUNCTION definition. Syntax:8hP P h ENDFUNC(# Parameters:P P h None(# See Also:P P h FUNCTION(#   ` :0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNC;0*0*0* ENDIF Show Me An Example...  ENDIF is the closing command for an IFENDIF conditional statement. Syntax:8hP P h ENDIF(# Parameters:P P h None(# See Also:P P h ELSE(# h hhhP P h IF(#    <0*0*0* For Example... This macro prints the current document path and filename in a footer. IF(?Name<>"") FooterB(Create!) TYPE(?Path+?Name) SubstructureExit ELSE PROMPT("The file hasn't been saved yet. Please save and rerun the macro.") PAUSE ENDIF( =0*0*0* ENDPROC Show Me An Example...  ENDPROC is the closing command for a PROCEDURE definition. Syntax:8hP P h ENDPROC(# Parameters:P P h None(# See Also:P P h PROCEDURE(#   ` >0*0*0* For Example... This macro prompts for a file to retrieve. It then calls a Procedure to retrieve the file. GLOBAL(Path;Filename) LABEL(Begin) GetString(Path;"Enter the Path of the file to retrieve.") GetString(Filename;"Enter the filename to retrieve.") Retrieve()P P h //calls the procedure Retrieve(# Error(Off!) IF(?Name="") h GO(Begin)(# ENDIF QUIT PROCEDURE Retrieve() h ONERROR CALL(Error)(# h FileRetrieve(Path+Filename)(# ENDPROC LABEL(Error) Input("The File doesn't exist. Press Enter to continue") RETURN?0*0*0* ENDSWITCH Show Me An Example...  ENDSWITCH is the closing command for a SWITCHENDSWITCH conditional statement. Syntax:8hP P h ENDSWITCH(# Parameters:P P h None(# See Also:P P h SWITCH(#   ( @0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) HRt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCHA0*0*0* ENDWHILE Show Me An Example...  ENDWHILE is the closing statement for a WHILEENDWHILE loop. Syntax:8hP P h ENDWHILE(# Parameters:P P h None(# See Also:P P h WHILE(#   ` B0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH C0*0*0* ERROR Show Me An Example...  ERROR determines whether an error condition should be ignored while a macro is running. By default, an error is not ignored and generally stops macro execution. ERROR can also redirect execution with ONERROR. If an ONERROR command is encountered in the macro before an Error occurs, the macro is redirected to the LABEL specified in ONERROR. Syntax:8hP P h Error(State)(# Parameters:P P h State(# h hhhP P h Specifies whether to ignore errors. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+Numeric8``4h7h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h Off!h"hXX%h(h((+0h.h1h``4h7h00:Ignore errors(#0 h hhhP P h On!h"hXX%h(h((+1h.h1h``4h7h00:Do not ignore errors (#0 h hhhP P h (# See Also:P P h ASSERT(# h hhhP P h LABEL(# h hhhP P h ONERROR(#   D0*0*0* For Example... This macro prompts for a file to retrieve. It then calls a Procedure to retrieve the file. GLOBAL(Path;Filename) LABEL(Begin) GetString(Path;"Enter the Path of the file to retrieve.") GetString(Filename;"Enter the filename to retrieve.") Retrieve()P P h //calls the procedure Retrieve(# Error(Off!) IF(?Name="") h GO(Begin)(# ENDIF QUIT PROCEDURE Retrieve() h ONERROR CALL(Error)(# h FileRetrieve(Path+Filename)(# ENDPROC LABEL(Error) Input("The File doesn't exist. Press Enter to continue") RETURNE0*0*0* EXISTS Show Me An Example...  EXISTS is used in conjunction with other commands, such as IF, to determine if the specified variable exists. For a variable to exist, it must have been assigned a value. The value returned represents the variable table the variable table in which the variable exists. h hhhP P h Valueh"hXX%h(h((+Description(#( h hhhP P h (# h hhhP P h 0h hh"hXX%h(h((+Does not exist(#( h hhhP P h 1h hh"hXX%h(h((+Exists in local table(#( h hhhP P h 2h hh"hXX%h(h((+Exists in global table(#( h hhhP P h 3h hh"hXX%h(h((+Exists in persist table(#( h hhhP P h (# Syntax:8hP P h EXISTS(Variable)(# Parameters:P P h Variable(# h hhhP P h Specifies the variable to evaluate.(# See Also:P P h ENDIF(# h hhhP P h GLOBAL(# h hhhP P h IF(# h hhhP P h LOCAL(# h hhhP P h PERSIST(#   F0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNCG0*0*0* FOREACH Show Me An Example...  FOREACH is the opening command of a FOREACHENDFOR conditional loop. A FOREACH loop executes all commands between FOREACH and ENDFOR. The number of times this loop executes depends on the number of items specified between the braces ({}). For example, if the command contains four Item parameters, the loop runs four times. Each time the loop executes, the next item is assigned to the variable specified in the Variable parameter. When the variable contains the value of the last item, the loop executes a final time. The macro then proceeds to the command immediately following ENDFOR and resumes. Syntax:8hP P h FOREACH(Variable;{Item1;Item2;...ItemN})(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. The variable specified here will contain the first item, and is replaced by the next item with each repetition of the loop.(# h hhhP P h Item(# h hhhP P h A character expression, numeric expression, or measurement expression specifying the item to assign to the variable.(# See Also:P P h ENDFOR(# h hhhP P h FORNEXT(#   8H0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH I0*0*0* FORNEXT Show Me An Example...  FORNEXT is the opening command of a FORNEXTENDFOR conditional loop. The FORNEXT command begins a loop which executes all commands between the FORNEXT and its corresponding ENDFOR a specific number of times. The commands between FORNEXT and ENDFOR are executed until the Variable parameter exceeds the Stop parameter. When the loop has executed the specified number of times, the macro proceeds to the command immediately following ENDFOR and resumes. Syntax:8hP P h FORNEXT(Variable;Start;Stop;Step)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. The variable specified here initially contains the value of the Start parameter, and will be replaced by an incremented (or decremented) value with each repetition of the loop.(# h hhhP P h Start(# h hhhP P h A numeric expression or a measurement expression specifying the initial value of the loop.(# h hhhP P h Stop(# h hhhP P h A numeric expression or a measurement expression specifying the value to terminate the loop.(# h hhhP P h Step (optional)(# h hhhP P h A numeric expression or a measurement expression specifying the value with which to increment the Variable parameter. If this parameter is not specified, the Variable parameter is incremented (or decremented) by a value of 1.(# See Also:P P h ENDFOR(# h hhhP P h FOREACH(#   @J0*0*0* For Example... This macro creates a user specified number of return labels. Display(Off!) GetNumber(tot;"How many return address labels would you like?") FORNEXT(cnt;1;tot;1) Type("Your name") Hrt Type("Your company") Hrt Type("Your address") Hrt Type("City, State ZIP") Hpg ENDFOR K0*0*0* FRACTION Show Me An Example...  FRACTION returns the fractional portion of a numeric expression. For example, since the quotient of 3/2 is 1.5, FRACTION(3/2) returns the value 0.5. This command is generally used in conjunction with commands such as IF, ASSIGN, or Type. Syntax:8hP P h FRACTION(Number)(# Parameters:P P h Number(# h hhhP P h A numeric expression specifying the number to evaluate. This numeric expression often contains a mathematical operation such as division.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h INTEGER(# h hhhP P h Type(#   hL0*0*0* For Example... This macro prompts for a numerator followed by a denominator and performs the division of the two numbers. The macro returns the integer value of the nearest whole number. DISPLAY(Off!) GETNUMBER(num1;"Enter the numerator") GETNUMBER(num2;"Enter the denominator") x:=FRACTION(num1/num2) y:=INTEGER(num1/num2) IF(x>=0.5) num:=y+1 ELSE num:=y ENDIF type(num) M0*0*0* FUNCTION Show Me An Example...  FUNCTION is the opening command for a FUNCTIONENDFUNC definition. A FUNCTION is a subroutine to which you can pass information and from which you can receive information. FUNCTION defines the function name and the parameter names as well as includes a series of commands to be executed when the FUNCTION is called. A RETURN command is used in the FUNCTION to return the result of the function operation. If RETURN is not used, the FUNCTION will return a value of 0. Commands after an ENDFUNC are ignored, so all FUNCTIONs should be placed at the end of a macro. Also, a FUNCTION cannot be defined within another FUNCTION definition. Creating and calling FUNCTIONs is much like creating, filling in, and executing your own Macro Commands. The function name is comparable to a command name and the parameter names represent aspects of the FUNCTION that can be manipulated. For example, you could create a FUNCTION that returns the average of six numbers. The sequence of commands would look like this: FUNCTION Avg(N1;N2;N3;N4;N5;N6) h Sum=N1+N2+N3+N4+N5+N6(# h Average=Sum/6(# h RETURN(Average)(# ENDFUNC Notice that the FUNCTION name is Avg and that the parameters do not contain any information; they are simply "holding places" for number one, number two, etc.. The actual numbers to fill in the parameters will be passed when the FUNCTION is called. The RETURN command returns the contents of variable Average to the location from which the FUNCTION is called. To call a FUNCTION, you simply state the function name and fill in the parameters. You must pass the same number of parameters as originally defined in the FUNCTION. Since the FUNCTION can return information, it must be called from within a command or statement that can evaluate its contents or perform an action such as IF, ASSIGN, or Type. For example, to call FUNCTION Avg and type the average of the six numbers passed to it, the command is: Type(Avg(4;10;65;9;11;47)) FUNCTIONs can be in the macro from which they are called, in another macro, or they can be combined into a macro file library. This library is a macro that doesn't execute, but simply contains FUNCTIONs that may be useful in many macros. If a FUNCTION isn't defined in the macro that calls it, the USE command must be placed in the calling macro to identify which macro contains theh)N0*0*0* FUNCTION. If you are storing FUNCTIONs in a macro file library, the file must be compiled before it can be used. To compile, simply play the macro. Syntax:8hP P h FUNCTION Name(Parameter1;Parameter2;...ParN)(# Parameters:P P h Function Name(# h hhhP P h Specifies the FUNCTION name. Although this parameter is usually text, it is not considered a character expression and should not be in quotes.(# h hhhP P h Parameter (optional)(# h hhhP P h Specifies the parameter names to which information will be passed when the FUNCTION is called. If no parameters are specified, The FUNCTION can still be called, executed, and evaluated.(# See Also:P P h ASSIGN(# h hhhP P h ENDFUNC(# h hhhP P h GLOBAL(# h hhhP P h IF(# h hhhP P h LOCAL(# h hhhP P h PROCEDURE(# h hhhP P h Type(# h hhhP P h USE(#   O0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNC PP0*0*0* GETNUMBER Show Me An Example...  GETNUMBER displays a dialog box in which the user enters a numeric expression. When the dialog box displays, the macro pauses and allows the user to enter in a number. The number is then assigned to the variable specified in the Variable parameter. If the user enters a keystroke other than a number, the value of 0 is assigned to the variable. Syntax:8hP P h GETNUMBER(Variable;"Prompt";"Title")(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. The variable contains the number entered by the user.(# h hhhP P h Prompt (optional)(# h hhhP P h A character expression specifying the prompt in the dialog box.(# h hhhP P h Title (optional)(# h hhhP P h A character expression specifying the title of the dialog box.(# See Also:P P h GETSTRING(# h hhhP P h GETUNITS(#   Q0*0*0* For Example... This macro creates a user specified number of return labels. DISPLAY(Off!) GETNUMBER(tot;"How many return address labels would you like?") FORNEXT(cnt;1;tot;1) Type("Your name") HRt Type("Your company") HRt Type("Your address") HRt Type("City, State ZIP") HPg ENDFOR R0*0*0* GETSTRING Show Me An Example...  GETSTRING displays a dialog box in which the user enters a character expression. When the dialog box displays, the macro pauses while the user types in text. If the optional Length parameter is specified, the dialog box prevents the user from entering more text than the number of characters specified. The text is assigned to the variable specified in the Variable parameter. Syntax:8hP P h GETSTRING(Variable;"Prompt";"Title";Length)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. The variable contains the text typed in by the user.(# h hhhP P h Prompt (optional)(# h hhhP P h A character expression specifying the prompt in the dialog box.(# h hhhP P h Title (optional)(# h hhhP P h A character expression specifying the title of the dialog box.(# h hhhP P h Length (optional)(# h hhhP P h A numeric expression specifying, in characters, the maximum amount of text allowed.(# See Also:P P h GETNUMBER(# h hhhP P h GETUNITS(#   S0*0*0* For Example... This macro prompts for a character and returns its ascii equivalent. GETSTRING(x;"Enter a character:") ascii:=CTON(x) PROMPT("The ASCII equivalent of "+x+" is "+ascii+".") PAUSE@T0*0*0* GETUNITS Show Me An Example...  GETUNITS displays a dialog box in which the user enters a measurement expression and, optionally, a unit of measurement character (",i,u,p). When the dialog box displays, the macro pauses while the user types in a measurement. If no character is specified, the macro will use the default unit of measurement. Syntax:8hP P h GETUNITS(Variable;"Prompt";"Title")(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. The variable contains the measurement entered by the user.(# h hhhP P h Prompt (optional)(# h hhhP P h A character expression specifying the prompt in the dialog box.(# h hhhP P h Title (optional)(# h hhhP P h A character expression specifying the title of the dialog box.(# See Also:P P h GETNUMBER(# h hhhP P h GETSTRING(#   U0*0*0* For Example... This macro prompts for and sets top and bottom margins. SAVESTATE AutoCodePlacement(On!) SetupSave GETUNITS(margint;"Enter top margin";"Margin") GETUNITS(marginb;"Enter bottom margin";"Margin") MarginTop(margint) MarginBottom(marginb)V0*0*0* GLOBAL Show Me An Example...  GLOBAL specifies variables to be used in the current macro, in FUNCTION's or PROCEDURE's of the current macro, or chained or nested macros. Syntax:8hP P h GLOBAL(Var1;Var2;...VarN)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. (# See Also:P P h CHAIN(# h hhhP P h FUNCTION(# h hhhP P h LOCAL(# h hhhP P h NEST(# h hhhP P h PERSIST(# h hhhP P h PROCEDURE(#   W0*0*0* For Example... This macro prompts for a file to retrieve. It then calls a Procedure to retrieve the file. GLOBAL(Path;Filename) LABEL(Begin) GETSTRING(Path;"Enter the Path of the file to retrieve.") GETSTRING(Filename;"Enter the filename to retrieve.") Retrieve()P P h //calls the procedure Retrieve(# ERROR(Off!) IF(?Name="") h GO(Begin)(# ENDIF QUIT PROCEDURE Retrieve() h ONERROR CALL(Error)(# h FileRetrieve(Path+Filename)(# ENDPROC LABEL(Error) INPUT("The File doesn't exist. Press Enter to continue") RETURNX0*0*0* GO Show Me An Example...  GO redirects macro execution to the label specified in the Label parameter. Syntax:8hP P h GO(Label)(# Parameters:P P h Label(# h hhhP P h Specifies the label to which the macro should be directed. The specified label must match a label specified by a LABEL command elsewhere in the macro.(# See Also:P P h CALL(# h hhhP P h LABEL(#   Y0*0*0* For Example... This macro searches for a period (.) followed by two spaces and capitalizes the first letter of the next sentence. DISPLAY(Off!) PosDocTop CALL(Convert) ONNOTFOUND(NotFnd) LABEL(Begin) SearchString(". ") SearchNext CALL(Convert) GO(Begin) LABEL(Convert) BlockOn(CharMode!) PosCharNext ConvertCaseUppercase BlockOff RETURN LABEL(NotFnd) DISPLAY(On!) PROMPT("It's finished. Press ENTER to continue.") PAUSE PosDocTopZ0*0*0* IF Show Me An Example...  IF is the opening command of a IFENDIF conditional statement. An IF statement permits the execution of a series of commands only if certain conditions exist. The IF command contains a relational expression that can be evaluated as true or false. For example, NUMBER>28 is a relational expression that could be either true or false depending on the value of variable NUMBER. When an IF expression is true, the commands directly after IF are executed. When an expression is false, the macro proceeds directly to the ENDIF command and resumes. To execute certain commands only when the IF expression is false, use ELSE. Syntax:8hP P h IF(Test)(# Parameters:P P h Test(# h hhhP P h A relational expression specifying the condition to evaluate.(# See Also:P P h AND(# h hhhP P h ELSE(# h hhhP P h ENDIF(# h hhhP P h NOT(# h hhhP P h OR(# h hhhP P h XOR(#   [0*0*0* For Example... This macro prints the current document path and filename in a footer. IF(?Name<>"") FooterB(Create!) TYPE(?Path+?Name) SubstructureExit ELSE PROMPT("The file hasn't been saved yet. Please save and rerun the macro.") PAUSE ENDIF( \0*0*0* INDIRECT Show Me An Example...  INDIRECT returns the contents of the specified variable. INDIRECT allows the variable name to be concatenated through any combination of character expressions, numeric expressions, or existing variables. This command is used in conjunction with other commands such as IF or Type. For Example: S1="New York" S2="Georgia" S3="Oregon" FORNEXT(A;1;3;1) h Type("The state of ")(# h Type(INDIRECT("S"+A))(# h Hardreturn(# ENDFOR In this example, INDIRECT creates the variable names S1, S2, and S3 by concatenating the character expression "S" and the variable A. The variable names have been created indirectly in the FORNEXT loop to eliminate the need to request them individually. Syntax:8hP P h INDIRECT(Variable)(# Parameters:P P h Variable(# h hhhP P h A combination of character expressions, numeric expressions, or variables specifying the variable name.(# See Also:P P h ASSIGN(#   ]0*0*0* For Example... This macro averages a series of numbers and returns the quotient value of the average. ASSIGN(Last;0) GETNUMBER(HowMany;"How many numbers do you have to average") ASSIGN(Y;0) FORNEXT(Count;1;HowMany) h GETNUMBER(INDIRECT("Number"+Count);"Enter in a number ")(# h ASSIGN(last;last+Indirect("Number"+Count))(# ENDFOR Type("The quotient of the average of ") FORNEXT(X;1;HowMany) h TYPE(Indirect("Number"+x)+"+")(# ENDFOR DeleteCharPrevious Type(" is "+last DIV howmany)0^0*0*0* INPUT Show Me An Example...  INPUT displays a prompt, pausing the macro while the user enters any necessary keystrokes. The macro remains paused until the user presses Enter or the command specified in the last PAUSESET. This command is similar to using PROMPT and PAUSE together. However, the PROMPT message is removed from the screen as soon as any key is pressed. INPUT is also similar to using STATUSPROMPT and PAUSE together. However, the STATUSPROMPT message is removed only by a blank STATUSPROMPT or by a blank INPUT. Syntax:8hP P h INPUT("Prompt")(# Parameters:P P h Prompt(# h hhhP P h A character expression specifying the prompt to display.(# See Also:P P h INPUT(# h hhhP P h PAUSE(# h hhhP P h PAUSESET(# h hhhP P h PROMPT(# h hhhP P h STATUSPROMPT(#   _0*0*0* For Example... This macro prompts for a file to retrieve. It then calls a Procedure to retrieve the file. GLOBAL(Path;Filename) LABEL(Begin) GETSTRING(Path;"Enter the Path of the file to retrieve.") GETSTRING(Filename;"Enter the filename to retrieve.") Retrieve()P P h //calls the procedure Retrieve(# ERROR(Off!) IF(?Name="") h GO(Begin)(# ENDIF QUIT PROCEDURE Retrieve() h ONERROR CALL(Error)(# h FileRetrieve(Path+Filename)(# ENDPROC LABEL(Error) INPUT("The File doesn't exist. Press Enter to continue") RETURN`0*0*0* INTEGER Show Me An Example...  INTEGER returns the integer portion of the specified numeric expression. For example, INTEGER(43/2) returns the value of 21. The fractional portion (0.5) is ignored. This command is generally used in conjunction with such commands as IF, ASSIGN, or Type. Syntax:8hP P h INTEGER(Number)(# Parameters:P P h Number(# h hhhP P h A numeric expression specifying the number to evaluate. This numeric expression often contains a mathematical operation such as division.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h FRACTION(# h hhhP P h Type(#   a0*0*0* For Example... This macro prompts for a numerator followed by a denominator and performs the division of the two numbers. The macro returns the integer value of the nearest whole number. DISPLAY(Off!) GETNUMBER(num1;"Enter the numerator") GETNUMBER(num2;"Enter the denominator") x:=FRACTION(num1/num2) y:=INTEGER(num1/num2) IF(x>=0.5) num:=y+1 ELSE num:=y ENDIF Type(num) b0*0*0* LABEL Show Me An Example...  LABEL marks a specific location, sometimes called a subroutine, in a macro. Execution can be directed to that location from anywhere in the macro using commands such as CALL, GO, ONCANCEL, ONERROR, and ONNOTFOUND. A macro can contain an unlimited number of LABEL commands, but each label must have a unique name. Label names cannot include spaces or be longer that thirty characters. Syntax:8hP P h LABEL(Label Name)(# Parameters:P P h Label Name(# h hhhP P h Specifies the label name. Although the name usually consists of text, it is not considered a character expression and should not be enclosed in quotation marks.(# See Also:P P h CALL(# h hhhP P h GO(# h hhhP P h ONCANCEL(# h hhhP P h ONERROR(# h hhhP P h ONNOTFOUND(#   c0*0*0* For Example... This macro searches for a period (.) followed by two spaces and capitalizes the first letter of the next sentence. DISPLAY(Off!) PosDocTop CALL(Convert) ONNOTFOUND(NotFnd) LABEL(Begin) SearchString(". ") SearchNext CALL(Convert) GO(Begin) LABEL(Convert) BlockOn(CharMode!) PosCharNext ConvertCaseUppercase BlockOff RETURN LABEL(NotFnd) DISPLAY(On!) PROMPT("It's finished. Press ENTER to continue.") PAUSE PosDocTopd0*0*0* LOCAL Show Me An Example...  LOCAL is used to ensure that a variable is local to a FUNCTION, PROCEDURE, or macro. Once the PROCEDURE or FUNCTION, or macro has executed, the local variables are discarded from memory and are no longer available. Syntax:8hP P h LOCAL(Var1;Var2;...VarN)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter.(# See Also:P P h DISCARD(# h hhhP P h FUNCTION(# h hhhP P h GLOBAL(# h hhhP P h PERSIST(# h hhhP P h PERSISTALL(# h hhhP P h PROCEDURE(#   he0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNCf0*0*0* LOOK Show Me An Example...  LOOK evaluates whether a key was pressed by the user. If a key has been pressed, the numeric equivalent of the key is assigned to the variable specified in the Variable parameter. If a key has not been pressed, the contents of the variable is assigned the value of 0 and the macro continues. LOOK is most useful in macros that execute certain commands only if a specific key is pressed. This command is used in conjunction with commands designed to evaluate expressions such as SWITCH, IF, or REPEAT. For a list of the keys and their numeric equivalents, see Appendix A in the Appendices section. Syntax:8hP P h LOOK(Variable)(# Parameters:P P h Variable(# h hhhP P h Specifies the variable to contain the numeric equivalent of the key.(# See Also:P P h SWITCH(# h hhhP P h IF(# h hhhP P h NTOC(# h hhhP P h REPEAT(#   Pg0*0*0* For Example... This macro counts keystrokes until the user presses CtrlEnter. STATUSPROMPT("Press Ctrl+Enter to quit") cnt:=0 REPEAT LOOK(info) IF((info<>0) AND (info<>8097)) cnt:=cnt+1 Type(NTOC(info)) ENDIF UNTIL(info=8097) STATUSPROMPT("") PAUSESET(EndFieldKey) PROMPT("You pressed "+cnt+" keystrokes. Press F9 to continue") PAUSE h0*0*0* MENULIST Show Me An Example...  MENULIST displays a dialog box containing the specified menu items. The items displayed in the dialog box are numbered automatically. The number of the item selected by the user is assigned to the variable specified in the Variable parameter. Once the variable has been assigned, it can be evaluated with such commands as IF or SWITCH. Syntax:8hP P h MENULIST(Variable;{"Item1";"Item2";..."ItemN"};"Title";Horizontal Position;Vertical Position)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter. The variable contains the number of the selected item.(# h hhhP P h Item(# h hhhP P h A character expression specifying the item.(# h hhhP P h Title (optional)(# h hhhP P h A character expression specifying the title of the dialog box.(# h hhhP P h Horizontal Position (optional)(# h hhhP P h A numeric expression specifying the horizontal position of the dialog box. If this parameter is not specified, the dialog will be centered.(# h hhhP P h Vertical Position (optional)(# h hhhP P h A numeric expression specifying the vertical position of the dialog box. If this parameter is not specified, the dialog will be centered.(# See Also:P P h SWITCH(# h hhhP P h IF(#   i0*0*0* For Example... This macro displays a menu from which the user chooses to whom they are writing a letter. TYPE("Dear ") MENULIST(choice;{"WordPerfect Corp";"Mom and Dad";"President of the US"}) SWITCH(choice) h CASEOF 1 : Type("Customer Support")(# h CASEOF 2 : Type("Mom and Dad")(# h CASEOF 3 : Type("Mr. President")(# ENDSWITCH Type(",") Hrt Hrt j0*0*0* NEST Show Me An Example...  NEST temporarily transfers control from the current macro to another macro. The transfer occurs when this command is encountered in the current macro. When the nested macro is complete, control returns to the parent macro and continues. Syntax:8hP P h NEST("Macro")(# Parameters:P P h Macro(# h hhhP P h A character expression specifying the macro to nest. The path and .WPM extension are optional.(# See Also:P P h CHAIN(#   H k0*0*0* For Example... This macro nests a macro RTRN_ADD.WPM which types a users return address. It then allows the user to fill in the inside address and salutation. NEST("rtrn_add.wpm") Hrt Hrt STATUSPROMPT("Enter the inside address and press F9 to continue") PAUSECOMMAND(EndField) Hrt Hrt Type("Dear ") STATUSPROMPT("Enter the salutation and press Enter") PAUSE STATUSPROMPT("") Type(",") Hrt Hrtl0*0*0* NEXT Show Me An Example...  NEXT executes the next cycle or iteration of a FORNEXT, FOREACH, WHILE or REPEAT loop. Usually, the ENDFOR, ENDWHILE, or UNTIL command ends the current iteration and directs execution to the beginning of the loop to start the next iteration. NEXT sends execution to the next iteration from a location other than at the end of the loop. For example, you might use nested IF statements as part of the loop and if a specific condition exists, NEXT causes the remaining commands to be ignored and the loop proceeds directly to the next iteration. Syntax:8hP P h NEXT(# Parameters:P P h None(# See Also:P P h BREAK(# h hhhP P h FORNEXT(# h hhhP P h FOREACH(# h hhhP P h REPEAT(# h hhhP P h WHILE(#   m0*0*0* For Example... This macro parses an array and displays the student name and grade. student[1]:="Mark B. PE 132 A" student[2]:="Kerry R. Physics 305 B" student[3]:="Ralph D. CS 351 A" student[4]:="John B. Math 402 B" FORNEXT(x;1;4;1) h len:=STRLEN(student[x])(# h namepos:=STRPOS(student[x];" ")(# h IF((len=0) OR (namepos=0))(# h hNEXT(# h hname:="xxx"(# h ENDIF(# h name:=SUBSTR(student[x];1;namepos1)(# h grade:=SUBSTR(student[x];len;1)(# h Type(name)(# h FORNEXT(space;1;15namepos;1)(# h hType(" ")(# h ENDFOR(# h Type(grade)(# h HRt(# ENDFORn0*0*0* NOT Show Me An Example...  NOT is an operator that evaluates an expression in a conditional statement and/or returns the complement of an expression. This command performs a logical NOT. Use NOT when you want the conditional statement to be evaluated as true only if the complement of the expression is true, in other words, NOT true means it is false. This operator is used in conjunction with such commands as IF, REPEAT, and WHILE. Syntax:8hP P h NOT(# Parameters:P P h None(# See Also:P P h AND(# h hhhP P h IF(# h hhhP P h OR(# h hhhP P h REPEAT(# h hhhP P h WHILE(# h hhhP P h XOR(#   o0*0*0* For Example... This macro places the path and filename of the current document in a header. Header:=1=1 ONNOTFOUND CALL(Assign) PosDocVeryTop SearchString("[Header A]") SearchNext() NOTFOUND(Off!) IF(NOT Header) h HeaderA(Create!)(# ELSE h HeaderA(Edit!)(# ENDIF DeleteToEndOfLine Type(?Path+?Name) SubstructureExit QUIT LABEL(ASSIGN) Header:=1=0 RETURN0p0*0*0* NOTFOUND Show Me An Example...  NOTFOUND determines whether to ignore a Not Found condition during macro execution. A Not Found condition most commonly occurs when a search fails. By default, Not Found conditions are not ignored and will generally stop the macro. NOTFOUND can also be used to redirect macro execution with ONNOTFOUND. If an ONNOTFOUND command occurs in the macro before a Not Found condition occurs, the macro is redirected to the label specified by ONNOTFOUND. Syntax:8hP P h NOTFOUND(State)(# Parameters:P P h State(# h hhhP P h Specifies whether to ignore a Not Found. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+Numeric8``4h7h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h Off!h"hXX%h(h((+0h.h1h``4h7h00:Ignore Not Found(#0 h hhhP P h On!h"hXX%h(h((+1h.h1h``4h7h00:Do not ignore Not Found(#0 h hhhP P h (# See Also:P P h ASSERT(# h hhhP P h ?NotFound(# h hhhP P h ONNOTFOUND(#   8q0*0*0* For Example... This macro places the path and filename of the current document in a header. Header:=1=1 ONNOTFOUND CALL(Assign) PosDocVeryTop SearchString("[Header A]") SearchNext() NOTFOUND(Off!) IF(NOT Header) h HeaderA(Create!)(# ELSE h HeaderA(Edit!)(# ENDIF DeleteToEndOfLine Type(?Path+?Name) SubstructureExit QUIT LABEL(ASSIGN) Header:=1=0 RETURN0r0*0*0* NTOC Show Me An Example...  NTOC (Number To Character) converts a WordPerfect key value or character set number to its character equivalent. The number is equal to the character number multiplied by 256 plus the character number. For example, & is character 38 in Character Set 1. Multiply 256 times 1 (256), then add 38 (294). The NTOC of 294 is &. NTOC returns an empty string ("") if a number is used which has no character equivalent. Syntax:8hP P h NTOC(Number)(# Parameters:P P h Number(# h hhhP P h A numeric expression specifying the number to convert.(# See Also:P P h CTON(#   s0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH t0*0*0* NUMSTR Show Me An Example...  NUMSTR converts a numeric expression or a measurement expression to a character expression. Numbers converted with NUMSTR are regarded as text by the macro. This command is used in conjunction with commands that evaluates expressions such as ASSIGN or Type. Syntax:8hP P h NUMSTR(Number;Right Digits;Left Digits)(# Parameters:P P h Number(# h hhhP P h A numeric or measurement expression specifying the number to convert.(# h hhhP P h Right Digits (optional)(# h hhhP P h A numeric expression specifying the number of digits right of the decimal.(# h hhhP P h Left Digits (optional)(# h hhhP P h A numeric expression specifying the number of digits left of the decimal.(# See Also:P P h STRNUM(#   Pu0*0*0* For Example... This macro defines page numbering in the form Current of Total (1 of 5). DISPLAY(Off!) PosDocBottom TotPgNum:=?page PosDocTop TotPgStr:=NUMSTR(TotPgNum) PageNumberPosition(BottomCenter!;UseDefaultValues!) PageNumberFormat("[page #] of "+TotPgStr)v0*0*0* ONCANCEL Show Me An Example...  ONCANCEL directs macro execution to the specified LABEL command when a Cancel occurs. If an ONCANCEL command has not been encountered when a Cancel occurs, the macro will stop. If a Cancel occurs after two or more ONCANCEL commands, the macro is directed to the LABEL command specified in the last encountered ONCANCEL command in the active macro. ONCANCEL also includes the option of calling a LABEL if you use ONCANCEL CALL. This option of ONCANCEL can also call a PROCEDURE. If you call a LABEL, include a RETURN command at the end of the commands to be executed by the specified LABEL. This returns the macro execution to the command immediately following the command most recently executed when the Cancel occurred. Syntax:8hP P h ONCANCEL(Label)(# h hhhP P h or(# h hhhP P h ONCANCEL CALL (Label)(# Parameters:P P h Label(# h hhhP P h The label must correspond to a LABEL command within the macro. If using ONCANCEL CALL, this parameter can be a PROCEDURE.(# See Also:P P h ASSERT(# h hhhP P h LABEL(# h hhhP P h ONERROR(# h hhhP P h ONNOTFOUND(# h hhhP P h PROCEDURE(# h hhhP P h RETURN(#   w0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) HRt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCHx0*0*0* ONERROR Show Me An Example...  ONERROR directs macro execution to the specified LABEL command when an Error occurs. If ONERROR has not been encountered when an Error occurs, the macro will stop. If an Error occurs after two or more ONERROR commands, the macro is directed to the LABEL command specified in the last encountered ONERROR command in the active macro. ONERROR also includes the option of calling a LABEL if you use ONERROR CALL. This option of ONERROR can also call a PROCEDURE. If you call a LABEL, include a RETURN command at the end of the commands to be executed by the specified LABEL. This will return the macro execution to the command immediately following the command most recently executed when the Error occurred. Syntax:8hP P h ONERROR(Label)(# h hhhP P h or(# h hhhP P h ONERROR CALL (Label)(# Parameters:P P h Label(# h hhhP P h The label must correspond to a LABEL command within the macro. If using ONERROR CALL, this parameter can be a PROCEDURE.(# See Also:P P h ASSERT(# h hhhP P h LABEL(# h hhhP P h ONCANCEL(# h hhhP P h ONNOTFOUND(# h hhhP P h PROCEDURE(# h hhhP P h RETURN(#   y0*0*0* For Example... This macro prompts the user to highlight text in a document, and the macro assigns it to a variable. Display(On!) ONERROR(error) LABEL(Begin) BlockKey PROMPT("Highlight the text to assign to a variable and press Enter") PAUSE x:=?BlockedText IF (x="") ASSERT(ErrorCondition!) ENDIF h hhhP P //the user must place more code here to make(#P QUIThhP P h //this macro more functional(# LABEL(Error) BEEP DisplayRewrite PROMPT("You must select text to assign it to a variable") PAUSE GO(Begin)z0*0*0* ONNOTFOUND Show Me An Example...  ONNOTFOUND directs macro execution to a specified LABEL command when a Not Found condition occurs. Macro execution is directed to the LABEL command specified in the last encountered ONNOTFOUND command. If an ONNOTFOUND command has not been encountered when a Not Found condition occurs, the macro will stop. ONNOTFOUND also includes the option of calling a LABEL if you use ONNOTFOUND CALL. This option of ONNOTFOUND can also call a PROCEDURE. If you call a LABEL, include a RETURN command at the end of the commands to be executed by the specified LABEL. This will return the macro execution to the command immediately following the command most recently executed when the Not Found occurred. Syntax:8hP P h ONNOTFOUND(Label)(# h hhhP P h or(# h hhhP P h ONNOTFOUND CALL (Label)(# Parameters:P P h Label(# h hhhP P h The label must correspond to a LABEL command within the macro. If using ONNOTFOUND CALL, this parameter can be a PROCEDURE.(# See Also:P P h ASSERT(# h hhhP P h LABEL(# h hhhP P h ONCANCEL(# h hhhP P h ONERROR(# h hhhP P h PROCEDURE(# h hhhP P h RETURN(#   {0*0*0* For Example... This macro searches for a period (.) followed by two spaces and capitalizes the first letter of the next sentence. DISPLAY(Off!) PosDocTop CALL(Convert) ONNOTFOUND(NotFnd) LABEL(Begin) SearchString(". ") SearchNext CALL(Convert) GO(Begin) LABEL(Convert) BlockOn(CharMode!) PosCharNext ConvertCaseUppercase BlockOff RETURN LABEL(NotFnd) DISPLAY(On!) PROMPT("It's finished. Press ENTER to continue.") PAUSE PosDocTop|0*0*0* OR Show Me An Example...  OR is an operator that evaluates at least two expressions in a conditional statement. Conditional statements are created with commands such as IF, REPEAT, and WHILE. This operator performs a logical OR that evaluates a conditional statement as true if at least one expression is true. Parameters:P P h None(# See Also:P P h AND(# h hhhP P h DIV(# h hhhP P h IF(# h hhhP P h NOT(# h hhhP P h REPEAT(# h hhhP P h WHILE(# h hhhP P h XOR(#   }0*0*0* For Example... This macro parses an array and displays the student name and grade. student[1]:="Mark B. PE 132 A" student[2]:="Kerry R. Physics 305 B" student[3]:="Ralph D. CS 351 A" student[4]:="John B. Math 402 B" FORNEXT(x;1;4;1) h len:=STRLEN(student[x])(# h namepos:=STRPOS(student[x];" ")(# h IF((len=0) OR (namepos=0))(# h hNEXT(# h hname:="xxx"(# h ENDIF(# h name:=SUBSTR(student[x];1;namepos1)(# h grade:=SUBSTR(student[x];len;1)(# h Type(name)(# h FORNEXT(space;1;15namepos;1)(# h hType(" ")(# h ENDFOR(# h Type(grade)(# h HRt(# ENDFOR ~0*0*0* PAUSE Show Me An Example...  PAUSE pauses a macro until Enter is pressed while in a document or the command specified in PAUSESET is pressed. This command enables the user to type text or press keystrokes as if there were no macro running. PAUSE does not prompt the user so this command is generally used in conjunction with PROMPT, STATUSPROMPT, or BEEP. Syntax:8hP P h PAUSE(# Parameters:P P h None(# See Also:P P h BEEP(# h hhhP P h PAUSECOMMAND(# h hhhP P h PAUSEKEY(# h hhhP P h PAUSESET(# h hhhP P h PROMPT(# h hhhP P h STATUSPROMPT(#   00*0*0* For Example... This macro searches for a period (.) followed by two spaces and capitalizes the first letter of the next sentence. DISPLAY(Off!) PosDocTop CALL(Convert) ONNOTFOUND(NotFnd) LABEL(Begin) SearchString(". ") SearchNext CALL(Convert) GO(Begin) LABEL(Convert) BlockOn(CharMode!) PosCharNext ConvertCaseUppercase BlockOff RETURN LABEL(NotFnd) DISPLAY(On!) PROMPT("It's finished. Press ENTER to continue.") PAUSE PosDocTop0*0*0* PAUSECOMMAND Show Me An Example...  PAUSECOMMAND pauses a macro until the user executes the specified command. PAUSECOMMAND does not prompt the user, so this command is generally used in conjunction with PROMPT, STATUSPROMPT, or BEEP. Syntax:8hP P h PAUSECOMMAND(Command)(# Parameters:P P h Command(# h hhhP P h A macro command specifying the command to end the pause. Any product command is valid for this parameter, but a command such as HardReturn would be the most common.(# See Also:P P h BEEP(# h hhhP P h PAUSE(# h hhhP P h PAUSEKEY(# h hhhP P h PAUSESET(# h hhhP P h PROMPT(# h hhhP P h STATUSPROMPT(#   0*0*0* For Example... This macro nests a macro RTRN_ADD which types a users return address. It then allows the user to fill in the inside address and salutation. NEST("rtrn_add.wpm") Hrt Hrt STATUSPROMPT("Enter the inside address and press F9 to continue") PAUSECOMMAND(EndField) Hrt Hrt Type("Dear ") STATUSPROMPT("Enter the salutation and press Enter") PAUSE STATUSPROMPT("") Type(",") Hrt Hrt0*0*0* PAUSEKEY Show Me An Example...  PAUSEKEY pauses a macro until the specified key is pressed. PAUSEKEY does not prompt the user so this command is generally used in conjunction with PROMPT, STATUSPROMPT, or BEEP. Syntax:8hP P h PAUSEKEY(Key Name)(# Parameters:P P h Key Name(# h hhhP P h Specifies the key to end the pause. There are specific key names assigned to each key. For a list of the key names see Appendix B in the Appendices section.(# See Also:P P h BEEP(# h hhhP P h PAUSE(# h hhhP P h PAUSECOMMAND(# h hhhP P h PAUSESET(# h hhhP P h PROMPT(# h hhhP P h STATUSPROMPT(#   0*0*0* For Example... This macro beeps if the current document is blank and displays a message. DISPLAY(Off!) IF(?DocBlank) h BEEP(# h DISPLAY(On!)(# h PROMPT("The document is blank. Press Tab to continue")(# h PAUSEKEY(TabKey)(# h DISPLAY(Off!)(# h QUIT(# ENDIF( 0*0*0* PAUSESET Show Me An Example...  PAUSESET specifies the default key for PAUSE and INPUT. The key specified in PAUSESET replaces a hardreturn as the command to end a pause. Syntax:8hP P h PAUSESET(Command)(# Parameters:P P h Command(# h hhhP P h A macro command specifying the command to end the pause. Any product command is valid for this parameter, but a command such as HardReturn would be the most common.(# See Also:P P h INPUT(# h hhhP P h PAUSE(# h hhhP P h PAUSECOMMAND(# h hhhP P h PAUSEKEY(#   h0*0*0* For Example... This macro counts keystrokes until the user presses CtrlEnter. STATUSPROMPT("Press Ctrl+Enter to quit") cnt:=0 REPEAT LOOK(info) IF((info<>0) AND (info<>8097)) cnt:=cnt+1 Type(NTOC(info)) ENDIF UNTIL(info=8097) STATUSPROMPT("") PAUSESET(EndFieldKey) PROMPT("You pressed "+cnt+" keystrokes. Press F9 to continue") PAUSE 0*0*0* PERSIST Show Me An Example...  PERSIST allows the specified variables to be recognized and accessed by other macros, FUNCTIONS, PROCEDURES, and merges. Normally, variables are only recognized, and can only be used, by the macro in which they are defined. PERSIST allows variables to be shared among macros during the present session of WordPerfect. Variables Var0 through Var9 persist automatically. All other variables require this command to persist. Syntax:8hP P h PERSIST(Variable1;Variable2;...VariableN)(# Parameters:P P h Variable(# h hhhP P h Any variable is valid for this parameter.(# See Also:P P h ASSIGN(# h hhhP P h DISCARD(# h hhhP P h GLOBAL(# h hhhP P h LOCAL(# h hhhP P h PERSISTALL(#   0*0*0* For Example... This macro assigns the typist's initials to a variable and makes it accessible until WordPerfect is exited. GetString(init;"Enter the typist's initials.") IF(EXISTS(init)) h PERSIST(init) h//The variable INIT is now accessible in any macro(# ENDIFhhP P h h //and/or merge as long as WordPerfect is not exited. Access it through a merge with the VARIABLE command, and access it through a macro with a TYPE command.(# ` 0*0*0* PERSISTALL Show Me An Example...  PERSISTALL allows all variables in the current macro to be recognized and accessed by other macros, FUNCTIONS, PROCEDURES, and merges during the present session of WordPerfect. This command takes effect when it is encountered, so only those variables defined after this command will be available to other macros. Variables Var0 through Var9 persist automatically. Syntax:8hP P h PERSISTALL(# Parameters:P P h None(# See Also:P P h ASSIGN(# h hhhP P h DISCARD(# h hhhP P h GLOBAL(# h hhhP P h LOCAL(# h hhhP P h PERSIST(#   00*0*0* For Example... This macro prompts the user for a return address and assigns it to a series of variables. It then makes the variables accessible until WordPerfect is exited. DLGCREATE(x;"Return Address";DLGNoCancel!;;;50;10) h DLGCONTROL(CtrlText!;name;"Name";StyInitial!;1;3;37;2)(# h DLGCONTROL(CtrlText!;address;"Street Address";;1;5;27;2)(# h DLGCONTROL(CtrlText!;c;"City, State ZIP ";;1;7;25;2)(# DLGEND PERSISTALL Prompt("All the variables are now accessible in any macro/merge.") WAIT(50) 0*0*0* PRESSKEY Show Me An Example...  PRESSKEY executes the specified keystroke. Normally, PRESSKEY will execute the original function of a key even if the key has been remapped. If a key has been remapped through Keyboard Layout, you can use PRESSKEY in conjunction with the ?KeyPressed system variable to execute the new function of the key. For the list of keys and their numeric equivalents see Appendix A in the Appendices section. Syntax:8hP P h PRESSKEY(Key Value)(# Parameters:P P h Key Value(# h hhhP P h A numeric expression specifying the numeric equivalent of the keystroke to execute. This parameter can also contain the ?KeyPressed system variable.(# See Also:P P h CHAR(# h hhhP P h LOOK(#   0*0*0* For Example... This macro takes the number returned by the CHAR command and presses the corresponding key. CHAR(x;"Enter a character: ") Type("You pressed ") PRESSKEY(x)x0*0*0* PROCEDURE Show Me An Example...  PROCEDURE is the opening command for a PROCEDUREENDPROC definition. A PROCEDURE is a subroutine to which you can pass information. Unlike a FUNCTION, a PROCEDURE cannot return information. PROCEDURE defines the procedure name and the parameter names, and precedes the series of commands to be executed when the PROCEDURE is called. Commands after an ENDPROC are ignored, so all PROCEDUREs should be placed at the end of a macro. Creating and calling a PROCEDURE is much like calling a LABEL. However, unlike a LABEL, information can be passed to the PROCEDURE to customize the procedure operation. If variables are used in the PROCEDURE, they must first be made available to the PROCEDURE using GLOBAL or PERSIST. If variables are only to be used in the PROCEDURE, use LOCAL in the PROCEDURE definition. To call a PROCEDURE, you simply state the procedure name and fill in the parameters. The parameters can contain any expression, including variables. You must pass the same number of parameters as originally defined in the PROCEDURE. Since a PROCEDURE cannot return information, it should not be called from within another command or conditional statement. Also, a PROCEDURE cannot be called from within another PROCEDURE. PROCEDUREs can be in the macro from which they are called, in another macro, or they can be combined into a macro file library. This library is a macro that doesn't execute, but simply contains PROCEDUREs that may be useful in many macros. If a PROCEDURE isn't defined in the macro that calls it, the USE command must be placed in the calling macro to identify which macro contains the PROCEDURE. If you are storing PROCEDUREs in a macro file library, the file must be compiled before it can be used. To compile, simply play the macro. Syntax:8hP P h PROCEDURE ProcedureName(Parameter1;Parameter2;...ParN)(# Parameters:P P h Procedure Name(# h hhhP P h Specifies the PROCEDURE name. Although this parameter is usually text, it is not considered a character expression and should not be in quotes.(# h hhhP P h Parameter (optional)(# h hhhP P h Specifies the parameter names to which information will be passed when the PROCEDURE is called. If no parameters are specified, the PROCEDURE can still be called and executed.(# See Also:P P h ENDPROC(# h)0*0*0*Ԍh hhhP P h FUNCTION(# h hhhP P h GLOBAL(# h hhhP P h LOCAL(# h hhhP P h PERSIST(# h hhhP P h USE(#   0*0*0* For Example... This macro prompts for a file to retrieve. It then calls a Procedure to retrieve the file. GLOBAL(Path;Filename) LABEL(Begin) GETSTRING(Path;"Enter the Path of the file to retrieve.") GETSTRING(Filename;"Enter the filename to retrieve.") Retrieve()P P h //calls the procedure Retrieve(# ERROR(Off!) IF(?Name="") h GO(Begin)(# ENDIF QUIT PROCEDURE Retrieve() h ONERROR CALL(Error)(# h FileRetrieve(Path+Filename)(# ENDPROC LABEL(Error) INPUT("The File doesn't exist. Press Enter to continue") RETURN0*0*0* PROMPT Show Me An Example...  PROMPT displays a temporary prompt on the status line. The prompt is removed when a key is pressed, or the display is rewritten. PROMPT does not pause the macro, so it is usually used with PAUSE or WAIT. Syntax:8hP P h PROMPT("Prompt")(# Parameters:P P h Prompt(# h hhhP P h A character expression specifying the prompt.(# See Also:P P h BEEP(# h hhhP P h PAUSE(# h hhhP P h STATUSPROMPT(# h hhhP P h WAIT(#   0*0*0* For Example... This macro searches for a period (.) followed by two spaces and capitalizes the first letter of the next sentence. DISPLAY(Off!) PosDocTop CALL(Convert) ONNOTFOUND(NotFnd) LABEL(Begin) SearchString(". ") SearchNext CALL(Convert) GO(Begin) LABEL(Convert) BlockOn(CharMode!) PosCharNext ConvertCaseUppercase BlockOff RETURN LABEL(NotFnd) DISPLAY(On!) PROMPT("It's finished. Press ENTER to continue.") PAUSE PosDocTop0*0*0* QUIT Show Me An Example...  QUIT stops a macro. No commands following it are executed. If the current macro was started by another macro, both macros stop. Chained or nested macros will not execute after QUIT occurs. Syntax:8hP P h QUIT(# Parameters:P P h None(#   ( 0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) HRt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCH0*0*0* REPEAT Show Me An Example...  REPEAT is the opening command of a REPEATUNTIL conditional loop. A REPEATUNTIL loop continues to execute all commands between REPEAT and UNTIL until the condition set in UNTIL is true. Since the condition is evaluated at the end, a REPEATUNTIL loop always executes at least once regardless of whether the UNTIL condition is true or false. For information on conditional loops whose test expressions are evaluated at the top of the loop, see WHILE and ENDWHILE. Syntax:8hP P h REPEAT(# Parameters:P P h There are no parameters, but REPEAT is always followed by commands to execute at least once.(# See Also:P P h ENDWHILE(# h hhhP P h UNTIL(# h hhhP P h WHILE(#   00*0*0* For Example... This macro counts keystrokes until the user presses CtrlEnter. STATUSPROMPT("Press Ctrl+Enter to quit") cnt:=0 REPEAT LOOK(info) IF((info<>0) AND (info<>8097)) cnt:=cnt+1 Type(NTOC(info)) ENDIF UNTIL(info=8097) STATUSPROMPT("") PAUSESET(EndFieldKey) PROMPT("You pressed "+cnt+" keystrokes. Press F9 to continue") PAUSE 0*0*0* RETURN Show Me An Example...  RETURN marks the end of a series of commands initiated by LABEL, PROCEDURE, or FUNCTION. This command is usually used in conjunction with CALL. When RETURN is encountered, macro execution returns to the command immediately following the command that called the LABEL or PROCEDURE. If RETURN occurs within a FUNCTION, it also has the capability of returning information from the FUNCTION to the location from which it was called. RETURN is then followed by an expression enclosed in parentheses. The expression contains the value to return to the FUNCTION. Syntax:8hP P h RETURN or RETURN(Expression)(# Parameters:P P h Expression(# h hhhP P h Any expression is valid for this parameter. It is often a variable or a parameter name as defined by the FUNCTION to which it is returning.(# See Also:P P h CALL(# h hhhP P h FUNCTION(# h hhhP P h LABEL(# h hhhP P h ONCANCEL(# h hhhP P h ONERROR(# h hhhP P h ONNOTFOUND(# h hhhP P h PROCEDURE(#   p0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNC0*0*0* RUNUNATTENDED  RUNUNATTENDED allows a macro to continue running even if it encounters a situation that requires user input. Specifically, retrieving a passwordprotected file or trying to read from a disk drive not containing a disk both give error messages requiring action from the user. Normally, each of these situations will return an error that suspends macro execution until the user responds. However, if RUNUNATTENDED is used, the situation is canceled (no response is necessary) and macro execution can be redirected with ONERROR. Without RUNUNATTENDED, the macro is suspended until the user responds to the problem. Syntax:8hP P h RUNUNATTENDED(State)(# Parameters:P P h State(# h hhhP P h Specifies whether critical problems are canceled.(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Off!h"hXX%h(0h((+h.h1h``4Critical problems are not canceled; response required(#` h hhhP P h On!h"hXX%h(1h((+h.h1h``4Critical problems are canceled; no response required(#` h hhhP P h (# See Also:P P h ONERROR(#   0*0*0* SAVESTATE Show Me An Example...  SAVESTATE saves the current state of certain WordPerfect features and returns back to that state should a macro change it. SAVESTATE automatically saves the state of Autocode Placement, Replace Confirm, and WP51 Cursor Movement. Syntax:8hP P h SAVESTATE(# Parameters:P P h None(#    0*0*0* For Example... This macro prompts for and sets top and bottom margins. SAVESTATE AutoCodePlacement(On!) SetupSave GETUNITS(margint;"Enter top margin";"Margin") GETUNITS(marginb;"Enter bottom margin";"Margin") MarginTop(margint) MarginBottom(marginb)0*0*0* SHELLASSIGN Show Me An Example...  SHELLASSIGN assigns an expression to a Shell variable to be used in a Shell macro. Syntax:8hP P h SHELLASSIGN(Variable;Expression)(# Parameters:P P h Variable(# h hhhP P h Specifies the name of the variable to be assigned. Any variable name is valid for this parameter.(# h hhhP P h Expression(# h hhhP P h Specifies the expression to assign to the variable. All expressions are valid for this parameter.(# See Also:P P h SHELLMACRO(# h hhhP P h SHELLVARIABLE(#   h0*0*0* For Example... This macro takes a shell variable and retrieves the respective file. The macro then places the path and filename in a footer, reassigns the shell variable and runs a shell macro named WPPRINT.SHM. WPVar:=SHELLVARIABLE(Name) FileRetrieve(WPVar) FooterB(Create!) h Type(?Path+?Name)(# h SubstructureExit(# path:=?path FileSave(Path+"WP.PRN") SHELLASSIGN(Name;"WP.PRN") SHELLMACRO("C:\OFFICE4\MACROS\WPPRINT.SHM") 0*0*0* SHELLMACRO Show Me An Example...  SHELLMACRO runs the specified Shell macro at the point this command is encountered. An .SHM extension is not required, and the path is necessary only if the macro is not located in the directory specified in the Location of Macro Files in Shell Setup. Syntax:8hP P h SHELLMACRO("Macro")(# Parameters:P P h Macro(# h hhhP P h A character expression specifying the Shell macro to run.(# See Also:P P h SHELLASSIGN(# h hhhP P h SHELLVARIABLE(#   0*0*0* For Example... See example for SHELLASSIGN0*0*0* SHELLVARIABLE Show Me An Example...  SHELLVARIABLE returns the contents of a Shell variable. Variable contents can either be typed, evaluated, or assigned to a WordPerfect variable. Syntax:8hP P h SHELLVARIABLE(Variable)(# Parameters:P P h Variable(# h hhhP P h Specifies the name of the Shell variable.(# See Also:P P h ASSIGN(# h hhhP P h SHELLASSIGN(# h hhhP P h SHELLMACRO(# h hhhP P h Type(#   0*0*0* For Example... See example for SHELLASSIGN0*0*0* SHOWATTROFF Show Me An Example...  SHOWATTROFF turns off a character display attribute. This command is used in conjunction with SHOWTEXT to change the display attributes. Syntax:8hP P h SHOWATTROFF(Attribute)(# Parameters:P P h Attribute(# h hhhP P h Specifies the display attribute to turn off. SHOWATTROFF requires at least one Attribute parameter, but will accept as many as need to be turned off. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+Numeric8``4h7h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h ExtraLarge!XX%h(h((+0h.h1h``4h7h00:Turns off Extra Large(#0 h hhhP P h VeryLarge!XX%h(h((+1h.h1h``4h7h00:Turns off Very Large(#0 h hhhP P h Large!8"hXX%h(h((+h.2h1h``4h7h00:h=Turns off Large(# h hhhP P h Small!8"hXX%h(h((+h.3h1h``4h7h00:h=Turns off Small(# h hhhP P h Fine!h"hXX%h(h((+4h.h1h``4h7h00:Turns off Fine(#0 h hhhP P h Superscript!(h((+h.5h1h``4h7h00:h=Turns off Superscript(# h hhhP P h Subscript!XX%h(h((+6h.h1h``4h7h00:Turns off Subscript(#0 h hhhP P h Outline!8"hXX%h(h((+7h.h1h``4h7h00:Turns off Outline(#0 h hhhP P h Italics!8"hXX%h(h((+8h.h1h``4h7h00:Turns off Italics(#0 h hhhP P h Shadow!8"hXX%h(h((+9h.h1h``4h7h00:Turns off Shadow(#0 h hhhP P h Redline!8"hXX%h(h((+10h.h1h``4h7h00:Turns off Redline(#0 h hhhP P h DoubleUnderline!p((+h.11h1h``4h7h00:h=Turns off Double Underline(# h hhhP P h Bold!h"hXX%h(h((+12h.h1h``4h7h00:Turns off Bold(#0 h hhhP P h Strikeout!XX%h(h((+13h.h1h``4h7h00:Turns off Strikeout(#0 h hhhP P h Underline!XX%h(h((+14h.h1h``4h7h00:Turns off Underline(#0 h hhhP P h SmallCaps!XX%h(h((+15h.h1h``4h7h00:Turns off Small Caps(#0 h hhhP P h Every!8"hXX%h(h((+h.16h1h``4h7h00:h=Turns off every display attribute(# h hhhP P h (# See Also:P P h SHOWATTRON(# h)0*0*0*Ԍh hhhP P h SHOWCODE(# h hhhP P h SHOWCOLOR(# h hhhP P h SHOWPOSITION(# h hhhP P h SHOWTEXT(#    0*0*0* For Example... This macro displays a menu created with the Show commands. SHOWPOSITION(0; -1) SHOWCODE(ReverseOff!) SHOWCOLOR(On!) SHOWCODE(ClrScreen!) SHOWPOSITION(21;8) SHOWTEXT("") SHOWPOSITION(21;9) SHOWTEXT(" Please select the ") SHOWPOSITION(21;10) SHOWTEXT(" desired recipient ") SHOWPOSITION(21;11) SHOWTEXT(" ") SHOWATTRON(Bold!) SHOWTEXT("1") SHOWATTROFF(Bold!) SHOWTEXT(". ") SHOWATTRON(Bold!) SHOWTEXT("F") SHOWATTROFF(Bold!) SHOWTEXT("red") SHOWTEXT(" ") SHOWPOSITION(21;12) SHOWTEXT(" ") SHOWATTRON(Bold!) SHOWTEXT("2") SHOWATTROFF(Bold!) SHOWTEXT(". ") SHOWATTRON(Bold!) SHOWTEXT("M") SHOWATTROFF(Bold!) SHOWTEXT("ary") SHOWTEXT(" ") SHOWPOSITION(21;13) SHOWTEXT(" ") SHOWPOSITION(21;14) SHOWTEXT("") SHOWPOSITION(1; 24) CHAR(menu1;"Selection: ") DisplayRewrite0*0*0* SHOWATTRON Show Me An Example...  SHOWATTRON turns on a character display attribute. This command is used in conjunction with SHOWTEXT to change the display attributes of text being displayed. Syntax:8hP P h SHOWATTRON(Attribute;Attribute;...Atr)(# Parameters:P P h Attribute(# h hhhP P h Specifies the display attribute to turn on. SHOWATTRON requires at least one Attribute parameter, but will accept as many as need to be turned on. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+Numeric8``4h7h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h ExtraLarge!XX%h(h((+0h.h1h``4h7h00:Turns on Extra Large(#0 h hhhP P h VeryLarge!XX%h(h((+1h.h1h``4h7h00:Turns on Very Large(#0 h hhhP P h Large!8"hXX%h(h((+h.2h1h``4h7h00:h=Turns on Large(# h hhhP P h Small!8"hXX%h(h((+h.3h1h``4h7h00:h=Turns on Small(# h hhhP P h Fine!h"hXX%h(h((+4h.h1h``4h7h00:Turns on Fine(#0 h hhhP P h Superscript!(h((+h.5h1h``4h7h00:h=Turns on Superscript(# h hhhP P h Subscript!XX%h(h((+6h.h1h``4h7h00:Turns on Subscript(#0 h hhhP P h Outline!8"hXX%h(h((+7h.h1h``4h7h00:Turns on Outline(#0 h hhhP P h Italics!8"hXX%h(h((+8h.h1h``4h7h00:Turns on Italics(#0 h hhhP P h Shadow!8"hXX%h(h((+9h.h1h``4h7h00:Turns on Shadow(#0 h hhhP P h Redline!8"hXX%h(h((+10h.h1h``4h7h00:Turns on Redline(#0 h hhhP P h DoubleUnderline!p((+h.11h1h``4h7h00:h=Turns on Double Underline(# h hhhP P h Bold!h"hXX%h(h((+12h.h1h``4h7h00:Turns on Bold(#0 h hhhP P h Strikeout!XX%h(h((+13h.h1h``4h7h00:Turns on Strikeout(#0 h hhhP P h Underline!XX%h(h((+14h.h1h``4h7h00:Turns on Underline(#0 h hhhP P h SmallCaps!XX%h(h((+15h.h1h``4h7h00:Turns on Small Caps(#0 h hhhP P h Every!8"hXX%h(h((+h.16h1h``4h7h00:h=Turns on every display attribute(# h hhhP P h (# See Also:P P h SHOWATTROFF(# h hhhP P h SHOWCODE(# h hhhP P h SHOWCOLOR(# h)0*0*0*Ԍh hhhP P h SHOWPOSITION(# h hhhP P h SHOWTEXT(#   0*0*0* For Example... See example for SHOWATTROFF0*0*0* SHOWCODE Show Me An Example...  SHOWCODE positions displayed text and allows for other display changes. A SHOWCODE command affects the next occurence of a SHOWTEXT command in the macro. Syntax:8hP P h SHOWCODE(Code)(# Parameters:P P h Code(# h hhhP P h Specifies the display change. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(h((+Numeric8``4h7h00:Description(#0 h hhhP P h Typeh"hXX%h(h((+Equivalent(#( h hhhP P h (# h hhhP P h PosHome!8"hXX%h(h((+0h.h1h``4h7h00:Displays text at upper left of document window(#0 h hhhP P h PosNextLine!(h((+h.1h1h``4h7h00:h=Displays text on the next line(# h hhhP P h PosBegLine!XX%h(h((+2h.h1h``4h7h00:Displays text at the beginning of the current line(#0 h hhhP P h PosLeft!8"hXX%h(h((+3h.h1h``4h7h00:Moves back to the last SHOWTEXT(#0 h hhhP P h PosRight!XX%h(h((+h.4h1h``4h7h00:h=Displays text two spaces to the right of the last SHOWTEXT(# h hhhP P h PosUp!8"hXX%h(h((+h.5h1h``4h7h00:h=Displays text one line up from the last SHOWTEXT(# h hhhP P h PosDown!8"hXX%h(h((+6h.h1h``4h7h00:Displays text one line down from the last SHOWTEXT(#0 h hhhP P h ClrLine!8"hXX%h(h((+7h.h1h``4h7h00:Clears the line from the end of the last SHOWTEXT(#0 h hhhP P h ClrScreen!XX%h(h((+8h.h1h``4h7h00:Clears the screen(#0 h hhhP P h AttrNormal!XX%h(h((+9h.h1h``4h7h00:Clears all attributes(#0 h hhhP P h AttrMnemonic!(h((+h.10h1h``4h7h00:h=Turns on the Mnemonic attribute for the next character(# h hhhP P h ReverseOn!XX%h(h((+11h.h1h``4h7h00:Turns on Reverse Video(#0h)0*0*0*Ԍh hhhP P h ReverseOff!XX%h(h((+12h.h1h``4h7h00:Turns off Reverse Video(#0 h hhhP P h SaveScreen!XX%h(h((+13h.h1h``4h7h00:Saves the screen(#0 h hhhP P h RestoreScreen!(h((+14h.h1h``4h7h00:Restores the screen(#0 h hhhP P h (# See Also:P P h SHOWATTROFF(# h hhhP P h SHOWATTRON(# h hhhP P h SHOWCOLOR(# h hhhP P h SHOWPOSITION(# h hhhP P h SHOWTEXT(#   ` 0*0*0* For Example... See example for SHOWATTROFF0*0*0* SHOWCOLOR Show Me An Example...  SHOWCOLOR turns a color scheme on or off. Syntax:8hP P h SHOWCOLOR(State;"Scheme Name")(# Parameters:P P h State(# h hhhP P h Specifies whether the color scheme is on or off. Select an enumerated type or its numeric equivalent(# h hhhP P h EnumeratedXX%h(Numeric81h``4h7Description(# h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Off!h"hXX%h(0h((+h.h1h``4h7Turns off color scheme(# h hhhP P h On!h"hXX%h(1h((+h.h1h``4h7Turns on color scheme(# h hhhP P h (# h hhhP P h Scheme Name (optional)(# h hhhP P h A character expression specifying the scheme name to turn on. This parameter is not required when turning a scheme off.(# See Also:P P h SHOWATTROFF(# h hhhP P h SHOWATTRON(# h hhhP P h SHOWCODE(# h hhhP P h SHOWPOSITION(# h hhhP P h SHOWTEXT(#   0*0*0* For Example... See example for SHOWATTROFF0*0*0* SHOWPOSITION Show Me An Example...  SHOWPOSITION positions the cursor on the screen and, optionally, displays a temporary prompt. SHOWPOSITION does not pause the macro, so it is used in conjunction with such commands as PAUSE or WAIT. Syntax:8hP P h SHOWPOSITION(Horizontal Position;Vertical Position;"Prompt")Parameters:7h00:Horizontal Position(#0 h hhhP P h A numeric expression specifying the horizontal position of the prompt. This position is measured in columns, with 0 representing the first column at the left of the screen.(# h hhhP P h Vertical Position(# h hhhP P h A numeric expression specifying the vertical position of the prompt. This position is measured in lines, with 0 representing the first row at the top of the screen.(# h hhhP P h Prompt (optional)(# h hhhP P h A character expression specifying the prompt to display.(# See Also:P P h PAUSE(# h hhhP P h SHOWATTROFF(# h hhhP P h SHOWATTRON(# h hhhP P h SHOWCODE(# h hhhP P h SHOWCOLOR(# h hhhP P h SHOWTEXT(# h hhhP P h WAIT(#    0*0*0* For Example... See example for SHOWATTROFF0*0*0* SHOWTEXT Show Me An Example...  SHOWTEXT displays a temporary prompt a specified number of times. SHOWPOSITION does not pause the macro, so it is used in conjunction with commands such as PAUSE or WAIT. Syntax:8hP P h SHOWTEXT("Prompt";Count)(# Parameters:P P h Prompt(# h hhhP P h A character expression specifying the prompt to display.(# h hhhP P h Count (optional)(# h hhhP P h A numeric expression specifying the number of times to display the prompt. If this parameter is not specified, the prompt will display once.(# See Also:P P h PAUSE(# h hhhP P h SHOWATTROFF(# h hhhP P h SHOWATTRON(# h hhhP P h SHOWPOSITION(# h hhhP P h SHOWCODE(# h hhhP P h SHOWCOLOR(# h hhhP P h WAIT(#   0*0*0* For Example... See example for SHOWATTROFF0*0*0* SPEED Show Me An Example...  SPEED slows down macro execution while writing to the screen. Macro speed is incremented in tenths of a second. For example, to specify a macro to wait onehalf second, the command is SPEED(5). The maximum delay is one minute or SPEED(600). The default macro speed is SPEED(0). SPEED is useful for debugging macros or making demonstration macros. Syntax:8hP P h SPEED(Tenths of a Second)(# Parameters:P P h Tenths of a Second(# h hhhP P h A numeric expression between 0 and 600 specifying macro speed.(# See Also:P P h PAUSE(# h hhhP P h WAIT(#   0*0*0* For Example... This macro displays how the SPEED command slows down the execution of a macro. FORNEXT(Count;1;20) TYPE("This is line "+Count+".") HRt ENDFOR SPEED(30) FORNEXT(Count;1;20) TYPE("This is line "+Count+".") HRt ENDFOR( 0*0*0* STATUSPROMPT Show Me An Example...  STATUSPROMPT displays a prompt on the status line. The prompt is stored in memory much like a variable and will continue to display until it is replaced by another prompt using either INPUT or another STATUSPROMPT command. If the prompt is not replaced, it will remain visible until it is cleared by a blank INPUT or STATUSPROMPT or until you exit WordPerfect. STATUSPROMPT does not pause the macro. To pause the macro until a specific key or command is executed, use PAUSE, PAUSECOMMAND, or PAUSEKEY. To display the prompt for a specific amount of time, use WAIT. Syntax:8hP P h STATUSPROMPT("Prompt")(# Parameters:P P h Prompt(# h hhhP P h A character expression specifying the prompt to display.(# See Also:P P h PAUSE(# h hhhP P h PAUSECOMMAND(# h hhhP P h PAUSEKEY(# h hhhP P h WAIT(#   0*0*0* For Example... This macro counts keystrokes until the user presses CtrlEnter. STATUSPROMPT("Press Ctrl+Enter to quit") cnt:=0 REPEAT LOOK(info) IF((info<>0) AND (info<>8097)) cnt:=cnt+1 Type(NTOC(info)) ENDIF UNTIL(info=8097) STATUSPROMPT("") PAUSESET(EndFieldKey) PROMPT("You pressed "+cnt+" keystrokes. Press F9 to continue") PAUSE 0*0*0* STEP Show Me An Example...  STEP executes a macro one step at a time and is useful for debugging macros. When STEP is turned on a dialog box offers debugging options. If you choose Step, the macro will execute the next command. Choosing List displays a list of all encountered variables and their contents. From this list you can choose which variable table to list (Local, Global, or Persistent). If you choose Run, the macro will begin executing and STEP will be turned off. Choosing Cancel will cancel STEP and macro execution. Syntax:8hP P h STEP(State)(# Parameters:P P h State(# h hhhP P h Specifies whether STEP is on. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Off!h"hXX%h(0h((+h.h1h``4Turns STEP off(#` h hhhP P h On!h"hXX%h(1h((+h.h1h``4Turns STEP on(#` h hhhP P h (#   0*0*0* For Example... This macro demonstrates how the STEP command works. The STEP command is mainly used for debugging purposes. FORNEXT(Count;1;5) TYPE("This is line "+Count+".") HRt ENDFOR STEP(On!) FORNEXT(Count;1;5) TYPE("This is line "+Count+".") HRt ENDFOR 0*0*0* STRLEN Show Me An Example...  STRLEN returns the number of characters (length), of a character expression. This command is used in conjunction with commands that can evaluate its contents or perform an action such as IF, ASSIGN, or Type. Syntax:8hP P h STRLEN("String")(# Parameters:P P h String(# h hhhP P h A character expression or a variable containing a character expression to evaluate.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h NUMSTR(# h hhhP P h STRNUM(# h hhhP P h STRPOS(# h hhhP P h STRUNIT(# h hhhP P h Type(#   0*0*0* For Example... This macro parses an array and displays the student name and grade. student[1]:="Mark B. PE 132 A" student[2]:="Kerry R. Physics 305 B" student[3]:="Ralph D. CS 351 A" student[4]:="John B. Math 402 B" FORNEXT(x;1;4;1) h len:=STRLEN(student[x])(# h namepos:=STRPOS(student[x];" ")(# h IF((len=0) OR (namepos=0))(# h hNEXT(# h hname:="xxx"(# h ENDIF(# h name:=SUBSTR(student[x];1;namepos1)(# h grade:=SUBSTR(student[x];len;1)(# h Type(name)(# h FORNEXT(space;1;15namepos;1)(# h hType(" ")(# h ENDFOR(# h Type(grade)(# h HRt(# ENDFOR0*0*0* STRNUM Show Me An Example...  STRNUM converts a character expression to a numeric expression. This command must be used in an expression and must be used in conjunction with commands that evaluate expressions, such as IF, ASSIGN or Type. Syntax:8hP P h STRNUM("String")(# Parameters:P P h String(# h hhhP P h A character expression specifying the text to convert.(# See Also:P P h ASSIGN(# h hhhP P h NUMSTR(# h hhhP P h STRLEN(# h hhhP P h STRPOS(# h hhhP P h STRUNIT(# h hhhP P h Type(#   0*0*0* For Example... This macro takes the string 15 and displays it as a Number, Unit and Unit String value. Num:="15" ASSIGN(Number;STRNUM(Num)) ASSIGN(Unit;STRUNIT(Num)) ASSIGN(UnitString;UNITSTR(Unit;Centimeters!)) TYPE("The Number value is "+ Number) HRt TYPE("The Unit value is "+ Unit) HRt TYPE("The Unit String value is "+ UnitString) HRt 0*0*0* STRPOS Show Me An Example...  STRPOS returns the position of a substring within an original string. For example, "Perfect" is a substring of "WordPerfect" and begins at the fifth character, or position. In this example, STRPOS returns a value of 5. This command is used in conjunction with commands that can evaluate its contents or perform an action such as ASSIGN, IF, or Type. If a substring is not found, STRPOS returns the value of 0. Syntax:8hP P h STRPOS("Original String";"Substring")(# Parameters:P P h Original String(# h hhhP P h A character expression specifying the original string.(# h hhhP P h Substring(# h hhhP P h A character expression specifying the substring.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h NUMSTR(# h hhhP P h STRLEN(# h hhhP P h STRNUM(# h hhhP P h STRUNIT(# h hhhP P h SUBSTR(# h hhhP P h Type(#   80*0*0* For Example... This macro parses an array and displays the student name and grade. student[1]:="Mark B. PE 132 A" student[2]:="Kerry R. Physics 305 B" student[3]:="Ralph D. CS 351 A" student[4]:="John B. Math 402 B" FORNEXT(x;1;4;1) h len:=STRLEN(student[x])(# h namepos:=STRPOS(student[x];" ")(# h IF((len=0) OR (namepos=0))(# h hNEXT(# h hname:="xxx"(# h ENDIF(# h name:=SUBSTR(student[x];1;namepos1)(# h grade:=SUBSTR(student[x];len;1)(# h Type(name)(# h FORNEXT(space;1;15namepos;1)(# h hType(" ")(# h ENDFOR(# h Type(grade)(# h HRt(# ENDFOR0*0*0* STRUNIT Show Me An Example...  STRUNIT converts a character expression to a measurement expression. This command is used in conjunction with such commands as ASSIGN or Type. Syntax:8hP P h STRUNIT("String")(# Parameters:P P h String(# h hhhP P h A character expression specifying the text to convert.(# See Also:P P h ASSIGN(# h hhhP P h NUMSTR(# h hhhP P h STRLEN(# h hhhP P h STRNUM(# h hhhP P h STRPOS(# h hhhP P h Type(#   00*0*0* For Example... This macro takes the string 15 and displays it as a Number, Unit and Unit String value. Num:="15" ASSIGN(Number;STRNUM(Num)) ASSIGN(Unit;STRUNIT(Num)) ASSIGN(UnitString;UNITSTR(Unit;Centimeters!)) TYPE("The Number value is "+ Number) HRt TYPE("The Unit value is "+ Unit) HRt TYPE("The Unit String value is "+ UnitString) HRt 0*0*0* SUBSTR Show Me An Example...  SUBSTR creates a substring from an existing string. For example, to create substring "Brad" from "Bradford", the command is SUBSTR("Bradford";1;4). The value 1 specifies beginning the substring at the first character or position of the original string. The value 4 represents extracting four consecutive characters, including the character at the beginning position, to create the substring. SUBSTR is used in conjunction with commands that can evaluate its contents or perform an action such as ASSIGN, IF, and Type. Syntax:8hP P h SUBSTR("Original String";Beginning Position;Number of Characters)(# Parameters:P P h Original String(# h hhhP P h A character expression specifying the string from which to create a substring.(# h hhhP P h Beginning Position(# h hhhP P h A numeric expression specifying the number of characters from the left (or at what position) to begin the substring. This parameter will also accept negative numbers to specify a position beginning at the right.(# h hhhP P h Number of Characters(# h hhhP P h A numeric expression specifying the number characters (including the beginning position) to extract as the substring.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h NUMSTR(# h hhhP P h STRLEN(# h hhhP P h STRPOS(# h hhhP P h SUBSTR(# h hhhP P h STRUNIT(# h hhhP P h Type(#   (#0*0*0* For Example... This macro parses an array and displays the student name and grade. student[1]:="Mark B. PE 132 A" student[2]:="Kerry R. Physics 305 B" student[3]:="Ralph D. CS 351 A" student[4]:="John B. Math 402 B" FORNEXT(x;1;4;1) h len:=STRLEN(student[x])(# h namepos:=STRPOS(student[x];" ")(# h IF((len=0) OR (namepos=0))(# h hNEXT(# h hname:="xxx"(# h ENDIF(# h name:=SUBSTR(student[x];1;namepos1)(# h grade:=SUBSTR(student[x];len;1)(# h Type(name)(# h FORNEXT(space;1;15namepos;1)(# h hType(" ")(# h ENDFOR(# h Type(grade)(# h HRt(# ENDFOR0*0*0* SWITCH Show Me An Example...  SWITCH is the opening command for a conditional switch statement. A complete switch statement includes the following commands: SWITCH, CASEOF, CONTINUE (optional), DEFAULT (optional), and ENDSWITCH. A switch statement compares a single SWITCH expression against individual CASEOF expressions and executes specific commands depending on which CASEOF matches the SWITCH expression. The SWITCH command contains an expression to evaluate. Any expression is valid, but it is usually a variable. In most cases, the contents of this variable are assigned earlier in the macro with commands such as CHAR or GETSTRING. This SWITCH expression is the "test" against which each individual case is compared. The individual cases are created with the CASEOF command. When an individual CASEOF expression matches the SWITCH expression, the macro executes whatever commands follow the CASEOF that provided the match. Both the SWITCH and the CASEOF expressions are case sensitive (capitalization) and must match exactly. If none of the CASEOF expressions match the SWITCH expression, the macro executes the commands between DEFAULT and ENDSWITCH. If a DEFAULT command is not included, the macro is redirected to the commands following ENDSWITCH. For example, LABEL(Question) CHAR(YESNO;"Do you have a preference? Y/N") SWITCH(NTOC(YESNO)) h CASEOF "Y";"y": Type("Yes")(# h CASEOF "N";"n": Type("No")(# h DEFAULT:8P P h GO(Question)(# ENDSWITCH In this example, the CHAR command asks the user a question. The user's response is stored in the variable YESNO. The switch statement that follows then evaluates that variable and executes appropriate commands depending on the contents of the variable. Specifically, if the variable contains either an uppercase or a lowercase "y," the macro types the word "Yes." If the variable YESNO contains either an uppercase or lowercase "n," the macro will type the word "No." If the variable contains anything else, the macro returns to label Question and the user will have a chance to respond again. The CHAR command only recognizes numbers. If a character ish)0*0*0* pressed in response to the CHAR command prompt, the character is converted to its numeric equivalent. The NTOC command in the switch expression converts the number back to its original character. For a list of characters and their numeric equivalents see Appendix A in the Appendices section. Syntax:8hP P h SWITCH(Expression)(# Parameters:P P h Expression(# h hhhP P h Specifies the expression to evaluate. All expressions are valid for this parameter.(# See Also:P P h CASEOF(# h hhhP P h CHAR(# h hhhP P h CONTINUE(# h hhhP P h DEFAULT(# h hhhP P h ENDSWITCH(# h hhhP P h GETSTRING(# h hhhP P h LABEL(# h hhhP P h NTOC(#   0*0*0* For Example... This macro constantly prompts for a name until Cancel is pressed. ONCANCEL CALL(Cancel) LABEL(Top) Name:="" GETSTRING(Name;"Type in a name, (Cancel or Enter) to quit";"Name") IF(Name="") h ASSERT(CancelCondition!)(# ENDIF TYPE(Name) Hrt GO(Top) LABEL(Cancel) CANCEL(Off!) CHAR(Selection;"Do you really want to Quit? Y/N") SWITCH(TOLOWER(NTOC(Selection))) h CASEOF "y" : QUIT(# h CASEOF "n" : CANCEL(On!) RETURN(# h DEFAULT : GO(Cancel)(# ENDSWITCH 0*0*0* TOLOWER Show Me An Example...  TOLOWER converts a character expression to lowercase letters. This command is used in conjunction with commands that can evaluate its contents or perform an action such as ASSIGN, IF, and Type. Syntax:8hP P h TOLOWER("String")(# Parameters:P P h String(# h hhhP P h A character expression specifying the text to convert.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h TOUPPER(# h hhhP P h Type(#   0*0*0* For Example... This macro executes a function from within a TYPE command. Prmt:="Would you like to continue?" Type ("You pressed "+YesNo(prmt)) //More code for the macro Quit FUNCTION YesNo (message) h LOCAL(ans)(# h IF (EXISTS(ans))(# h hDISCARD(ans)(# h ENDIF(# h LABEL(Begin)(# h CHAR(ans;message+" Y/N")(# h SWITCH(TOLOWER(NTOC(ans)))(# h hCASEOF "y" : ans:="Y"(# h hCASEOF "n" : ans:="N"(# h hDEFAULT : GO(Begin)(# h ENDSWITCH(# h RETURN(ans)(# ENDFUNC0*0*0* TOUPPER Show Me An Example...  TOUPPER converts a character expression to uppercase letters. This command is used in conjunction with commands that can evaluate its contents or perform an action such as ASSIGN, IF, and Type. Syntax:8hP P h TOUPPER("String")(# Parameters:P P h String(# h hhhP P h A character expression specifying the text to convert.(# See Also:P P h ASSIGN(# h hhhP P h IF(# h hhhP P h TOLOWER(# h hhhP P h Type(#   h0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH 0*0*0* UNITSTR Show Me An Example...  UNITSTR converts a measurement expression to a character expression. Syntax:8hP P h UNITSTR(Measurement;Unit of Measurement)(# Parameters:P P h Measurement(# h hhhP P h A measurement expression specifying the number to convert or a variable containing a measurement expression.(# h hhhP P h Unit of Measurement(# h hhhP P h Specifies the unit of measurement. Select an enumerated type or its numeric equivalent(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Inches!8"hXX%h(0h((+h.h1h``4Converts inches (")(#` h hhhP P h InchesI!8"hXX%h(1h((+h.h1h``4Converts inches (i)(#` h hhhP P h Centimeters!(h((+2h.h1h``4h7Converts centimeters(# h hhhP P h Millimeters!(h((+3h.h1h``4h7Converts millimeters(# h hhhP P h Points!8"hXX%h(4h((+h.h1h``4Converts points(#` h hhhP P h WP1200ths!XX%h(5h((+h.h1h``4Converts 1200ths of an inch(#` h hhhP P h WP42Units!XX%h(6h((+h.h1h``4Converts WP 4.2 units(#` h hhhP P h (#   0*0*0* For Example... This macro takes the string 15 and displays it as a Number, Unit and Unit String value. Num:="15" ASSIGN(Number;STRNUM(Num)) ASSIGN(Unit;STRUNIT(Num)) ASSIGN(UnitString;UNITSTR(Unit;Centimeters!)) TYPE("The Number value is "+ Number) HRt TYPE("The Unit value is "+ Unit) HRt TYPE("The Unit String value is "+ UnitString) HRt 0*0*0* UNTIL Show Me An Example...  UNTIL is the closing command of a REPEATUNTIL loop. The loop continues until the expression in the UNTIL command is true. For example, a macro that counts to ten could use the following REPEATUNTIL loop: ASSIGN(Count;1) REPEAT h ASSIGN(Count;Count + 1)(# UNTIL(Count=10) This example adds 1 to the value of variable Count each time the loop repeats. When Count equals 10, the UNTIL expression is satisfied and the loop ends. The macro then resumes with the command immediately following UNTIL. UNTIL expressions are evaluated at the end of the loop. As a result, a REPEATUNTIL loop always executes at least once, regardless of whether the condition is true or false. For information on conditional loops that evaluate expressions at the beginning, and will not execute if the expression is false, see WHILE and ENDWHILE. Syntax:8hP P h UNTIL(Test)(# Parameters:P P h Test(# h hhhP P h A relational expression to evaluate.(# See Also:P P h ENDWHILE(# h hhhP P h REPEAT(# h hhhP P h WHILE(#   0*0*0* For Example... This macro counts keystrokes until the user presses CtrlEnter. STATUSPROMPT("Press Ctrl+Enter to quit") cnt:=0 REPEAT LOOK(info) IF((info<>0) AND (info<>8097)) cnt:=cnt+1 Type(NTOC(info)) ENDIF UNTIL(info=8097) STATUSPROMPT("") PAUSESET(EndFieldKey) PROMPT("You pressed "+cnt+" keystrokes. Press F9 to continue") PAUSE 0*0*0* USE Show Me An Example...  USE enables macros to share FUNCTIONs and PROCEDUREs. This command specifies a macro containing a FUNCTIONs and/or PROCEDUREs that can be used in the current macro. USE can specify a macro file library (a macro that does not execute, but simply contains FUNCTIONs and/or PROCEDUREs), or another executable macro. Syntax:8hP P h USE("Macro")(# Parameters:P P h Macro(# h hhhP P h A character expression specifying the macro or macro file library to use.(# See Also:P P h FUNCTION(# h hhhP P h PROCEDURE(#   0*0*0* For Example... This macro uses the function FileExists from the macro Library.wpm. DISPLAY(Off!) USE("Library.wpm") LABEL(Begin) GetString(flname;"Enter the name of the file") rslt:=FileExists("";flname+".doc").//FileExists is a function in(# h hhhP P h h hh"hXX%h(h((+h.//Library.wpm It returns a(# IF(rslt)8hP P h h hh"hXX%h(h((+h.//boolean (true/false) value.(# CHAR(ans;"This file already exists. Overwrite it? y/n") SWITCH(NTOC(ans)) CASEOF "Y";"y" : GO(Save) CASEOF "N";"n" : CONTINUE DEFAULT : GO(Begin) ENDSWITCH ENDIF LABEL(Save) FileSave(flname+".doc")h0*0*0* USERFUNCTION Show Me An Example...  USERFUNCTION passes executable strings to a third party program. The string specified depends on the program to which it is being passed. Syntax:8hP P h USERFUNCTION(:)(# Parameters:P P h Signature(# h hhhP P h Specifies a fourcharacter identification for the third party program.(# h hhhP P h Action(# h hhhP P h Specifies a character string that the third party program can execute.(#   0*0*0* For Example... This command is specific to thirdparty products such as TSR's. Therefore, no example is supplied since this command will be specific to each individual user. 0*0*0* VARERRCHK Show Me An Example...  VARERRCHK determines whether undefined variables cause an error message. By default, undefined variables will generate the error "Variable not Assigned a Value" and stops the macro from executing further. Undefined variables can occur in commands, such as Type, that use variables to perform an action. For example, the command Type(Number) could generate an error if variable Number is not assigned earlier in the macro. The same error is generated if the Type command is meant to type the word "Number", but the quotes defining it as a character expression are not included. With VARERRCHK(Off!), a macro will continue running even if it contains undefined variables. Syntax:8hP P h VARERRCHK(State)(# Parameters:P P h State(# h hhhP P h Specifies whether variable error checking is on. Select an enumerated type or its numeric equivalent.(# h hhhP P h EnumeratedXX%h(Numeric81h``4Description(#` h hhhP P h Typeh"hXX%h(Equivalent(# h hhhP P h (# h hhhP P h Off!h"hXX%h(0h((+h.h1h``4Error checking off(#` h hhhP P h On!h"hXX%h(1h((+h.h1h``4Error checking on(#` h hhhP P h (# See Also:P P h (#   0*0*0* For Example... This macro assigns a name to the variable Name if the variable doesn't exist. VARERRCHK(Off!) IF (Name="") h GETSTRING(Name;"Enter your name";"Name")(# TYPE(Name) ELSE TYPE(Name) ENDIF0*0*0* WAIT Show Me An Example...  WAIT suspends macro execution for a specified amount of time. This is useful, for example, to display a prompt on the screen for a certain amount of time. If a user begins typing while the macro is suspended, the keystrokes are ignored until the specified time has elapsed. The length of WAIT is specified in tenths of a second, with a maximum of one minute, or WAIT(600). Syntax:8hP P h WAIT(Tenths of a Second)(# Parameters:P P h Tenths of a Second(# h hhhP P h A numeric expression specifying the amount of time to wait.(# See Also:P P h PAUSE(# h hhhP P h PROMPT(# h hhhP P h STATUSPROMPT(#   h0*0*0* For Example... This macro prompts the user for a return address and assigns it to a series of variables. It then makes the variables accessible until WordPerfect is exited. DLGCREATE(x;"Return Address";DLGNoCancel!;;;50;10) h DLGCONTROL(CtrlText!;name;"Name";StyInitial!;1;3;37;2)(# h DLGCONTROL(CtrlText!;address;"Street Address";;1;5;27;2)(# h DLGCONTROL(CtrlText!;c;"City, State ZIP ";;1;7;25;2)(# DLGEND PERSISTALL Prompt("All the variables are now accessible in any macro/merge.") WAIT(50) 0*0*0* WHILE Show Me An Example...  WHILE is the opening command of a WHILEENDWHILE loop. This loop repeatedly executes the commands between WHILE and ENDWHILE as long as the WHILE expression is true. The expression is evaluated at the top of the loop. If the expression is false, macro execution resumes with the command immediately following ENDWHILE. For information on loops that evaluate expressions at the end of the loop, see REPEAT and UNTIL. Syntax:8hP P h WHILE(Test)(# Parameters:P P h Test(# h hhhP P h A relational expression to evaluate.(# See Also:P P h ENDWHILE(# h hhhP P h REPEAT(# h hhhP P h UNTIL(#   h0*0*0* For Example... This macro creates a secondary merge file through a series of prompts. ASSIGN(More;"Y") WHILE(TOUPPER(More)="Y") h FOREACH(field;{"First Name";"Last (# h hName";"Company";"Address";"City";"State";"Zip"})(# h hGETSTRING(info;"Enter the "+field;"Field "+field;)(# h hTYPE(info)(# h hEndField(# h hinfo:=""(# h ENDFOR(# h MergeCode(EndRecord!)(# h CHAR(More;"Enter another record? Y/N")(# h ASSIGN(More;NTOC(More))(# ENDWHILEH 0*0*0* XOR Show Me An Example...  XOR is an operator that evaluates at least two expressions in a conditional statement. Conditional statements are created with commands such as IF, REPEAT, and WHILE. This operator performs a logical exclusive OR and evaluates a conditional statement as true if one expression is true, but not if more than one expression is true. Parameters:P P h None(# See Also:P P h AND(# h hhhP P h IF(# h hhhP P h NOT(# h hhhP P h OR(# h hhhP P h REPEAT(# h hhhP P h WHILE(#   0*0*0* For Example... This macro sends an appropriate letter to one or both employees. CHAR(Emp1;"Did employee number one finish the assigned task? Y/N") CHAR(Emp2;"Did employee number two finish the assigned task? Y/N") IF((TOUPPER(Emp1)="Y") XOR (TOUPPER(Emp2)="Y")) h SWITCH ("Y")(# h hCASEOF TOUPPER(Emp1) : CALL(Emp1)(# h hCASEOF TOUPPER(Emp2) : CALL(Emp2)(# h ENDSWITCH(# ELSE h IF(TOUPPER(Emp1)="Y")(# h hemp:="Both"(# h hLetter:="Congrats"(# h ELSE(# h hemp:="Neither"(# h hLetter:="ChewOut"(# h ENDIF(# ENDIF PERSIST(emp) CHAIN(Letter) LABEL(Emp1) h emp:="Paul"(# h Letter:="ChewOut"(# h RETURN(# LABEL(Emp2) h emp:="George"(# h Letter:="ChewOut"(# h RETURN