Chapter 11
Corel® PerfectScript Programming Commands
Corel® PerfectScript Programming Commands
Three new macro commands have been added: MacroCompile, MacroIsCompiled, and MacroPlay. See online Help for information about these commands. Also, the following commands have been changed: DialogAddControl, DialogDelete, FileFind, FileNameDialog, GetFileAttributes, MacroInfo, OLEAutomation, and SetFileAttributes. See online Help for information about these commands.
|
gcf |
| Purpose |
Return the greatest common factor of a list of values. The greatest common factor is the largest number that will divide evenly into all the specified values. If the values have no common factor, 1 is returned. |
|||
| Return Value | Greatest common factor of a list of values. | |||
| Syntax |
|
|||
| Parameters |
|
|
GetCurrentDirectory |
| Purpose | Get the name of the current directory. |
| Examples | Appendix A: 8078 |
| Return Value | Name of the current directory. |
| Syntax | string := GetCurrentDirectory () |
|
GetFileAttributes |
| Purpose |
Return DOS file attributes. |
|||||||||
| Examples | Appendix A: 8082 | |||||||||
| Return Value | One of the following values, or a negative number if an error occurs. GetFileAttributes can return more than one value at a time. Use bitwise operators to determine the values. | |||||||||
|
||||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
GetFileDateAndTime |
| Purpose | Return a number representing the date and time a file was last written to. Use DateString and TimeString functions to convert the number to a string. | |||
| Examples | Appendix A: 8084 | |||
| Return Value |
A number representing a date and time, or -1 if an error occurs. |
|||
| Examples |
Explanation: Displays date and time <filename> was created. |
|||
| Syntax |
|
|||
| Parameters |
|
|
GetNumber |
| Purpose | Display a dialog box that contains an edit control to enter an integer or real number. | |||||||||
| Examples | Appendix A: 8004 | |||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
GetObject |
| Purpose | Obtains the instance of an OLE object. | ||||||
| Return Value | Instance that identifies an OLE object. After an OLE object variable is assigned an object instance, commands can be called, and values obtained and set for the object variable. When the object and variable are no longer needed, use the Discard command to destroy the object instance. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
GetString |
| Purpose |
Display a dialog box that contains an edit control to enter a character string. |
||||||||||||
| Examples | Appendix A: 8037 | ||||||||||||
| Syntax |
|
||||||||||||
| Parameters |
|
|
GetUnits |
| Purpose |
|
|||||||||
| Examples | Appendix A: 8006 | |||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
Global |
| Purpose | Declare global variables and arrays, and assign them to the global variable table. Global variables can be used in Run or Chain macros. | ||||||
| Examples | Appendix A: 8009 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
Go |
| Purpose |
Jump to a Label statement and do not return. Go is generally used to exit multiple layers of nested statements, or to create a loop. |
|||
| Examples | Appendix A: 8038 | |||
| Syntax |
|
|||
| Parameters |
|
|
GoOnLine |
| Purpose |
Start an online service at a specified location. |
||||||||||||
| Syntax |
|
||||||||||||
| Parameters |
|
|
If |
| Purpose |
A conditional statement that determines whether a statement (or statement block) is executed. See Conditional Statements in Chapter 5: Conditional, Loop, and Calling Statements. If <Test> is true, the statements between If and Else are executed. If <Test> is false, the statements between Else and EndIf are execu 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 EndI EndIf closes an If statement. The general form of an If statement is:
|
|||
| Examples | Appendix A: 8004 | |||
| Syntax |
|
|||
|
||||
| Parameters |
|
|
IfPlatform |
| Purpose |
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:
|
||||||||||||||
| Examples | Appendix A: 8057 | ||||||||||||||
| Syntax |
|
||||||||||||||
|
|||||||||||||||
| Parameters |
|
|
IN |
| Purpose | Operator. Precedence level 6. | ||||
|
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. |
||||
| 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 |
||||
|
Notes |
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. |
||||
| Syntax |
|
|
Include |
| Purpose |
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. |
|||
| Examples | Appendix A: 8091 | |||
| Syntax |
|
|||
| Parameters |
|
|
Indirect |
| Purpose |
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.
Explanation: Types three lines: State of Utah, State of Idaho, and State of Arizona.
Explanation: Call three Labels with a single Call statement in a ForNext loop. |
|||
| Examples | Appendix A: 8022 | |||
| Return Value | The contents of <VariableName>. | |||
| Syntax |
|
|||
| Parameters |
|
|
Integer |
| Purpose |
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. |
|||
| Examples | Appendix A: 8023 | |||
| 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 |
|||
| Syntax |
|
|||
| Parameters |
|
|
IntegerPart |
| Purpose |
Return the integer portion of a numeric value (the integer of 3.2 is 3.0). vInt := IntegerPart (3.2) Result: vInt = 3.0 |
|||
| Return Value | Integer portion of a numeric value. | |||
| Syntax |
|
|||
| Parameters |
|
|
Label |
| Purpose |
Identify a macro subroutine, which generally includes a statement block followed by Return or Quit. See Subroutines in Chapter 5: Conditional, Loop, and Calling Statements. Label is used by Call, Case, Case Call, Go, OnCancel, OnCancel Call, OnError, OnError Call, OnNotFound, OnNotFound Call, OnDDEAdvise Call, DDEExecuteExt. |
|||
| Examples | Appendix A: 8002 | |||
| Syntax |
|
|||
| Parameters |
|
|
lcm |
| Purpose |
Get the least common multiple of a list of values. The least common multiple is the smallest number that all specified values are multiples of. If the values have no common multiple, 1 is returned. |
|||
| Return Value | Least common multiple of a list of values. | |||
| Syntax |
|
|||
| Parameters |
|
|
lg |
| Purpose | Get the base 2 binary logarithm of a value. | |||
| Return Value | Base 2 binary logarithm of a value. | |||
| Syntax |
|
|||
| Parameters |
|
|
LIKE |
| Purpose |
Operator. Precedence level 6. Performs an equality comparison. |
|
Return Value |
boolean |
| Syntax | boolean := any LIKE any |
|
ln |
| Purpose | Get the base 'e' (natural or napierian) logarithm of a value. | |||
| Return Value | Base 'e' logarithm of a value. | |||
| Syntax |
|
|||
| Parameters |
|
|
Local |
| Purpose |
Declare local variables and arrays, and assign them to the local variable table. Variables are Local by default. The Local variable table is removed from memory when the current routine in the macro ends. |
||||||
| Examples | Appendix A: 8022 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
log |
| Purpose | Get the base 10 (common) logarithm of a value. | |||
| Return Value | Base 10 logarithm of a value. | |||
| Syntax |
|
|||
| Parameters |
|
|
logn |
| Purpose |
Get the base n logarithm of a value. |
||||||
| Return Value | Base n logarithm of a value. | ||||||
| Syntax |
|
||||||
| Parameters |
|