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.
|
SendKeys |
| Purpose |
Send keystrokes to the application that has focus. Make sure focus is where it should be. Most errors using SendKeys occur when keys are sent to the wrong place. Keys such as Alt or F1 must be enclosed in braces to specify a single keystroke. For example,
sends four keystrokes (Alt, L, L, and H) which opens the Line Height dialog box. The following commands are equivalent to the previous example:
If you combine keystrokes in a single set of braces, you must separate them with a plus operator; otherwise, the result is unpredictable. Enclosing single character keystrokes in braces is optional. Assign frequently used keystrokes to a variable. For example,
opens the Margins dialog box, and is equivalent to the Corel WordPerfect product command FormatMarginsDlg. A minus operator releases a keystroke. For example,
cuts selected text to the Clipboard (Shift+Del), then pastes it at the insertion point (Shift+Ins). SendKeys is always processed immediately. For example,
opens the Corel WordPerfect Open File dialog box. |
||||||||||
| Note | In Corel WordPerfect, set InhibitInput(Off!) for SendKeys to operate correctly. | ||||||||||
| Syntax |
|
||||||||||
| Parameters |
|
|
SetCurrentDirectory |
| Purpose | Specify a new default directory. | |||
| Examples | Appendix A: 8079 | |||
| Return Value | Return True if successful, False if not. | |||
| Syntax |
|
|||
| Parameters |
|
|
SetFileAttributes |
| Purpose | Change file attributes. | |||||||||||||||||||||||||
| Examples | Appendix A: 8083 | |||||||||||||||||||||||||
| Return Value | Return True if successful, False if not. | |||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||
| Parameters |
|
|
SetFileDateAndTime |
| Purpose | Change the date and time a file was last written to. | ||||||
| Examples | Appendix A: 8085 | ||||||
| Return Value | Return True if successful, False if not. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
Sign |
| Purpose | Return the sign of a value. | |||
| Return Value |
Return -1 if Value is less than 0, 0 if Value equals 0, and 1 if Value is greater than 0. |
|||
| Syntax |
|
|||
| Parameters |
|
|
sin |
| Purpose | Get the sine of an angle in radians. | |||
| Return Value | Sine of an angle in radians. | |||
| Syntax |
|
|||
| Parameters |
|
|
sinh |
| Purpose | Get the hyperbolic sine of an angle in radians. | |||
| Return Value | Hyperbolic sine of an angle in radians. | |||
| Syntax |
|
|||
| Parameters |
|
|
SizeOf |
| Purpose |
Get the size needed to store a specified data value. This command is mostly used with BinaryPack and BinaryUnpack. |
|||
| Return Value |
Size needed to store a specified data value. |
|||
| Syntax |
|
|||
| Parameters |
|
|
Speed |
| Purpose |
Slow macro execution. Time is measured in tenths of a second. Speed(0) runs at maximum speed. Speed(5) delays a macro one-half second between statements. The maximum delay is one minute or Speed(600). The following example delays one second between beeps.
|
|||
| Examples | Appendix A: 8035 | |||
| Syntax |
|
|||
| Parameters |
|
|
SquareRoot |
| Purpose | Get the square root of a value. | ||
| Return Value |
Square root. |
||
| Syntax |
|
||
| Parameters |
|
|
Step |
| Purpose |
Turn on Macro Debugger single stepping. See Corel PerfectScript Help for information about the debugger itself. |
||||||
| Syntax |
|
||||||
| Parameters |
|
|
String |
| Purpose | Pass a value as an ANSI string (DLL call in0line parameter function). See DLLCall. | ||
| Syntax |
|
|
StrFill |
| Purpose |
Fill (replicate) a string a specified number of times. |
||||||
| Return Value | Replicated string. | ||||||
| Examples |
|
||||||
| Syntax |
|
||||||
| Parameters |
|
|
StrFraction |
| Purpose |
Get the numeric value of a string representing a fraction. vFrac := StrFraction ("1/2") Result: vFrac = 0.5 vFrac := StrFraction ("187 7/8") Result: 187.875 |
|||
| Return Value | Numeric value of a string representing a fraction. | |||
| Syntax |
|
|||
| Parameters |
|
|
StrInsert |
| Purpose | Insert a substring into a string, replace characters in a string, or remove characters from a string. | ||||||||||||
| Return Value |
The modified string. |
||||||||||||
| Examples |
Result: ...Corel...
Result: ...Corel Canada...
Result: ...Corel Corporation... |
||||||||||||
| Syntax |
|
||||||||||||
| Parameters |
|
|
StrIsChar |
| Purpose | Determine whether a string or character is of a specified type. | ||||||||||||||||||||||||||||||||
| Return Value |
True if String is of type CharSet, False if not. |
||||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||||
| Parameters |
|
|
StrLeft |
| Purpose |
Get the left part of a string.
Result: ...Corel...
Result: ...Corel Corporation... |
||||||
| Return Value | Left part of a string. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
StrLen |
| Purpose |
Return the number of characters in a string. The string can be a variable, constant, character string, or result of an expression.
Result: vNumber equals 11
Result: vNumber equals 5
Result: vNumber equals 11
Result: vNumber equals 2 |
|||
| Examples | Appendix A: 8036 | |||
| Return Value | The number of characters in a string. | |||
| Syntax |
|
|||
| Parameters |
|
|
StrMakeList |
| Purpose | Return a list of substrings. | ||||||
| Return Value | The string list of SubString items. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
StrNum |
| Purpose | Convert a character string of numbers to a numeric equivalent. | |||
| Examples | Appendix A: 8037 | |||
| Return Value | A number. | |||
| Examples |
Result: vNum = 123
Result: vNum = 123.5
Result: vNum = 9 |
|||
| Syntax |
|
|||
| Parameters |
|
|
StrPad |
| Purpose | Pad (lengthen) a string to a specified length. | ||||||||||||||||||||||||
| Return Value | The padded string. | ||||||||||||||||||||||||
| Examples |
In the following examples, PadString consists of numbers to illustrate the command. Any string of characters, including spaces, could have been used.
Result: Corel1234512345
Result: 1234512345Corel
Result: 12345Corel12345
Result: Corel111Products222are333great |
||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||
| Parameters |
|
|
StrParseList |
| Purpose | Parse a string list into substrings. | |||||||||||||||||||||
| Return Value |
The array of substrings (a substring occupies each array element). |
|||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||
| Parameters |
|
|
StrPos |
| Purpose | Determine whether a character string is also a substring. | |||||||||
| Examples | Appendix A: 8039 | |||||||||
| Return Value |
The beginning position of a substring, or zero if a substring is not found. |
|||||||||
| Examples |
vPos := StrPos("WordPerfect"; "Perfect") Result: vPos = 5 vPos := StrPos("WordPerfect"; "Scott") Result: vPos = 0 vPos := CharPos("Corel WordPerfect"; "or"; 7) Result: vPos = 8 Explanation: Search begins at character position 7, bypassing the first occurrence of the substring. |
|||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
StrReverse |
| Purpose | Reverse all characters in a string. | |||
| Return Value | The string in reverse character order. | |||
| Syntax |
|
|||
| Parameters |
|
|
StrRight |
| Purpose |
Get the right part of a string.
Result: ...Products...
Result: ...Corel Products... |
||||||
| Return Value | Right part of a string. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
StrScan |
| Purpose | Return the index (position) of the first matching or non-matching character. | ||||||||||||||||||||||||||||||||
| Return Value | If no matching or non-matching characters are found, the length of String plus 1 is returned (or 0 if scan was reversed). | ||||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||||
| Parameters |
|
|
StrToChars |
| Purpose | Remove characters from a string. | |||||||||||||||||||||||||||||
| Return Value |
Transformed string. |
|||||||||||||||||||||||||||||
| Examples |
Result: vStr = 95
Result: vStr = Win!
Result: vStr = 95 |
|||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||
| Parameters |
|
|
StrTransform |
| Purpose | Convert a string of characters into other characters. | ||||||||||||||||||||||||
| Return Value | Transformed string. | ||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||
| Parameters |
|
|
StrTrim |
| Purpose |
Trim (remove) characters from a string. |
||||||||||||||||||||||||||||||||||||||
| Return Value | The string trimmed of characters to a specified length. | ||||||||||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|
Structure |
| Purpose | Pass a value as a C struct (DLL call in-line parameter function). See DLLCall. | ||
| Return Value | string | ||
| Syntax |
|
|
StrUnit |
| Purpose |
Convert a string of numbers to a measurement. The string may contain a number, an arithmetic expression that results in a number, or a character string of numbers. If a character string is used, alphabetic characters (except units of measure), operators, and punctuation marks are ignored. The default unit of measure is WordPerfect units. You can change the default using DefaultUnits, or by specifying a unit of measure as part of the character string. DefaultUnits(Centimeters) vUnit := STRunIT(9) Result: vUnit equals 9.C vUnit :equals STRunIT(4+3) Result: vUnit equals 7.C vUnit :equals STRunIT("10") Result: vUnit equals 10.C vUnit :equals STRunIT("10abc") Result: vUnit equals 10.C vUnit :equals STRunIT("10i") Result: vUnit equals 10I The units of measure are: " inches i inches c centimeters m millimeters p points (72 per inch) w WP units (1200 per inch) |
|||
| Examples | Appendix A: 8038 | |||
| Return Value | A unit of measure. | |||
| Syntax |
|
|||
| Parameters |
|
|
SubChar |
| Purpose | Extract a substring from a character string. Use CharPos to locate a substring. | |||||||||
| Examples | Appendix A: 8013 | |||||||||
| Return Value |
A character string. // vSub = "Word" vSub := SubChar("WordPerfect"; 1; 4) |
|||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
SubStr |
| Purpose | Extract a substring from a character string. Use StrPos to locate a substring. | |||||||||
| Examples | Appendix A: 8039 | |||||||||
| Return Value |
A character string. // vSub = "Word" vSub := SubStr("WordPerfect"; 1; 4) |
|||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
Sum |
| Purpose | Get the sum of a list of values. | |||
| Return Value |
Sum of a list of values. |
|||
| Syntax |
|
|||
| Parameters |
|
|
Switch |
| Purpose |
A conditional statement that tests for matching expressions. If a match is found, a statement (or statement block) is executed. See Conditional Statements in Chapter 5: Conditional, Loop, and Calling Statements. If Test matches Selector, the statement block that follows Selector is executed and no other evaluation is made. Test and Selector are case sensitive and must match exactly. If Continue follows an executed statement block, the next statement block is automatically executed. Continue is optional. The DEFAULT statement block is executed if no Selector matches Test. DEFAULT is optional. If no match is found and DEFAULT is not used, the macro continues to the first statement after EndSwitch. If Break occurs in a state block, the macro continues to the first statement after EndSwitch. EndSwitch closes a Switch statement. The general form of a Switch statement is:
|
||||||
| Examples | Appendix A: 8002 | ||||||
| Syntax |
|
||||||
|
|||||||
| Parameters |
|