A conditional statement that determines whether a statement (or statement block) is executed.
If <Test> is true, the statements between If and Else are executed. If <Test> is false, the statements between Else and EndIf are executed.
Else is optional. If <Test> is false and Else is not used, the macro skips the statements between If and EndIf, and executes the first statement after EndIf.
EndIf closes an If statement.
The general form of an If statement is:
If (<Test> )
...statement block...
Else
...statement block...
EndIf
Parameters
<Test> boolean Evaluate to true or false.
IfPlatform
Example
Syntax
([{<PlatformID> enumeration}])
Description
A conditional statement that specifies a platform or platforms for which subsequent statements are compiled.
If the current platform matches one of the specified platforms, the statements between IfPlatform and EndIfPlatform are compiled and executed.
EndIfPlatform closes an IfPlatform statement.
The general form of an IfPlatform statement is:
IfPlatform (<PlatformID> )
...statement block...
ElseIfPlatform
...statement block...
EndIfPlatform
Parameters
<PlatformID> enumeration (optional/repeating) One or more platform identifiers. Separate multiple platforms with a semicolon.
If equal, the body of the statements are compiled. If this parameter is missing, the statement body is ignored as if a recognized ID was not specified.
This is a compile-time only statement. Use MacroInfo or VersionInfo to get platform type and version numbers at runtime.
WIN!
Win32!
Win95!
Win98! This enumeration is recognized if the macro is compiled on a Win98 system.
WinNT!
_Version9! This enumeration is recognized if the macro is compiled using the PerfectScript version 9 macro system.
_Version9_0_0! This enumeration is recognized if the macro is compiled using the Professional PerfectScript version 9 macro system.
_Version9_0_1!
_Version9_0_3!
_Version9_0_4!
Win2000! Windows 2000 platform
CorelWine! Synonym for Linux in the Linux version of the Suite.
Note
This command is not available for use on a Linux operating system.
boolean or numeric := value or array IN array
boolean or numeric := string IN string
Description
Operator. Precedence level 6.
Examples
z := 3 IN {1; 2; 3}
Result: z = 3
z := 3 IN (1; 2; 4}
Result: z = False
z := {1; 2; 3} IN {1; 2; 3}
Result: z = True
z := {1; 2; 3} IN {1; 2; 3; 4}
Result: z = True
z := {1; 2; 3} IN {1; 2; 4}
Result: z = False
Return Value (arrays)
True if the left operand is contained in the right operand, or False is not. The left operand may be a value or an array. The right operand must be an array.
If the left operand is a value equal to one of the elements in the right operand array, True is returned.
If the left operand is an array, and every element in the array is equal to some element in the right operand array, True is returned.
If the left operand is a simple value, and the right operand is an array, and the left operand is in an element of the array, the index in the array of the left operand value is returned. If the array is a single dimensional array, this index is a direct index into the array. If the array is multidimensional, this is a composite index that represents the index where this value would be found if all elements in the array were laid out in a long single dimensional array in column major order. For example, 12 IN {{1;3;4;7;8};{5;9;2;12;0}} will return 9. It is really at index [2; 4] in a multidimensional array. This array is 2 rows of 5 elements. If this array were laid out as a single dimensional array in column major order, it would look like the array {1;3;4;7;8;5;9;2;12;0}. 12 is at index 9 in this array.
Return Value (strings)
If the left hand value is not a substring of the right hand value, False is returned. If the left hand value is a substring, the substring index in string is returned (1 based index). This command is case- sensitive. If a case-insensitive comparison is desired, use Toupper on both the left and right values. If the left operand is an empty string, True is returned.
Include
Example
Syntax
(<FileName> string)
Description
Specify a file with executable statements, functions, and/or procedures to include in a macro. The functions and procedures can be called from the macro.
Include is a non-executable statement that can occur anywhere in a macro. Include files are automatically compiled with the macro. Return or Quit statements in an Include file end all macro execution. Makesure that the included file is not compiled.
Parameters
<FileName> string The path and name of a macro file. You cannot substitute string with a variable.
Example
// There are two macros in this example
// The INCLUDE macro (INC.WCM) is compiled when
// you play the MAIN macro (PARENT.WCM)
// Demonstrate INCLUDE command
// INCLUDE macro: INC.WCM
// Without compiling, save this macro in the macros directory
APPLICATION (A1; "WordPerfect"; Default; "EN")
Type("2")
PROCEDURE TestProc(x)
Type(x)
ENDPROC
// MAIN macro: PARENT.WCM
APPLICATION (A1; "WordPerfect"; Default; "EN")
Type("1")
INCLUDE("INC.WCM")
Type("3")
CALL TestProc(4)
QUIT
any := Indirect
Example
Syntax
Direct: (<VariableName> string)
Indirect: (<VariableName> string) := any
Description
Create variable and label names out of a combination of character strings and/or numbers. Indirect can also be used on the left hand side of an assignment statement (Indirect(variable) := any).
Use Indirect wherever you would use a variable. On the right side of an assignment statement, variable must be declared and initialized before Indirect. You can use Indirect to call a Label, but not to create one.
State1 := "Utah"
x := Indirect("State" + 1) // x equals "Utah"
Variable Example in shorthand notation
State1 := "Utah"
State2 := "Idaho"
State3 := "Arizona"
ForNext(Nmbr; 1; 3; 1)
Type("State of " + Indirect("State" + Nmbr))
HardReturn
EndFor
Explanation: Types three lines: State of Utah, State of Idaho, and State of Arizona.
Label Example
ForNext(x; 1; 3; 1)
Call(Indirect("Lab" + x))
EndFor
Quit
Label(Lab1)
...statement block...
Return
Label(Lab2)
...statement block...
Return
Label(Lab3)
...statement block...
Return
Explanation: Call three Labels with a single Call statement in a ForNext loop.
Return Value
The contents of <VariableName>.
Parameters
<VariableName> string Character strings and/or numbers are concatenated to form variable and Label names. You cannot use Indirect to create a subroutine name.
numeric := Integer
Example
Syntax 1
(Value: numeric)
Description 1
Return the integer portion of a real number.
If Value does not contain an integer, 0 is returned. A negative real number is rounded up to the next integer value, and a positive real number is rounded down.
Return Value 1
An integer.
vInteger := Integer(1.5)
Result: vInteger equals 1
vResult := Integer(1.77 * 2)
Result: vResult equals 3
vZero := Integer(.7)
Result: vZero equals 0
vNegative := Integer(-1.77)
Result: vNegative equals -2
Parameter 1
Value: numeric A real number.
Syntax 2
(<Value>: numeric)
Description 2
Lets you specificy a parameter's type and format. Intever can be used only to pass parameters in calls to OLE automation methods or properties. Integer generates a compile-time error if used outside an OLE automation call.
Return Value 2
Integer
Parameter 2
Value: numeric The value or variable to be converted and passed as a parameter.
signed 2 byte numeric := Integer
Syntax 2
(<Value>: numeric)
Description 2
Lets you specificy a parameter's type and format. Intever can be used only to pass parameters in calls to OLE automation methods or properties. Integer generates a compile-time error if used outside an OLE automation call.
Return Value 2
Integer
Parameter 2
Value: numeric The value or variable to be converted and passed as a parameter.
numeric := Integer
Example
Syntax
(Value: numeric)
Description
Return the integer portion of a real number.
If Value does not contain an integer, 0 is returned. A negative real number is rounded up to the next integer value, and a positive real number is rounded down.
Return Value
An integer.
vInteger := Integer(1.5)
Result: vInteger equals 1
vResult := Integer(1.77 * 2)
Result: vResult equals 3
vZero := Integer(.7)
Result: vZero equals 0
vNegative := Integer(-1.77)
Result: vNegative equals -2
Parameters
Value: numeric A real number.
numeric := IntegerPart
Syntax
(Value: numeric)
Description
Return the integer portion of a numeric value (the integer of 3.2 is 3.0).
Example
vInt := IntegerPart (3.2)
Result: vInt = 3.0
Return Value
Integer portion of a numeric value.
Parameters
Value: numeric A fractional number (return integer part of).