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.
|
~ |
| Purpose | Operator. Precedence level 1. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := ~ numeric |
| Return Value | Returns the bitwise complement of a number (toggles binary value 1 to 0, or 0 to 1). |
|
** |
| Purpose | Operator. Precedence level 2. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric ** numeric |
| Return Value | Returns the left operand raised to the power of the right operand. |
| Examples |
vResult = 2**3 Result: vResult = 8 (2 to the 3rd power) |
|
* |
| Purpose | Operator. Precedence level 3. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric * numeric |
| Return Value | Return the product of two numbers. |
|
/ |
| Purpose | Operator. Precedence level 3. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric / numeric |
| Return Value | Return the floating point quotient of two numbers. |
|
% |
| Purpose | Operator. Precedence level 3. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric % numeric |
| Return Value | Return the floating point division remainder. |
|
+ |
| Purpose | Operator. Precedence level 4. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric + numeric |
| Return Value | Sum of two numbers. |
| Examples |
vNmbr := 10 + 10 Result: vNmbr = 20 |
|
+ |
| Purpose | Operator. Precedence level 4. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | string := string + string |
| Return Value | The result of concatentating two strings. |
| Examples |
vStr := "abcdefg" + "xyz" Result: vStr = "abcdefgxyz" |
|
- |
| Purpose | Operator. Precedence level 4. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric - numeric |
| Return Value | Difference between two numbers. |
| Examples |
vNmbr := 10 - 10 Result: vNmbr = 0 |
|
- |
| Purpose | Operator. Precedence level 4. See Arithmetic Operators in Chapter 4: Expressions. |
| Syntax | string := string - string |
| Return Value | Result of removing one string from another. If the right string does not occur in the left string, the left string is returned unchanged. |
| Examples |
vStr := "abcdefg" - "cd" Result: vStr = "abefg" |
|
<< |
| Purpose | Operator. Precedence level 5. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric << numeric |
| Return Value | Return the numeric result of shifting bits one or more positions to the left. Bits shifted off the left end are lost. This operator works only on integer data. |
|
>> |
| Purpose |
Operator. Precedence level 5. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric >> numeric |
| Return Value | Return the numeric result of shifting bits one or more positions to the right. Bits shifted off the right end are lost. This operator works only on integer data. |
|
<<< |
| Purpose | Operator. Precedence level 5. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric <<< numeric |
| Return Value | Return the numeric result of rotating bits one or more positions to the left. Rotated bits off the left end are inserted on the right end of the value. This operator works only on integer data. |
|
>>> |
| Purpose | Operator. Precedence level 5. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric >>> numeric |
| Return Value | Return the numeric result of rotating bits one or more positions to the right. Rotated bits off the right end are inserted on the left end of the value. This operator works only on integer data. |
|
= |
| Purpose |
The = operator has two functions. See Operators in Chapter 4: Expressions. Assignment Operator. Precedence level 10. Assign a value to a variable (synonym for ":="). See =. Relational Equality Operator. Precedence level 6. Determines if operands are equal. |
| Syntax | boolean := any = any |
| Return Value |
Returns True if two operands are equal, or False if not. This operator is defined for values and arrays. Two arrays are equal if they have the same number of dimensions and all corresponding elements are equal. |
| Examples |
z := {1; 2; 3} = {1; 2; 3} Result: z = True z := {1; 2; 3} = {1; 3; 2} Result: z = False z := {1; 2; 3} = {1; 2; 3; 4} Result: z = False |
|
<> |
| Purpose | Operator. Precedence level 6. Synonym for "!=". See Relational Operators in Chapter 4: Expressions. |
| Syntax |
boolean := any <> any |
| Return Value |
False if two operands are equal, True if not. This operator is defined for values and arrays. Two arrays are not equal if they have different dimensions or if at least one corresponding element is not equal. |
| Examples |
z := {1; 2; 3} <> {1; 2; 3} Result: z = False z := {1; 2; 3} <> {1; 3; 2} Result: z = True z := {1; 2; 3} <> {1; 2; 3; 4} Result: z = True |
|
!= |
| Purpose | Operator. Precedence level 6. Synonym for "<>". See Relational Operators in Chapter 4: Expressions. |
| Syntax | boolean := any != any |
| Return Value |
False if two operands are equal, True if not. This operator is defined for values and arrays. Two arrays are not equal if they have different dimensions or if at least one corresponding element is not equal. |
| Examples |
z := {1; 2; 3} != {1; 2; 3} Result: z = False z := {1; 2; 3} != {1; 3; 2} Result: z = True z := {1; 2; 3} != {1; 2; 3; 4} Result: z = True |
|
< |
| Purpose | Operator. Precedence level 6. See Relational Operators in Chapter 4: Expressions. |
| Syntax | boolean := any < any |
| Return Value | True if the left operand is less than the right, False if not. For strings, returns True if the left operand alphabetically precedes the right. |
|
<= |
| Purpose | Operator. Precedence level 6. See Relational Operators in Chapter 4: Expressions. |
| Syntax | boolean := any <= any |
| Return Value | Return True if the left operand is less than or equal to the right, False if not. For strings, returns True if the left operand alphabetically precedes, or is identical (including case) to the right. |
|
> |
| Purpose | Operator. Precedence level 6. See Relational Operators in Chapter 4: Expressions. |
| Syntax | boolean := any > any |
| Return Value | Return True if the left operand is greater than the right, False if not. For strings, returns True if the right operand alphabetically precedes the left. |
|
>= |
| Purpose | Operator. Precedence level 6. See Relational Operators in Chapter 4: Expressions. |
| Syntax | boolean := any >= any |
| Return Value | Return True if the left operand is greater than or equal to the right, False if not. For strings, returns True if the right operand alphabetically precedes, or is identical (including case) to the left. |
|
& |
| Purpose | Operator. Precedence level 7. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric & numeric |
| Return Value | Return bitwise AND of two numbers. Bit result is 1 if both bits are 1, 0 if not. |
|
| |
| Purpose | Operator. Precedence level 7. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric | numeric |
| Return Value | Return the bitwise OR of two numbers. The bit result is 1 if either bit is 1, and 0 if both bits are 0. |
|
^ |
| Purpose | Operator. Precedence level 7. See Bitwise Operators in Chapter 4: Expressions. |
| Syntax | numeric := numeric ^ numeric |
| Return Value | Return the bitwise XOR (exclusive OR) of two numbers. The bit result is 0 if the bits match, 1 if not. |
|
:= |
| Purpose | Operator. Precedence level 10. Assign a value to a variable. Synonym for "=" (assignment operator). |
| Syntax | variable := any |
|
= |
| Purpose |
The = operator has two functions. See Operators in Chapter 4: Expressions. Relational Equality Operator. Precedence level 6. Determines if operands are equal. See =. Assignment Operator. Precedence level 10. Assign a value to a variable (synonym for ":="). |
| Syntax | variable = any |
|
[ ] |
| Purpose | Operator. |
| Syntax | any := array[{<index> numeric; ...}] |
| Return Value | The specified element of an array. |
|
[0] |
| Purpose |
Operator. Specify zero as the index regardless of the number of dimensions. The same value is returned by the command vElements := Dimensions (array[]; 0). See Dimensions command. Declare Array[3; 5; 6] vElements := Array[0] Result: vElements = 90 |
| Syntax | numeric := array[0] |
| Return Value | The number of elements in an array variable. |
|
// |
| Purpose |
The compiler ignores all text between // and the next hard return [HRt]. Comment text does not affect macro execution. The comment line, including spaces, has a maximum length of 512 characters. |
| Syntax | // <CommentText> |
|
/* */ |
| Purpose |
The compiler ignores all text between /* and */ (// comments end at the next hard return [HRt]). Comment text does not affect macro execution. Comment blocks can be nested. If nested, a comment terminator (*/) must occur for every comment start (/*). The count must match. A /* */ statement on a line after // is ignored. A block of macro statements can be commented out by a comment block with a /* on a line above the statements and a */ on a line below. Without removing /* and */, the statements can be reactivated by putting a // statement before /* and */, which comments out the comment markers. |
| Syntax |
/*
...<CommentText> */ |
|
AbsVal |
| Purpose |
Get the absolute value of a value. The absolute value is the distance a value is from zero, and is always positive. If the value is negative, the absolute value is the positive equivalent of the same value. The absolute value of a positive value is the same value. |
|||
| Syntax |
|
|||
| Return Value | Absolute value of a value. | |||
| Parameters |
|
|
acos |
| Purpose | Get an angle in radians for a specified cosine. This is called the arc, or inverse cosine. | |||
| Syntax |
|
|||
| Return Value | Angle in radians. | |||
| Parameters |
|
|
acosh |
| Purpose | Get an angle in radians whose hyperbolic cosine is specified. This is called the arc, or inverse hyperbolic cosine. | |||
| Syntax |
|
|||
| Return Value | Angle in radians. | |||
| Parameters |
|
|
Address |
| Purpose | Pass a variable address (DLL call in-line parameter function). See DLLCall. | |||
| Syntax |
|
|||
| Parameters |
|
|
AND |
| Purpose | Operator. Precedence level 8. Combine two relationship expressions. See Logical Operators and Logical Expressions in Chapter 4: Expressions. |
| Syntax | boolean := boolean AND boolean |
| Return Value | True if both expressions are true, False if not. |
|
AnsiString |
| Purpose | Pass value as an ANSI string (DLL call in-line parameter function). See DLLCall. | ||
| Syntax |
|
|
AppActivate |
| Purpose | Activate and display a window, using the window title or the window handle. AppActivate returns the window handle, or use AppLocate to get the window handle. | ||||||
| Syntax |
|
||||||
| Return Value |
Window handle. |
||||||
| Parameters |
| ||||||
| Examples |
Appendix A: 8001
|
|
AppClose |
| Purpose | Close an application by its title or window handle. | |||
| Syntax |
|
|||
|
ReturnValue |
True if successful, False if not. | |||
| Parameters |
|
|||
| Examples | Appendix A: 8096 |
|
AppExecute |
| Purpose | Start an application and specify how its window is displayed. | |||||||||||||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||||||||||||
| Return Value |
Application handle (unique number) if the application is successfully started, or an error value less than or equal to 32 if not. For the list of error values, refer to your Windows 95 documentation. Check error values with code similar to the following:
|
|||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|||||||||||||||||||||||||||||||||||||||
| Examples | Appendix A: 8000, 8001 |
|
AppExecuteExt |
| Purpose |
The same as AppExecute. See AppExecute. |
||
| Syntax |
|
|
Application |
| Purpose |
Identify, for the compiler, an application to use in a macro. Application is a non-executable statement that can occur anywhere in a macro, but it must precede product commands to the application it identifies. Applications used in the macro automatically start unless they are already active. The user cannot terminate an application used in a macro until the macro ends. |
|||||||||||||||
| Syntax |
|
|||||||||||||||
| Parameters |
| |||||||||||||||
| Examples | Appendix A: 8000 |
|
AppLocate |
| Purpose |
Return a window handle. AppLocate compares a name to the title bar text of all open windows. If a match is found, the window handle of the matching window is returned. If the search criteria matches more than one window, the window handle of the most recently opened window is returned. If no match is found, zero is returned. You can use an asterisk (*) as a wildcard character at any position in the AppLocate parameter. If the parameter contains only an asterisk, AppLocate returns the window handle of the active window. |
|||
| Syntax |
|
|||
| Return Value | The window handle of the window found in the search, or 0 if no window is found. | |||
| Parameters |
| |||
| Examples | Appendix A: 8001 |
|
AppShow |
| Purpose | Specify an application's display state. Identify the application by title or window handle. | |||||||||||||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||||||||||||
| Return Value | Window handle. | |||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|||||||||||||||||||||||||||||||||||||||
| Examples | Appendix A: 8096 |
|
asin |
| Purpose | Get an angle in radians for a specified sine. This is called the arc, or inverse sine. | |||
| Syntax |
|
|||
| Return Value | Angle in radians. | |||
| Parameters |
|
|
asinh |
| Purpose | Get an angle in radians for a specified hyperbolic sine. This is called the arc, or inverse hyperbolic sine. | |||
| Syntax |
|
|||
| Return Value | Angle in radians. | |||
| Parameters |
|
|
Assert |
| Purpose |
Create a Cancel, Error, or Not Found condition, or user-defined condition. See OnCondition. A Cancel, Error, Not Found, or user condition stops a macro unless preceded by OnCancel, OnError, OnNotFound, or OnCondition, which direct macro execution to a specified Label. Assert has no effect when preceded by Cancel(Off!), Error(Off!), NotFound(Off!), or OnCondition(<Condition>; Off!) An error value is assigned to variable ErrorNumber when one of the conditions occur. The values are: ErrorNumber.CancelConditionAsserted! ErrorNumber.ErrorConditionAsserted! ErrorNumber.NotFoundConditionAsserted! ErrorNumber.UserDefinedCondition! You cannot assign a value to ErrorNumber. Use code similar to the following to check all conditions with one subroutine (see Subroutines in Chapter 5: Conditional, Loop, and Calling Statements).
|
||||||||||||||||||
| Syntax |
|
||||||||||||||||||
| Parameters |
| ||||||||||||||||||
| Examples | Appendix A: 8002 |
|
atan |
| Purpose | Get the angle in radians for a specified tangent. This is called the arc, or inverse tangent. | |||
| Syntax |
|
|||
| Return Value | Angle in radians. | |||
| Parameters |
|
|
atan2 |
| Purpose | Get the angle in radians for a specified tangent that is Value / Value2. This is called the arc, or inverse tangent. | ||||||
| Syntax |
|
||||||
| Return Value | Angle in radians. | ||||||
| Parameters |
|
|
atanh |
| Purpose | Get an angle in radians for a specified hyperbolic tangent. This is called the arc, or inverse hyperbolic tangent. | |||
| Syntax |
|
|||
| Return Value | Angle in radians. | |||
| Parameters |
|
|
Average |
| Purpose | Get the average of a list of values. | |||
| Syntax |
|
|||
| Return Value | Average of a list of values. | |||
| Parameters |
| |||
| Examples |
vAvg := Average (2; 4; 6; 8) Result: vAvg = 5.0 |