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.
|
Nest |
| Purpose |
Call (start) a nested macro. This command is included for DOS compatibility. The Windows equivalent is Run. A nested macro starts immediately when called. When a nested macro ends, the first statement following Nest is executed. PerfectScript automatically compiles uncompiled Nest macros. Macro execution stops if the macro will not compile. |
||||||
| Examples | Appendix A: 8010 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
NetAddConnection |
| Purpose | Connect to a network resource. | |||||||||||||||||||||||||||||||
| Return Value | Returns 0 if the connection was successful, or a non-zero value that represents an error code if not. | |||||||||||||||||||||||||||||||
| Examples | NetAddConnection ("wpc35 | |||||||||||||||||||||||||||||||
| dev1:win32sh"; "I:") | ||||||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||||
| Parameters |
|
|
NetCancelConnection |
| Purpose |
Terminate a connection to a network resource. |
|||||||||||||||
| Return Value | True if successful, False if not. | |||||||||||||||
| Examples | NetCancelConnection ("I:") | |||||||||||||||
| Syntax |
|
|||||||||||||||
| Parameters |
|
|
NetConnectionDlg |
| Purpose | Open a dialog box for connecting to network resources. | |||||
| Return Value | The status code returned by the dialog. | |||||
| Syntax |
|
|||||
| Parameters |
|
|
NetDisconnectDlg |
| Purpose | Open a dialog box for disconnecting from network resources. | |||||||
| Return Value | The status code returned by the dialog. | |||||||
| Syntax |
|
|||||||
| Parameters |
|
|
NetGetConnection |
| Purpose | Return the name of a network resource associated with a local device. | |||
| Return Value | string Empty when an error occurs. | |||
| Examples | vNetResource := NetGetConnection ("M:") | |||
| Syntax |
|
|||
| Parameters |
|
|
NetGetUniversalName |
| Purpose | Get the UNC name of a local file. | |||
| Return Value | UNC name of a local file. | |||
| Syntax |
|
|||
| Parameters |
|
|
NetGetUser |
| Purpose | Get a user network ID. |
| Return Value | User network ID. |
| Syntax | string := NetGetUser () |
|
NewDefault |
| Purpose |
Specify a macro's new default application. NewDefault accepts the prefix of an OLE object, as well as a product mnemonic. The compiler verifies that each product command is valid for the default application. Invalid product commands produce a syntax error during compilation. This is a compile-time only statement, and makes the specified object prefix or product mnemonic the current default prefix for unknown commands. Product commands to the default application do not require a product prefix. A product command to a non-default application, without a product prefix, creates a compile-time syntax error. |
|||
| Examples | Appendix A: 8027 | |||
| Syntax |
|
|||
| Parameters |
|
|
Next |
| Purpose |
Advance a loop iteration before the end of the loop. Use Next inside a conditional statement such as If or Switch in a loop to advance a loop iteration when a specified condition is met. Statements after Next are ignored. |
| Examples | Appendix A: 8031 |
| Syntax | Next |
|
NOT |
| Purpose |
Operator. Precedence level 1. Invert the result of a relational expression. See Logical Operators and Logical Expressions |
in Chapter 4: Expressions. |
| Return Value | True if the inverted value is true, False if not. | |
| Syntax | boolean := NOT boolean |
|
NotFound |
| Purpose |
Determine how a macro responds to a Not Found condition. A Not Found condition is generally the result of a failed search. Create a Not Found condition with Assert(NotFoundCondition!). |
|||||||||
| Examples | Appendix A: 8021 | |||||||||
| Return Value |
|
|||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
NthRoot |
| Purpose | Get the Nth root of a value. | ||||||
| Return Value | Nth root of a value. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
NToC |
| Purpose | Convert a number to its character equivalent. | |||
| Examples | Appendix A: 8028 | |||
| Return Value | The character equivalent of an ANSI decimal value. | |||
| Syntax |
|
|||
| Parameters |
|
|
NToC |
| Purpose | Convert a number from a Corel WordPerfect character set to its character equivalent. | ||||||
| Examples | Appendix A: 8028 | ||||||
| Return Value | The character equivalent of a number in a Corel WordPerfect character set. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
NumStr |
| Purpose | Convert a number to a character string of numbers. | |||||||||
| Return Value |
A character string of numbers.
|
|||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
Object |
| Purpose |
Defines an OLE object variable prefix. After a prefix variable is defined, the prefix is used to identify all object method (command) calls and properties (values). Before methods and properties can be accessed, an object instance must be assigned to this variable by the CreateObject or GetObject commands. |
|||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|
ObjectInfo |
| Purpose | Return information about an OLE object. | ||||||||||||||||||||
| Return Value | Specified item. If the variable specified is not an object variable, False is returned. | ||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||
| Parameters |
|
||||||||||||||||||||
|
OemString |
| Purpose | Pass a value as an OEM string (DLL call in0line parameter function). See DLLCall. | ||
| Syntax |
|
|
OnCancel |
| Purpose |
Specify a Label or routine (function or procedure) to execute when a Cancel condition occurs. A macro with more than one OnCancel executes the last OnCancel before a Cancel condition occurs. A Cancel condition stops a macro unless preceded by OnCancel. |
|||
| Examples | Appendix A: 8002 | |||
| Return Value | The previous Label set to execute by the OnCancel command. If there is no label, "" is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OnCancel Call |
| Purpose |
Specify a Label-Return statement or routine (function or procedure) to execute when a Cancel condition occurs. Return directs macro execution to the first statement after the Cancel condition. A macro with more than one OnCancel Call executes the last OnCancel Call before a Cancel condition occurs. A Cancel condition stops a macro unless preceded by OnCancel Call. |
|||
| Examples | Appendix A: 8035 | |||
| Return Value | The previous Label set to execute by the OnCancel Call command. If there is no label, "" is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OnCondition |
| Purpose |
Specify a Label or routine (function or procedure) to execute when a Cancel, Error, NotFound, or user-defined condition occurs. A macro with more than one OnCondition executes the last Condition command before a Cancel, Error, NotFound, or user-defined condition occurs. One of these conditions stops a macro unless preceded by OnCondition. |
||||||||||||||||||
| Note | A user-defined condition number must be greater than or equal to 100. It is expressed as UserDefinedCondition! + numeric, or as a numeric. For example, UserDefinedCondition! + Assert to cause the user-defined condition. | ||||||||||||||||||
| Return Value | The previous Label set to execute by the OnCondition command. If there is no label, "" is returned. | ||||||||||||||||||
| Syntax |
|
||||||||||||||||||
| Parameters |
|
|
OnCondition Call |
| Purpose |
Specify a Label-Return statement or routine (function or procedure) to execute when a specified condition occurs. See Condition. Return directs macro execution to the first statement after the specified condition. A macro with more than one OnCondition Call executes the last Condition command before a Cancel, Error, NotFound, or user-defined condition occurs. One of these conditions stops a macro unless preceded by OnCondition Call. |
||||||||||||||||||
| Note | A user-defined condition number must be greater than or equal to 100. It is expressed as UserDefinedCondition! + numeric, or as a numeric. For example, UserDefinedCondition! + Assert to cause the user-defined condition. | ||||||||||||||||||
| Return Value |
The previous Label set to execute by the OnCancel Call command. If there is no label, "" is returned. |
||||||||||||||||||
| Syntax |
|
||||||||||||||||||
| Parameters |
|
|
OnDDEAdvise Call |
| Purpose | Establish a link with an application and test for changes in the value of the DDERequest ItemName parameter. | |||||||||||||||||||
| Return Value |
Refer to a Microsoft SDK (DdeGetLastError function) for detailed information on each enumeration. One of the following enumerations: |
|||||||||||||||||||
|
||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||
| Parameters |
|
|
OnError |
| Purpose |
Specify a Label or routine (function or procedure) to execute when an Error condition occurs. A macro with more than one OnError statement executes the last OnError before an Error condition occurs. An Error condition stops a macro unless preceded by OnError. |
|||
| Examples | Appendix A: 8002 | |||
| Return Value | The previous Label set to execute by the OnError command. If there is no label, "" is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OnError Call |
| Purpose |
Specify a Label-Return statement or routine (function or procedure) to execute when an Error condition occurs. Return directs macro execution to the first statement after the Error condition. A macro with more than one OnError Call statement executes the last OnError Call before an Error condition occurs. An Error condition stops a macro unless preceded by OnError Call. |
|||
| Examples | Appendix A: 8030 | |||
| Return Value | The previous Label set to execute by the OnError Call command. If there is no label, "" is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OnExit |
| Purpose |
Specifies a label or routine (function or procedure) to execute when an Exit condition occurs. A macro calls this label when it encounters one of the following exit conditions: Quit command, Return command from the main body of a macro, all macro statements have been executed (macro ends), Exitcondition! asserted (see Assert command). |
|||
| Return Value | Previous exit handler label. If one does not exist, an empty string ("") is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OnNotFound |
| Purpose |
Specify a Label or routine (function or procedure) to execute when a Not Found condition occurs. A macro with more than one OnNotFound statement executes the last OnNotFound before a Not Found condition occurs. A Not Found condition stops a macro unless preceded by OnNotFound. |
|||
| Examples | Appendix A: 8002 | |||
| Return Value | The previous Label set to execute by the OnNotFound command. If there is no label, "" is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OnNotFound Call |
| Purpose |
Specify a Label-Return statement or routine (function or procedure) to call when a Not Found condition occurs. Return directs macro execution to the first statement after the Not Found condition. A macro with more than one OnNotFound Call statement calls the last OnNotFound Call before a Not Found condition occurs. A Not Found condition stops a macro unless preceded by OnNotFound Call. |
|||
| Examples | Appendix A: 8031 | |||
| Return Value | The previous Label set to execute by the OnNotFound Call command. If there is no label, "" is returned. | |||
| Syntax |
|
|||
| Parameters |
|
|
OpenFile |
| Purpose |
Open a file for reading and writing text data. Close the file when it is no longer needed, or system resources will be lost. The file is closed automatically when the macro ends. See CloseFile. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
| Examples | Appendix A: 8088 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Return Value |
The file ID, or a negative number if an error occurs. The following file I/O (input/output) commands require a file ID:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|
OR |
| Purpose | Operator. Precedence level 9. Combine two relationship expressions. See Logical Operators and Logical Expressions in Chapter 4: Expressions. |
| Return Value | True if at least one expression is true, False if not. |
| Syntax | boolean := boolean OR boolean |
|
Pause |
| Purpose |
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. |
| Examples | Appendix A: 8032 |
| Syntax | Pause |
|
Persist |
| Purpose |
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. |
||||||
| Examples | Appendix A: 8022 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
PersistAll |
| Purpose |
Assign a macro's variables and arrays to the Persist variable table. Persist variables are available to any PerfectFit application while PerfectFit is running. 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" |
|||||||
| Examples | Appendix A: 8033 | |||||||
| Return Value |
|
|||||||
| Syntax |
|
|||||||
| Parameters |
|
|
pi |
| Purpose | Get 'pi' (3.14.... ratio of the circumference of a circle to its diameter). |
| Return Value | Result of pi. |
| Syntax | numeric := pi |
|
Procedure |
| Purpose |
Identify a macro subroutine that can receive one or more values from a calling statement (see Calling Statements in Chapter 5: Conditional, Loop, and Calling Statements). 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. |
||||||
| Examples | Appendix A: 8004 | ||||||
|
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:
In the next example, the value of x is 10 after calling Test:
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:
The syntax accepts EndProc or EndProcedure. |
||||||
| Syntax |
|
||||||
|
|||||||
| Parameters |
|
|
Procedure Prototype |
| Purpose |
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 (see Compiler Errors in Chapter 3: Creating Macros). 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. |
||||||
| Examples | Appendix A: 8004 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
Product |
| Purpose | Get the product of a list of values. | |||
| Return Value | Product of a list of values. | |||
| Syntax |
|
|||
| Parameters |
|
|
Prompt |
| Purpose |
Display a message box with OK and Cancel button controls. 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 general form of a Prompt statement is:
A Prompt statement can have another form:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
| Examples | Appendix A: 8032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|
Quit |
| Purpose | End a macro. |
| Note | Chain does not execute if a macro ends because of Quit. |
| Examples | Appendix A: 8005 |
| Syntax | Quit |