This command determines what percent to increase a value by, in order to get another value.
Return Value
The percent to increase the first value by.
Parameters
Value:
numeric The value to increase.
Value2:
numeric The value that is increased to.
numeric: PercentOf
Syntax
([Percent: numeric]; [Value: numeric})
Description
This command returns a specified percentage of a value.
Return Value
The specified percentage of the specified value.
Parameters
Percent:
numeric The percentage of the value to return.
Value:
numeric The value to return a percentage of.
numeric: PercentOfTotal
Syntax
([Value: numeric]; [Total: numeric})
Description
The percentage of a total value.
Return Value
The percentage.
Parameters
Value:
numeric The value to test.
Total:
numeric The total value to test against.
Pause
Example
Description
Pause a macro, returning computer control to the user.
To resume macro execution, press Enter, or choose Tools, Macro, Pause. To stop a macro, choose Tools, Macro, Play. When Pause follows a Prompt statement, choose OK to resume macro execution or Cancel to create a Cancel condition.
Persist
Example
Syntax
({<VariableName> variable := <Value> any})
Description
Declare PerfectFit variables and arrays, and assign them to the persistent variable table.
Persist variables are available to any PerfectFit application while PerfectFit is running.
Parameters
<VariableName> variable One or more user-defined variables separated by a semicolon. Variables must begin with a letter and can include any other combination of letters or numbers. Separate multiple variables with a semicolon. Parentheses are optional. For example,
Persist <VariableName>; <VariableName>
Persist (<VariableName>; <VariableName>)
are both valid statements. The next example declares persist arrays with 5 elements and 15 elements:
Persist FirstArray[5]; NextArray[15]
The last example simultaneously declares a variable and assigns a value:
Persist x := 2
or...
Persist x
x := 2
If you create two variables with the same name (for example, Global x and Persist x), the following statement
Persist x := 5
specifies which variable x is assigned the value 5.
<Value> any (optional) Value assigned to <Variable> at time of declaration. For example, Persist vTest = 20. vTest equals 20 at run time.
If missing, the value of <Variable> is undefined.
enumeration := PersistAll
Syntax
(State: enumeration)
Description
Assign a macro's variables and arrays to the Persist variable table.
Persist variables are available to any PerfectFit application while PerfectFit is running.
Return Value
Off! Previous state was Off!
On! Previous state was On!
Only variables assigned values after PersistAll or declared Persist are Persist variables. Variables assigned values before PersistAll, and variables declared Local or Global, are not Persist variables. In the following example, only var6 and var7 are Persist variables:
Application(A1; "WordPerfect"; Default; "US")
Local var1; var2
var3 = 0
Global var4
Persist var7
var7 = "Persist Variable"
PersistAll
Local var5
var4 = 2
var6 = "Persist Variable"
Parameters
State: enumeration (optional) If missing, the state defaults to On.
Off!
On!
NoChange! The current state is obtained and not changed.
numeric array: PrimeFactors
Syntax
([Value: numeric])
Description
This command returns a list of prime factors for a specified value.
Return Value
An array containing the prime factors. If there are none, an empty array is returned.
Parameters
Value:
numeric The value to compute the prime factors of.
numeric := pi
Description
Returns the value of pi.
Return Value
Result of pi.
Note
The symbol for pi is. Pi equals approximately 3.14, which is the ratio of the circumference of a circle to its diameter.
Procedure <Name>label
Example
Syntax
({[<Parameter>any]})
Description
Identify a macro subroutine that can receive one or more values from a calling statement.
Procedures contain one or more statements that execute when the procedure is called. Unlike Label subroutines, procedures do not execute unless called. A calling statement consists of the procedure's name, and can have one or more parameters that contain values passed to the procedure. Return, EndProc, or EndProcedure direct macro execution to the statement that follows the procedure's caller.
Address Mode
To change the value of a variable passed to a procedure, precede the calling statement parameter and its corresponding procedure parameter with an ampersand (&). In the following example, the value of x is 5 after calling Test:
x := 5
Test(x) // calling statement
Procedure Test(z)
z := z + 5
EndProc
In the next example, the value of x is 10 after calling Test:
x := 5
Test(&x) // calling statement
Procedure Test(&z)
z := z + 5
EndProc
The ampersand before variable x means the variable's address (location in memory) is passed to the procedure, not the variable's value. Changes made at the address of x are made to the contents of x.
The general form of a Procedure statement is:
Procedure <Name> (<Parameter>; <Parameter>)
...statement block...
EndProc
The Syntax accepts EndProc or EndProcedure.
Parameters
<Name> label The name of the procedure. It begins with a letter and consists of one or more letters or numbers.
{<Parameter> any} (optional) Receive a value from a calling statement. If an ampersand precedes the calling statement variable, an ampersand must precede the corresponding procedure variable (see Address Mode above). Multiple variables are separated by a semicolon.
Procedure Prototype <Name> label
Example
Syntax
({[<Parameter> any]})
Description
Verify the syntax of a Procedure statement (see Procedure).
If the syntax of a procedure contained in a Use macro file is incorrect and the procedure is called from the main macro, you get a run-time error but not a compile-time error. Use Procedure Prototype at the start of a main macro so that syntax errors will appear as compile-time errors instead of run-time errors.
Parameters
<Name> label The name of the procedure. It begins with a letter and consists of one or more letters or numbers.
<Parameter> any (optional) Receive a value from a calling statement. If an ampersand precedes the calling statement variable, an ampersand must precede the corresponding procedure variable (see Address Mode under Procedure). Multiple variables are separated by a semicolon.
numeric := Product
Syntax
({Value: numeric})
Description
Get the product of a list of values.
Return Value
Product of a list of values.
Parameters
Value: numeric The list of values. Separate multiple values with a semicolon.
Display a message box with OK and Cancel button controls. The parent of this dialog is maintained by the macro and is initially set to the application that started the macro. The dialog may be attached to a different application or window by setting a new default parent with the SetDefaultParent command.
Pause following Prompt displays a Prompt message box until the user selects OK or Cancel. OK removes the prompt and resumes macro execution. Cancel removes the prompt and creates a Cancel condition (see OnCancel).
If Prompt is not followed by Pause, the message box is displayed until an EndPrompt occurs or the macro ends. You can display only one message box at a time. Calling a second message box replaces the first.
The text displayed on the prompt dialog can be selected and copied to the clipboard.
Explanation: The prompt displays a stop-sign icon, no buttons, and beeps. It waits until other statements have executed before disappearing.
Parameters
Title: string The text displayed in the title bar.
Prompt: string (optional) The text displayed in the prompt box. If missing, the title is displayed as the prompt and "PerfectScript" as the title.
Style: enumeration (optional) The icon to display to the left of Prompt. The default value is no icon. Type | between enumerations to combine styles (not all combinations are possible). The values are:
NoIcon!
QuestionMark!
InformationIcon!
ExclamationPoint!
WarningIcon! Same as ExclamationPoint!
ErrorIcon! Same as StopSign!.
Asterisk! Same as InformationIcon!
StopSign!
ApplicationIcon! Standard application icon.
WindowsLogo!
NoPause! Specifies default action (Prompt does not pause).
Pause! Prompt command pauses until a button is pressed (same as following Prompt
command with a Pause command).
Beep!
NoButtons! Show the prompt without OK and Cancel buttons. Use the EndPrompt command to remove the prompt (not the Pause command).
Buttons! Show the default buttons.
HorizontalPosition: numeric (optional) The number of pixels from the left side of the main window to the left side of the message box. If you omit this parameter, the prompt is centered horizontally in the main window.
VerticalPosition: numeric (optional) The number of pixels from the top of the main window to the top of the message box. If you omit this parameter, the prompt is centered vertically in the main window.
Quit
Example
Description
End a macro.
Chain does not execute if a macro ends because of Quit.