Chapter 11

See Graphic.

Corel® PerfectScript® 8 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.


Beep

Purpose

Cause a computer speaker or installed sound board to beep.

Beep is commonly used with warning messages, or to signal when a macro pauses or finishes a task.

Syntax

Beep([BeepType: enumeration])

Parameters

BeepType

enumeration (optional) Type of beep to produce. Supported beep types correspond to the types listed in the Windows Sounds Control Panel. If missing, Default! is used.

Default!

System default sound ("Default" in Control Panel).

Question!

System question sound ("Question" in Control Panel).

Asterisk!

System asterisk sound ("Asterisk" in Control Panel).

Exclamation!

System exclamation sound ("Exclamation" in Control Panel).

CriticalStop!

System stop sound ("CriticalStop" in Control Panel).

Standard!

Uses computer’s built in speaker sound.


BIFFilePath

Purpose

Retrieve the path and filename of a 16-bit BIF (Binary Initialization File).

This command is provided for backward compatibility only. Settings are now located in the Windows Registry (see the Registry commands).

Return Value

The BIF path and filename.

Syntax

string := BIFFilePath ([BIFFileType: enumeration])

Parameter

BIFFileType

enumeration The BIF type that is returned in BIFFilePath. A user can have only two active BIF files. Default: Private!

Private!

A BIF file containing settings that apply to a single user.

Public!

A BIF file containing settings that are shared by many, and possibly concurrent, users.


BIFInfo

Purpose

Retrieve information from a BIF (Binary Initialization File).

This command is provided for backward compatibility only. Settings are now located in the Windows Registry (see the Registry commands).

Return Value

The status of the BIF call is returned in a variable. As a function, you can use BIFInfo in an If statement. The values are:

Success!

BufferTooSmall!

Length of Group, Section, or Item exceeds buffer size.

ItemNotFound!

UnknownError!

Syntax

enumeration := BIFInfo ([Status: variable]; [Group: string]; [Section: string]; [Item: string]; [DateTime: variable]; [ItemFlags: variable]; [ItemLength: variable]; [ItemType: variable]; [UseCount: variable]; [ItemInfoType: enumeration]; [BIFFile: string])

Parameters

Status

variable (optional) The status of a BIF call is returned in this variable (see Return Value above). The semicolon is still required if not used.

Group

string (optional) The name of a Group. If this parameter is not used, the number of Group names is returned in the UseCount parameter.

Section

string (optional) The name of a Section. If this parameter is not used, the number of Section names in the specified Group is returned in the UseCount parameter.

Item

string (optional) The name of an Item. If this parameter is not used, the number of Item names in the specified Group and Section is returned in the UseCount parameter.

Note

No data is returned unless you specify a variable (following five parameters).

DateTime

variable (optional) The date and time the item was created is returned in this variable.

ItemFlags

variable (optional) The flags associated with an item are returned in this variable. If Group, Section, and Item are not used, 0 is returned.

ItemLength

variable (optional) The length of an item entry is returned in this variable. If Group, Section, and Item are not used, 0 is returned.

ItemType

variable (optional) The item type is returned in this variable. If Group, Section, and Item are not used, 0 is returned. This is the value sent to the ItemType parameter of BIFRead and BIFWrite.

UseCount

variable (optional) If Group, Section, or Item is not used, the number of Groups, Sections, or Items in a BIF is returned in this variable (see the Group, Section, and Item parameters). Otherwise, 0 is returned.

ItemInfoType

enumeration (optional) The standard BIF types to examine. Default: Private!

Both!

Look in both standard BIFs. Only valid when counting Groups, Sections, or Items.

Private!

Look in Private BIF only.

Public!

Look in Public BIF only.

BIFFile

string (optional) The name of a non-standard BIF. If not specified, the command uses the implicit BIF file.


BIFRead

Purpose

Read a BIF (Binary Initialization File), and return Group, Section, or Item names, or item value.

This command is provided for backward compatibility only. Settings are now located in the Windows Registry (see the Registry commands).

Notes

Group, the highest BIF level.

Section, the next BIF level after Group, is associated with Group subdivisions.

Item, the lowest BIF level, is associated with a Section entry.

Items contain values.

Group, Section, and Item names are subject to change.

Return Value

The status of a BIF call is returned in a variable. As a function, you can use BIFRead in an If statement. Any value greater than or equal to Success! is successful.

Success!

TypeMismatch!

ItemType does not match the returned item type (see ItemType parameter).

BufferTooSmall!

Length of Group, Section, or Item exceeds buffer size.

ItemNotFound!

UnknownError!

Syntax

enumeration := BIFRead ([Status: variable]; [Group: string]; [Section: string]; [Item: string]; Value: variable; [ExpectedItemType: enumeration]; [NameSeparator: string]; [NameListType: enumeration]; [BIFFile: string])

Parameters

Status

variable (optional) The status of a BIF call is returned in this variable (see Return Value above). The semicolon is still required if not used.

Group

string (optional) Contains a Group name. If Group is not used, the BIF Group names are returned in a variable (see Value parameter).

Section

string (optional) Contains a Section name. If Group is used and Section is not, the BIF Section names for the specified Group are returned in a variable (see Value parameter).

Item

string (optional) Contains an Item name. If Group and Section are used and Item is not, the BIF Item names for the specified Group and Section are returned in a variable (see Value parameter).

Value

variable The Group, Section, or Item names are returned in this variable, depending on which one is not used. If Group, Section, and Item are used, the Item value is returned.

ExpectedItemType

enumeration (optional) The expected item type to return in a variable (see Value parameter). ItemType is not used if Group, Section, or Item is not used. If not specified, the command uses the BIF ItemType.

Any!

Boolean!

SignedByte!

UnsignedByte!

SignedWord!

UnsignedWord!

SignedDWord!

UnsignedDWord!

Float4!

Float8!

Float32Bit!

Float64Bit!

AnsiString!

WPWordString!

BagOfBits!

NameSeparator

string (optional) A delimiter string that separates Group, Section, or Item names. The delimiter is not limited to a single character. If missing, the default is a semicolon. NameSeparator is not used when returning an item value (Group, Section, and Item are used).

NameListType

enumeration (optional) A standard BIF to read. Standard BIFs are associated with Corel WordPerfect products (see BIFFile parameter). Default: Both!. The values are:

Both!

Look in both standard BIFs.

Private!

Look in Private BIF only.

Public!

Look in Public BIF only. You cannot specify Public! to read an Item value. Public! is ignored unless you are reading a list (Group, Section, or Item names).

BIFFile

string (optional) The name of a non-standard BIF (a user-defined or non-Corel WordPerfect product BIF). If both parameters are used, BIFFile overrides NameListType. If neither parameter is used, the default is NameListType.


BIFWrite

Purpose

Write data to a BIF (Binary Initialization File), or delete a group, section, or item from a BIF.

This command is provided for backward compatibility only. Settings are now located in the Windows Registry (see the Registry commands).

Notes

See BIFRead for a description of BIF Groups, Sections, Items, and Values. To write data to a BIF, you must use the Group, Section, Item, and Value parameters. If you do not specify a value for each parameter, you will delete a level or item from the BIF. See the parameter descriptions below.

BIFWrite calls to the public and private BIF fail if a Corel WordPerfect Suite application is running.

Return Value

The status of a BIF call is returned in this variable. As a function, you can use BIFRead in an If statement. Any value greater than or equal to Success! is successful.

Success!

UnknownError!

Unknown Group, Section, or Item type.

TypeUnknown!

ItemNotFound!

ItemNotFound!

StillInPublic!

Syntax

enumeration := BIFWrite ([Status: variable]; [Group: string]; [Section: string]; [Item: string]; [Value: any]; [ItemType: enumeration]; [ItemFlags: enumeration]; [BIFFile: string])

Parameters

Status

variable (optional) The status of a BIF call is returned in this variable (see Return Value above). The semicolon is still required if not used.

Group

string (optional) A Group name. To delete a Group, specify the Group name and do not use the Section parameter. To delete all Groups, Sections, and Items, do not use the Group parameter.

Section

string (optional) A Section name. The Group name must be used. To delete a Section, specify the Section name and do not use the Item parameter. If not used, Group is deleted.

Item

string (optional) An Item name. The Group and Section names must be used. To delete an Item, specify the Item name and do not use the Value parameter. If not used, Section is deleted.

Value

any (optional) The Item value to write to the BIF. If not used, Item is deleted.

Do not write to a standard BIF while the associated Corel WordPerfect application is running. Standard BIFs remain open while Corel PerfectFit is running.

ItemType

enumeration (optional) The Value data type to write to the BIF.

Any!

Boolean!

SignedByte!

UnsignedByte!

SignedWord!

UnsignedWord!

SignedDWord!

UnsignedDWord!

Float4!

Float8!

Float32Bit!

Float64Bit!

AnsiString!

WPWordString!

BagOfBits!

If you write a new value to a BIF item, you must specifiy the same type as the previous item. If not specified, ItemType is determined by the current data value.

If ItemType does not match the current value type, it is converted if possible. If not converted properly, you may not be able to read the value back later (see BIFRead).

ItemFlags

enumeration (optional) Flags (attributes) affect only the public BIF. Value 4 is processed when an item is read from a BIF. All other values are processed when Shared Code starts. Default: None!

None!

No flags.

DeletePrivate!

Remove an item in a private BIF that has the same name as an item in the public BIF.

OverridePrivate!

The public BIF item has precedence over an item with the same name in a private BIF. Normally, the opposite is true.

DistributeToPrivate!

An item is copied to the private BIF when opened.

OverridePrivate!

The public BIF item has precedence over an item with the same name in a private BIF. Normally, the opposite is true.

BIFFile

string (optional) Contains the name of a non-standard BIF to write to. If the BIF does not exist, it is created with specified Group, Section, and Item names, and Item value. If missing, the command uses the private BIF (see BIFRead, NameListType parameter).


BinaryPack

Purpose

Pack data into a raw binary data form.

Return Value

Raw binary data returned from BinaryPack.

Syntax

raw binary data := BinaryPack (Value: any; [TotalSize: enumeration or numeric]; {[Offset: enumeration or numeric]; [Type: enumeration]; [Size: enumeration or numeric]})

Parameters

Value

any The value to be packed.

TotalSize

enumeration or numeric (optional) The total size of the raw binary data value to produce. This parameter may be specified as a numeric value, or as the enumeration value Auto!

If missing or Auto!, the raw binary data will be the size of all its parts combined.

Note

The next three parameters form an optional repeating group. Currently, only one group is permitted. If one parameter is used, all must be used. Parameters specify the attributes of the value to be packed into the raw binary data value. Multiple groups may be specified, each describing one value to be packed.

Offset

enumeration or numeric (optional) The beginning offset (starting at 0) within the raw binary data value to pack Value into. This is the offset of the first byte of the data value. This parameter may be specified as a numeric value, or as the enumeration Auto!. If missing, or specified as Auto!, the next available offset (starting at 0) is used. Any gaps in the final raw binary data value may contain undefined data.

Type

enumeration (optional) The type that Value is packed into. The default size for the Size parameter is shown in [ ]. If missing, Auto! is used.

Auto!

Actual data type of Value is used.

Detect!

Actual data type of Value is used.

Byte!

Pack Value into bytes (1..n bytes [1]).

Word!

Pack Value into a word (2 bytes [2]).

DWord!

Pack Value into a double word (4 bytes [4]).

Real!

Pack Value into a ‘C’ double (8 bytes [8]).

Integer!

Pack Value into a ‘C’ long (1, 2, 4 bytes [4]).

Boolean!

Pack Value into a Windows BOOL (1, 2, 4 bytes [4]).

WPString!

Pack Value into a Corel WordPerfect string (2 byte characters [length+1]).

AnsiString!

Pack Value into an ANSI string (1 byte characters [length+1]).

HexString!

Pack Value into direct binary data from a string of hex characters (1 byte characters [length]).

Size

enumeration or numeric (optional) The size, in bytes, of the raw binary data of Value. This parameter may be specified as a numeric value, or as the enumeration value Auto!. If missing, or specified as Auto!, the default size of Type is used (shown above in [ ]).

Note

If the Type parameter is Word!, DWord!, or Real!, the Size parameter must be Auto!, or it must agree with the default size for that type (shown in [ ] above).

If Type is Integer! or Boolean!, Size must be Auto!, or it must be 1, 2, or 4.

If Type is WPString! or AnsiString!, Auto! uses the full length of the string plus 1. If Size is larger than the length, the excess data is zero filled. If Size is smaller, only Size (number of) characters is used.

If Type is HexString!, each two-character pair is made into a byte. If Size is shorter , only Size (number of) bytes are produced. If Size is longer, the excess data is zero filled. If Type is Auto!, the full length of the string is used.


BinaryUnPack

Purpose

Unpack data from a raw binary data form.

Return Value

Unpacked data returned by BinaryUnPack.

Syntax

any := BinaryUnPack (Value: raw binary data; {Offset: enumeration or numeric; Type: enumeration; Size: enumeration or numeric})

Parameters

Value

raw binary data The raw binary value to unpack.

Note

The next three parameters form a repeating group. At least one group must be specified (only one group is permitted currently). If one parameter is used, all must be used. Parameters specify the attributes of the values to be unpacked from the raw binary data value. Multiple groups may be specified, each describing one value to be unpacked.

Offset

enumeration or numeric The beginning offset (starting at 0) of the value within the raw binary data to unpack. This is the offset of the first byte of the data value. If specified as Auto!, the next available offset (starting at 0) is used.

Type

enumeration Type of value to unpack from the raw binary data. The default size for Size parameter is shown in [ ].

Byte!

Unpack the value from a byte (1 byte [1]).

Word!

Unpack the value from a word (2 bytes [2]).

DWord!

Unpack the value from a double word (4 bytes [4]).

Real!

Unpack the value from a ‘C’ double (8 bytes [8]).

Integer!

Unpack the value from a ‘C’ long (4 bytes [1, 2, 4]).

Boolean!

Unpack the value from a Windows BOOL (1, 2, 4 bytes [4]).

WPString!

Unpack the value from a Corel WordPerfect string (2 byte characters [to first NULL character]).

AnsiString!

Unpack the value from an ANSI string (1 byte characters [to first NULL character]).

HexString!

Unpack the value forming a string of hex characters (1 byte [to length specified]).

Size

enumeration or numeric The size, in bytes, that Value is unpacked from. If specified as Auto!, the default size of the Type is used (shown above in [ ]).

Note

If the Type parameter is Word!, DWord!, or Real!, the Size parameter must be Auto!, or it must agree with the default size for that type (shown in [ ] above).

If Type is Intger! or Boolean!, Size must be Auto!, or it must be 1, 2, or 4.

If Type is WPString! or AnsiString!, Auto! uses the full length of the string plus 1. If Size is larger than the length, the excess data is zero filled. If Size is smaller, only Size (number of) characters are used.

If Type is HexString!, each two-character pair is made into a byte. If size is shorter, only Size (number of) bytes are produced. If Size is longer, the excess data is zero filled. If Type is Auto!, the full length of the string is used.


Break

Purpose

End a loop, and direct macro execution to the first statement after the ending loop statement (see Loop Statements in Chapter 5: Conditional, Loop, and Calling Statements).

In a Switch statement, Break directs macro execution to the first statement after EndSwitch. Break bypasses the normal test expression of a loop or conditional statement. Statements after Break are ignored.

Example

Appendix A: 8022

Syntax

Break


Call

Purpose

Call macro code associated with a Label, Procedure, or Function (see Subroutines in Chapter 5: Conditional, Loop, and Calling Statements); it can pass one or more values to a Procedure or Function.

A Return statement in a Label, Procedure, or Function directs macro execution to the statement that follows the call of the Label.

Example

Appendix A: 8005

Syntax

Call (<Label> label)

Parameters

<Label>

label A Label, Procedure, or Function name that begins with a letter and consists of one or more letters or numbers. The format for calling Label is:

Call(LabelSub)

...other statements...

Label(LabelSub)

...statement block...

Return

The syntax for calling and passing a value to a Procedure or Function is:

Call <Label> label ({<Parameter> any})

The formats for calling Procedures and Functions are:

Call ProcSub({<Parameter>})

...other statements...

Procedure ProcSub({<Parameter>})

...statementblock...

EndProc

Call FuncSub({<Parameter>})

...other statements...

Function FuncSub({<Parameter>})

...statementblock...

Return(<Value>)

EndFunc


Call

Purpose

Call macro code associated with a Label, Procedure, or Function (see Subroutines in Chapter 5: Conditional, Loop, and Calling Statements); it can pass one or more values to a Procedure or Function.

A Return statement in a Label, Procedure, or Function directs macro execution to the statement that follows the Label’s caller.

Syntax

Call <Label> label ({[<Parameter>any]})

Parameters

<Label>

label A Label, Procedure, or Function name that begins with a letter and consists of one or more letters or numbers. The format for calling Label is:

Call(LabelSub)

...other statements...

Label(LabelSub)

...statement block...

Return

The syntax for calling and passing a value to a Procedure or Function is:

Call <Label> label ({<Parameter> any})

The formats for callng Procedures and Functions are:

Call ProcSub({<Parameter>})

...other statements...

Procedure ProcSub({<Parameter>})

...statementblock...

EndProc

Call FuncSub({<Parameter>})

...other statements...

Function FuncSub({<Parameter>})

...statementblock...

Return(<Value>)

EndFunc


CallbackResume

Purpose

Resume macro execution paused by CallbackWait.  The macro continues to the next command after CallbackWait.

Example

Appendix A: 8098

Syntax

CallbackResume


CallbackWait

Purpose

Replace the loop statement after DialogShow, pausing the macro to allow the callback to be executed.  Use this command with CallbackResume.

CallbackWait and CallbackResume are easier to use and more efficient than loops.

Example

Appendix A: 8098

DialogShow ("Dialog1"; "WordPerfect"; Msg)

CallbackWait

Quit

Label (Msg)

If (Msg[5] = 274)

DialogDestroy ("Dialog1")

CallbackResume

Return

Endif

If (Msg[3] = "OKBttn")

DialogDestroy ("Dialog1")

CallbackResume

Return

Endif

Return

DialogShow ("Dialog1"; "WordPerfect"; Msg)

Loop = 1

While (Loop)

EndWhile

Quit

Label (Msg)

If (Msg[5] = 274)

DialogDestroy ("Dialog1")

Loop = 0

Return

Endif

If (Msg[3] = "OKBttn")

DialogDestroy ("Dialog1")

Loop = 0

Return

Endif

Return

Syntax

CallbackWait()


Cancel

Purpose

Determine how a macro responds to a Cancel condition. Create a Cancel condition by pressing Esc, or with Assert(CancelCondition!).

Example

Appendix A: 8005

Return Value

Off!

Previous Cancel state was Off!

On!

Previous Cancel state was On!

Syntax

enumeration := Cancel ([State: enumeration])

Parameters

State

enumeration (optional) Specify the Cancel state. Cancel state is On! when a macro begins. If missing, the current state is returned without changing it.

Off!

Ignore a Cancel condition.

On!

Stop a macro unless preceded by OnCancel, which directs macro execution to a specified Label.


Case

Purpose

A conditional statement that tests for matching expressions.  If a match is found, a Label is called.  See Conditional Statements in Chapter 5: Conditional, Loop, and Calling Statements.

Case compares <Test> to a set of <Cases> (values). If the first comparison is true (if <Test> and <Case> match), the Label following <Case> is called. If the comparison is false, the next <Case> is evaluated and so forth. If no comparison is true, DefaultLabel is called.

Example

Appendix A: 8011

Syntax

Case (<Test> any; {<Case> any; <Label> label}; [<DefaultLabel> label])

Parameters

Test

any The control expression. Variables are assigned values by commands such as GetString, GetNumber, or Menu.

Case

any An expression (variable, constant, character) with a value that is usually assigned before the macro is compiled. It is possible to assign the value at run-time.

Label

label Label to call if <Case> matches <Test>.

DefaultLabel

label (optional) The Label to execute if no <Case> matches <Test>. If not specified, the statement immediately following Case is executed.


Case Call

Purpose

A conditional statement that tests for matching expressions.  If a match is found, a Label is called.  See Conditional Statements in Chapter 5: Conditional, Loop, and Calling Statements.

Case Call compares <Test> to a set of <Cases> (values). If the first comparison is true (if <Test> and <Case> match), the Label following <Case> is executed. If the comparison is false, the next <Case> is evaluated and so forth. If no comparison is true, DefaultLabel is called.

Case is different from Case Call, in that a Return statement after Label directs macro execution to the statement that follows Case Call.

Example

Appendix A: 8007

Syntax

Case Call (<Test> any; {<Case> any; <Label> label}; [<DefaultLabel> label])

Parameters

Test

any The control expression. Variables are assigned values by commands such as GetString, GetNumber, or Menu.

Case

any An expression (variable, constant, character) with a value that is usually assigned before the macro is compiled. It is possible to assign the value at run-time.

Label

label Label to call if <Case> matches <Test>.

DefaultLabel

label (optional) The Label to execute if no <Case> matches <Test>. If not specified, the statement immediately following Case Call is executed.


CaseOf

Purpose

Identify the code to execute when a CaseOf <Selector> matches the control expression in a Switch statement.  Parentheses around Selector are optional. See Switch.

Syntax

CaseOf ({<Selector> any}):


Ceiling

Purpose

Get the smallest integer greater than or equal to a specified value (the ceiling of a number).

vInt := Ceiling (15.4)

Result: vInt = 16

Return Value

Integer.

Syntax

numeric := Ceiling (Value: numeric)

Parameters

Value

numeric Return the ceiling of this value.


Chain

Purpose

Call (start) another macro when the parent macro ends.

Corel PerfectScript automatically compiles uncompiled Chain macros. Macro execution stops if the macro will not compile. A Chain macro does not return to its caller (see Run).

Although Chain can occur anywhere in a macro, the Chain macro does not execute until the current macro ends. If the current macro contains more than one Chain command, only the macro file in the last Chain command is executed when the current macro ends.

You can cancel Chain (so the macro is not executed) with a Quit statement. For example,

Chain(EnvPaths + "Test4.wcm")

...other statements...

Switch(Test)

CaseOF 1: Chain(EnvPaths + "Test1.wcm")

CaseOF 2: Chain(EnvPaths + "Test2.wcm")

CaseOF 3: Chain(EnvPaths + "Test3.wcm")

CaseOF 4: Call(DoSomethingElse)

Default: Quit

EndSwitch

Explanation: If <Test> equals 1, 2, or 3, the corresponding macro plays when the parent macro ends. If <Test> equals 4, the DoSomethingElse subroutine is called and Test4.wcm plays when the parent macro ends. If <Test> does not equal 1, 2, 3, or 4, the macro quits and a Chain statement does not execute.

Example

Appendix A: 8009

Syntax

Chain (MacroFilename: string; {[Parameter: any]})

Parameters

MacroFilename

string The path and filename of a compiled macro.

Parameter

any (optional) Enclose multiple parameters in braces ({}), separated by a semicolon. For example: Chain ("macro"; {"a"; "b"; "c"}). Parameter values are passed to a special array variable named MacroArgs.

If missing, MacroArgs[ ] is not defined in the new macro.


CharLen

Purpose

Return the number of characters in a string, including codes. The string can be a variable, constant, character string, or result of an expression.

Example

Appendix A: 8012

Return Value

The number of characters, including codes, in a string.

Syntax

numeric := CharLen (String: string)

Parameters

String

string A variable, constant, character string, or result of an expression.


CharPos

Purpose

Return the beginning character position of a substring in a string.

Return Value

The beginning character position of a substring, or 0 if a substring is not found.

Examples

Appendix A: 8013

vPos := CharPos("WordPerfect"; "Perfect")

Result: vPos = 5

vPos := CharPos("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

numeric := CharPos (String: string; SubString: string; [Beginning: numeric])

Parameters

String

string A character string to evaluate.

Substring

string A substring to locate in String.

Beginning

numeric (optional)


CloseFile

Purpose

Close one file or all files. Close file(s) when they are no longer needed, or system resources will be lost. All open files are closed automatically when the macro ends. See OpenFile.

Example

Appendix A: 8088

Return Value

True if successful, False if not.

Syntax

boolean := CloseFile ([FileID: numeric])

Parameters

FileID

numeric (optional) If not specified, all open files are closed.


Condition

Purpose

Determine how a macro responds to a Cancel, Error, NotFound, or user-defined condition.

Return Value

Off!

Previous condition state was Off!

On!

Previous condition state was On!

Example

If Cancel is On! to start, the following two lines return the following results.

vCnd1 := Condition (CancelCondition!; Off!)

Result := vCnd1 = On!

(condition was On!, now is Off!)

vCnd2 := Condition (CancelCondition!; On!)

Result := vCnd2 = Off!

(condition was Off!, now is On!)

Syntax

enumeration := Condition (Condition: enumeration or numeric; [State: enumeration])

Parameters

Condition

enumeration or numeric Specify a condition to change. See OnCondition for a description of how to specify a user- defined condition number.

CancelCondition!

See Cancel command.

ErrorCondition!

See Error command.

ExitCondition!

See ExitHandlerState command.

NotFoundCondition!

See NotFound command.

UserDefinedCondition!

See OnCondition command.

State

enumeration (optional) Set the state of the specified condition. When a macro starts, all conditions are On!. If missing, the current state is returned without changing it.

Off!

Ignore the specified condition.

On!

Stop a macro unless preceded by OnCondition, which directs macro execution to a specified Label.


Constant

Purpose

Define a constant variable (an identifier whose value cannot change at run-time).

Constants make macros easier to read. For example,

Constant (Start := 0; Stop := 1)

defines two constants. Start is replaced by 0 wherever it occurs in the macro, and Stop by Constants are compile-time only commands that are constant from the point of declaration to the end of the macro. All constants have a single value (array constants are not accepted), and cannot appear on the left side of subsequent assignment statements (or a compile-time error occurs).

Separate multiple definitions with a semicolon. Parentheses are optional.

Constant (Inch := 2.54C; Diameter := Inch)

Constant Radius := 10I

Constant (Tel :="222-5555")

Constant Team := "Dan, Steve, Alan, Barry, Jimmy, Dave"

Syntax

Constant ({<Name> variable := <Value> any})


Constants

Purpose

Get various mathematical and physical constants.

Return Value

A constant.

Syntax

numeric := Constants (Constant: enumeration)

Parameters

Constant

enumeration The math constant to return.

e!

Napierian base of natural logarithms.

pi!

Ratio of the circumference of a circle to its diameter.

EulersConstant!

Eulers’ constant (sometimes called oiler’s constant).

GoldenRatio!

Approximately (1+(square root of 5))/2.


Continue

Purpose

Execute the code in the next CaseOf statement without evaluating its expression.  See Switch.

Syntax

Continue


ConvertType

Purpose

Convert a value to a specified data type.

If Value is a number and Type is a measurement, or if Value is a measurement and Type is a number, a measurement conversion is also applied to the magnitude of the value to convert between the measurement and the type specified by DefaultUnitsType. You can prevent this by specifying None! for DefaultUnitsType.

If both Value and Type are measurements, or if both are numbers, DefaultUnitsType is not used.

Return Value

Converted data type.

Example

vTestValue := 72

vResult = ConvertType( vTestValue; Centimeters!; Points!)

Result: vResult = 2.54C

Syntax

any := ConvertType (Value: any; Type: enumeration; [DefaultUnitsType: enumeration])

Parameters

Value

any Value to convert.

Type

enumeration Convert Value to this data type.

Boolean!

String!

WP string.

WPString!

AnsiString!

OemString!

Number!

Convert Value to a float or an integer. Value is converted to an integer if the result has no fractional part and is in the range of an integer.

Float!

Integer!

Measurement!

Convert Value to the measurement type specified by the current default units type (see DefaultUnits command).

Centimeters!

Inches!

Millimeters!

Points!

WPUnits!

RawBinary!

DateTime!

Convert Value to a DateTime value, stored as a number by the Date and Time commands. See Date and Time commands for more information.

DefaultUnitsType

enumeration (optional) Default units to use when converting between measurements and numbers. If both Value and Type are measurements, or if both are numbers, this parameter is not used. If missing, DefaultUnits! is used.

None!

Do no number to measurement conversion. This causes no conversion of the magnitude of the numeric value. It only changes the type of the value. See the None! value of the DefaultUnits command.

DefaultUnits!

Assume that numbers are in the units specified by the current default units type.

Centimeters!

Assume that numbers are in units of centimeters.

Inches!

Assume that numbers are in units of inches.

Millimeters!

Assume that numbers are in units of millimeters.

Points!

Assume that numbers are in units of points.

WPUnits!

Assume that numbers are in units of WpUnits.


CopyFile

Purpose

Copy a file.

Example

Appendix A: 8078

Return Value

True if successful, False if not.

Syntax

boolean := CopyFile (SourceFilename: string; DestinationFilename: string; [Prompts: enumeration])

Parameters

SourceFilename

string A path and filename.

DestinationFilename

string A path and filename.

Prompts

enumeration (optional) Default: NoPrompts!

NoPrompts!

Prompts!

Confirm replacement if the destination file exists.


cos

Purpose

Get the cosine of an angle in radians.

Return Value

Cosine of an angle.

Syntax

numeric := cos (Angle: numeric)

Parameters

Angle

numeric Get the cosine of this angle.


cosh

Purpose

Get the hyperbolic cosine of an angle in radians.

Return Value

Hyperbolic cosine of an angle.

Syntax

numeric := cosh (Angle: numeric)

Parameters

Angle

numeric Get the hyperbolic cosine of this angle.


CreateDirectory

Purpose

Create a directory.

Example

Appendix A: 8080

Return Value

True if successful, False if not.

Syntax

boolean := CreateDirectory (DirectoryName: string; [Prompts: enumeration])

Parameters

DirectoryName

string Include the full path.

Prompts

enumeration (optional) Default: NoPrompts!

NoPrompts!

Prompts!

Prompt if the directory exists.


CreateObject

Purpose

Create a new 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

OLEObjectVariable := CreateObject (ClassName: string)

Parameters

ClassName

string Class name of the OLE object to create, also called the ProgID. This must be the name of a register OLE automation object.


CToN

Purpose

Convert a character to its numeric equivalent.

Example

Appendix A: 8012

Return Value

Numeric equivalent of a character.

Syntax

numeric := CToN (Character: string)

Parameters

Character

string Character to convert. If a string is used, the numeric equivalent of the first character is returned.


CubeRoot

Purpose

Get the cube root of a value.

Return Value

Cube root.

Syntax

numeric := CubeRoot (Value: numeric)

Parameters

Value

numeric Get the cube root of this value.