6.1
What are
parameters
Information or specifications that a command uses to perform its
action are called parameters. The command is what is done; the
parameter is how it does it or what it does it to. You can think
of parameters as the specifications for the command. Both
product
commands and PerfectScript programming commmands can take
parameters.
For example, changing to double space will record the command
LineSpacing(2) in the macro.
LineSpacing() is the command, 2
is the parameter. Typing "abc" in a document will record the
command Type("abc") in the macro.
Type is the command, "abc" is
the parameter. Parameters are specified for the command in the
parentheses immediately following the
command.
Some commands take a single parameter. Example:
LineSpacing(2), which takes one parameter to
specify the value to which the line spacing will be set.
Some commands take no parameters because no additional
information is needed. Example: PosWordNext(),
which positions the cursor at the beginning of the next word.
Some command take multiple parameters. If a command takes
multiple parameters, the order of parameters is
significant—the
command will expect to find each parameter in a specific location
in the parameter list. Example:
FileCopy("abc";"def"), which copies file "abc"
to file "def." If the order of the parameters were reversed,
file "def" would be copied to file "def." Multiple parameters
are separated by semicolons.
Some commands have optional parameters. If an
optional parameter is omitted, the default value for that
parameter will be used by the command. If an optional parameter
is omitted for a command that has multiple parameters, you must
still insert the semicolon separating that parameter from the
others in the parameter list.
Depending on the version of WordPerfect that you are using,
parameters may be labeled, e.g., LineSpacing(Spacing:
2). These labels assist in understanding what the
parameters refer to. When macros are recorded, these labels are
inserted automatically. When you program macros, these labels
are optional.
6.2
Enumerations
Some commands take parameters that can have any value. Example:
PageNumber(15) sets the page number to the value
of the parameter, 15. You can use any value for that parameter,
just as you can set the page number to any number. But other
parameters are restricted to only certain choices. Example:
Justification(Right!), which sets the
justification to right-aligned. The only valid values for the
parameter for the Justification() command are:
Center!, DecAlign!, Full!, FullAll!, Left!, and Right!. These
correspond to the only types of justification available in
WordPerfect, and the only choices available on the Justification
menu.
A parameter value that must be chosen from a specific list of
choices is called an enumeration. Enumerations always
end with an exclamation point ("!"). The most common enumeration
choices are "Yes! No!" and "On! Off!." Example:
WidowOrphan(On!), which turns widow/orphan
protection on. It would make no sense to give a parameter other
than On! or Off! to this command, so you are restricted to one of
those two enumerations for the parameter.
6.3
Strings v.
numbers
Parameters can be of three different types: strings, e.g.
("xyz"); numbers, e.g. (2.5); or enumerations, e.g. (On!).
Usually only one type can be used for any given parameter: a
number cannot be used when a string is required, and vice-versa.
It is important to understand the difference between strings
and numbers.
A string consists of one or more characters (in other
words, text). The string represents the literal
characters themselves. Remember this rule: WHEN A
STRING IS USED AS A
PARAMETER, THE STRING IS ENCLOSED IS QUOTES. A very
common use
of strings is with the Type() command, as seen
above. That command inserts the same characters as those in the
string, into the document.
A number is a mathematical value, an amount. Numbers
are
represented by numerical characters (numerals), but in a macro
numbers and numerals are not equivalent. For example, the number
123 (without quotes) represents the mathematical value one
hundred twenty-three. The string "123" (in quotes) consists of
the numeral (character) "1," followed by the numeral "2,"
followed by the numeral "3."
This distinction becomes clearer if you remember that
arithmetic can only be performed on numbers, not strings
(numerals). If it is impossible or useless for arithmetic to be
performed on a group of numerals, then the numerals make up a
string, and do not represent a number. Good examples of numerals
representing a string are identifiers: telephone numbers,
account numbers, numerical parts of addresses, etc.
To repeat, strings (the literal characters) are enclosed in
quotes when used as a parameter. Numbers are not enclosed in
quotes.
6.4
Units of
Measure
Some parameters are dependent on the units of measure in effect
in WordPerfect. This can cause unintended results when the macro
is recorded when one setting for units of measure is in effect,
but played under a different setting. For example, if you record
a
macro to set the left margin to 1.5 while the units of measure
are set for inches, you will set a left margin of 1.5 inches, but
the parameter recorded will be simply (1.5), i.e.,
MarginLeft(1.5). If this macro is later played
when the units of measure are set for centimeters, a left margin
of 1.5 centimeters will result!
If a macro might be run under a different setting for units of
measure, you should include the unit in the
parameter, e.g., (1.5i) or (1.5") for 1.5 inches in the example
above. The other measurement values are "c" for centimeters, "m"
for
millimeters, "p" for points, and "w" for WordPerfect units
(1/1200 of
an inch).