Endfor Missing Number

Chapter eleven

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 inverse: DialogAddControl, DialogDelete, FileFind, FileNameDialog, GetFileAttributes, MacroInfo, OLEAutomation, and SetFileAttributes. See online Help for data most these commands.


Else

Purpose

All statements between Else and Endif are executed when the If expression is Imitation.  See If.

Syntax

Else


ElseIfPlatform

Purpose

Works with IfPlatform and EndIfPlatform statements, similar to the Else statement in an If-Else-Endif control argument except that a new platform ID may be specified.

Syntax

ElseIfPlatform ([{<PlatformID> enumeration}])

Parameters

<PlatformID>

enumeration (optional, repeating) List of platform IDs to test. If the ID of the current platform is specified, only the statements upwardly to the next ElseIfPlatform statement are included in the macro (all others are ignored). If missing, the current �ignore� land is reversed (ignored statements are compiled up to the next ElseIfPlatform statement). Statements that would have been compiled are ignored; statements that would have been ignored are compiled.


EndApp

Purpose

Identify, for the compiler, an application that is no longer used in a macro (come across Application).

EndApp is a non-executable statement that can occur anywhere in a macro. Afterwards EndApp, a product control to the awarding specified by EndApp creates a compile-time syntax error.

Example

Appendix A: 8058

Syntax

EndApp (<ProductPrefix> identifier)

Parameters

<ProductPrefix>

identifier A unique identifier that must lucifer the ProductPrefix parameter of an Application statement, or the prefix of an OLE object variable. This command is a compile time only statement, and removes a product or object prefix from the product proper noun list maintained by the macro compiler. If the prefix of the electric current default object or product is removed, the previous default prefix becomes the new default prefix.


EndFor

Purpose

Close a For control loop.  See For.

Syntax

EndFor


EndFunc

Purpose

Shut a Office argument (synonym for EndFunction).  See Function.

Syntax

EndFunc


EndFunction

Purpose

Close a Function argument (synonym for EndFunc).  Encounter Office.

Syntax

EndFunction


EndIf

Purpose

Close an If control statement.  Encounter If.

Syntax

EndIf


EndIfPlatform

Purpose

Close an IfPlatform conditional compile statement.  See IfPlatform.

The parameter is optional and ignored. Its only purpose is to certificate what it goes with.

Syntax

EndIfPlatform ([{<PlatformID> enumeration}])


EndProc

Purpose

Close a Procedure statement (synonym for EndProcedure).  Meet Procedure.

Syntax

EndProc


EndProcedure

Purpose

Close a Procedure statement (synonym for EndProc).  See Process.

Syntax

EndProcedure


EndPrompt

Purpose

Terminate the current Prompt.  See Prompt.

Syntax

EndPrompt


EndSwitch

Purpose

Close a Switch control statement.  See Switch.

Syntax

EndSwitch


EndWhile

Purpose

Close a While control loop.  See While.

Syntax

EndWhile


EndWith

Purpose

Close a With statement. Run into With.

Syntax

EndWith


EnvVariableGet

Purpose

Render the value of an environment variable.

Return Value

Environment variable value.

Syntax

string := EnvVariableGet ([EnvVariableName: string]; [EnvType: enumeration])

Parameters

EnvVariableName

cord (optional) The environment variable proper name. If not used, a listing of all environment variables is returned.

EnvType

enumeration (optional) The type of variable. If mising, DOS! is used.

DOS!


EnvVariableSet

Purpose

Set the value of an environment variable, or delete information technology.

Syntax

EnvVariableSet (EnvVariableName: string; [Value: string]; [EnvType: enumeration])

Parameters

EnvVariableName

string The environs variable name.

Value

cord (optional) The value to assign to the variable. If missing, the surround variable is deleted.

EnvType

enumeration (optional) The type of variable. Default: DOS!

DOS!


Error

Purpose

Determine how a macro responds to an Error condition. Create an Error condition with Assert(ErrorCondition!).

Instance

Appendix A: 8020

Return Value

Off!

Previous country was Off!

On!

Previous state was On!

Syntax

enumeration := Mistake ([State: enumeration])

Parameters

Country

enumeration (optional) Specify the Error state. The default is Error(On!). If missing, the electric current state is returned without changing it.

Off!

Ignore an Error condition.

On!

Stop a macro unless preceded past OnError, which directs macro execution to a specified Label.


ErrorNumber

Purpose

Return the mistake value of a Cancel, Mistake, Not Found, or user-divers condition.

Notes

ErrorNumber is a macro system variable that returns an enumeration, which can exist referred to past proper noun. The enumerations accept the same numeric values equally in previous versions. The value of ErrorNumber is cleared before every control. Afterwards the command is excuted, ErrorNumber returns a value that indicates if an mistake occured. If a handler condition is disabled, the macro continues when the specified condition occurs. Yous can test ErrorNumber manually for ErrorNumber.Success!. Commands that exercise not reset Error

Number are MacroInfo(ErrorNumber!) calls, ErrorNumber itself, and compound statements, such every bit If- Endif, Switch-EndSwitch, Repeat-Until, While- EndWhile, For-EndFor, and so on. Copy the value returned by ErrorNumber into a variable if the value is needed afterwards executing other macro commands, such equally PROMPT, which reset ErrorNumber.

Render Value

Success!

Formerly value 0.

CancelConditionAsserted!

Cancel condition was asserted. Erstwhile value 1.

ErrorConditionAsserted!

An Error condition was asserted. Former value two.

NotFoundConditionAsserted!

A Not Constitute status was asserted. Former value 7.

UserDefinedCondition!

This value defines the base of operations value for assertions of user defined weather. See the Assert command for more information virtually the value of user defined status codes.

Syntax

enumeration := ErrorNumber


Exists

Purpose

Determine if a variable exists.

To be, a variable must be alleged and initialized. Given that variable westward is declared and not initialized, and that Local ten is initialized to 5, Global y to 10, and Persist z to 15, the following statements are valid:

vNoInit := Exists(west)

Result: vNoInit equals Exists.NotFound!

vLocal := Exists(10)

Result: vLocal equals Exists.Local!

vGlobal := Exists(y)

Issue: vGlobal equals Exists.Global!

vPersist := Exists(z)

Result: vPersist = Exists.Persistent!

If(Exists(vLocal))

Beep

EndIf

Explanation: Computer beeps because Exists returns a value other than Exists.NotFound!.

If(Exists(vLocal) = Exists.Persistent!)

Beep

EndIf

Caption: The computer does not beep considering Exists returns Exists.Local!. (vLocal is a Local variable, not a Persist variable.)

Example

Appendix A: 8022

Return Value

If Pool is left off, the values are:

NotFound!

Variable does not exist.

Local!

Variable exists in local pool.

Global!

Variable exists in global puddle.

Persistent!

Variable exists in persistent puddle.

If Puddle is specified, the return value is Truthful (exists in the puddle specified by the Pool parameter) or False (does not exist).

Syntax

enumeration or boolean:= Exists (VariableName: variable; [Puddle: enumeration])

Parameters

VariableName

variable A variable declared as Local, Global, or Persistent. Variables begin with a letter and can include any other combination of letters or numbers.

Puddle

enumeration (optional) If missing, the command returns the Pool the variable is in. If provided, the command returns boolean True or Faux indicating whether the variable is in the specified Pool.

Local!

Encounter if the variable exists in the local variable pool.

Global!

See if the variable exists in the global variable pool.

Persistent!

See if the variable exists in the persistent variable pool.


ExitHandlerState

Purpose

Determine how a macro responds to an Go out condition.

Create an Get out status with Assert(ExitCondition!).

Different Error, Abolish, and NotFound, ExitHandlerState does non prevent or enable a status from occurring. Information technology enables or disables calling the exit handler when an exit condition occurs.

Example

Appendix A: 8022

Render Value

Off!

Previous country was Off!

On!

Previous state was On!

Syntax

enumeration := ExitHandlerState ([State: enumeration])

Parameters

State

enumeration (optional) Specify the Exit land. If missing, the electric current state is returned without irresolute it. Default: Get out(On!).

Off!

Disable leave handler condition calling.

On!

Enable exit handler condition calling.


ExponentPart

Purpose

Return the exponent portion of a numeric value.

For case, the exponent of iii.2e18 is 18.

Return Value

Exponent portion of a numeric value.

Syntax

numeric := ExponentPart (Value: numeric)

Parameters

Value

numeric A fractional number (return exponent part of).


Factorial

Purpose

Render the Nth factorial, which is the production of all numbers in a series (1, 1, two, five, 24,...) less than or equal to a specified value.

Return Value

Nth factorial.

Syntax

numeric := Factorial (Nth: numeric)

Parameters

Nth

numeric Compute the Nth term in the series.


False

Purpose

The constant boolean value FALSE.

Syntax

boolean := Fake


Fibonacci

Purpose

Render the Nth term in a Fibonacci sequence (0, one, one, 2, 3,...). The Fibonacci is the sum of the preceding two terms in the serial.

Render Value

Nth term in a Fibonacci sequence.

Syntax

numeric := Fibonacci (Nth: numeric)

Parameters

Nth

numeric Term of the Fibonacci sequence to return.


FileConvert

Purpose

Converts a file of one blazon to a file of another type. The available file types depends on the converters installed by the user. Non all conversions are available on all systems.

A file can only exist converted to a similar file type (documents to documents, graphics to graphics, and so on).

Render Value

The common return values follow. Any value non equal to Success! is an error. Other error values are returned as numeric values.

Success!

Successful conversion.

InAndOutSame!

Input and output filenames were the same (they must be unlike).

NoDriver!

Conversion driver not available for requested conversion. It may need to be installed.

UnknownType!

File type unknown.

UnknownGraphic!

Graphic file blazon cannot exist converted.

InvalidSource!

Invalid source filename.

InvalidDestination!

Invalid destination filename.

Incompatible!

Destination file type is incompatible with the source file type.

Syntax

enumeration or numeric := FileConvert (SourceFilename: cord; [SourceFileType: enumeration or numeric]; DestinationFilename: cord; DestinationFileType: enumeration or numeric)

Parameters

SourceFilename

cord Proper name of file to convert.

SourceFileType

enumeration or numeric (optional) Blazon of source file to convert. If missing, AutoDetect! is used. Many of the file types returned past the FileType command are valid source file types. Types not listed may be specified as numeric values.

AutoDetect!

Automatically detects the file type using the FileType command.

WordPerfect42!

WordPerfect50!

WordPerfect51!

WordPerfect678!

WordPerfectCompound!

WPMac31!

WordStar70!

MSWord55!

Word60!

Word97!

RichTextFormat!

AsciiText!

AsciiFormatted!

AsciiDelimited!

AsciiCRLFtoSRT!

AsciiGenericWP!

AnsiText

AnsiDelimited!

AnsiCRLFtoSRT!

AnsiGenericWP!

AmiPro30!

WindowsWrite!

HTML!

WPG1!

WPG2!

TIFF!

WMF!

BMP!

GIF!

JPG!

CorelDRAW7!

Excel70!

Excel97!

Lotus123v4!

PresentationsMaster!

PresentationsMaster3!

DestinationFilename

cord Name of the output file.

DestinationFileType

enumeration or numeric Blazon of file to catechumen to. These values may change between major releases of PerfectScript. The common file types follow. Types not listed may be specified as numeric values.

WordPerfect42!

WordPerfect50!

WordPerfect51!

WordPerfect678!

WordPerfectCompound!

WPMac31!

WordStar70!

MSWord55!

Word60!

Word97!

RichTextFormat!

AsciiText!

AsciiDelimited!

AsciiGenericWP!

AnsiText

AnsiDelimited!

AnsiGenericWP!

AmiPro30!

WindowsWrite!

HTML!

WPG1!

WPG2!

TIFF!

WMF!

BMP!

GIF!

JPG!

CorelDRAW7!

PresentationsMaster!

PresentationsMaster3!


FileConvertError

Purpose

Returns the name of a file conversion error.

Render Value

Printable proper name of the fault returned by the FileType control.

Syntax

string := FileConvertError (ErrorCode: enumeration or numeric)

Parameters

ErrorCode

enumeration or numeric Error code for which to return a proper name, returned by the FileType command. The more mutual values follow. Specify other mistake values every bit numeric values.

InAndOutSame!

Input and output filenames were the aforementioned (they must be unlike).

NoDriver!

Conversion driver non available for requested conversion. It may need to be installed.

UnknownType!

File type unknown.

UnknownGraphic!

Graphic file type cannot exist converted.

InvalidSource!

Invalid source filename.

InvalidDestination!

Invalid destination filename.

Incompatible!

Destination file blazon is incompatible with the source file blazon.


FileError

Purpose

Return the mistake associated with the final file control.

Example

Appendix A: 8090

Return Value

A number greater than 0 (concluding file error), -ane (unknown fault), or 0 (no fault). Error numbers have loword and hiword values. The loword contains an error code generated by Corel WordPerfect�southward I/O routines, described in the Corel WordPerfect for Windows SDK (WError.H file). The hiword contains a Windows specific error value, described in the Microsoft Windows SDK.

Syntax

numeric := FileError


FileFind

Purpose

Find a file that matches user-defined search criteria (filename and DOS attributes).

Instance

Appendix A: 8090

Return Value

A filename, or an empty filename if no match is found.

Syntax

cord := FileFind ([Filename: cord]; [Attributes: enumeration]; [Context: numeric])

Parameters

Filename

string (optional) Include the full path. If missing, the next matching file is institute (come across Context below).

Attributes

enumeration (optional) Default: Normal!

Normal!

ReadOnly!

Hidden!

System!

Label!

Directory!

In improver to files, directories are also returned. This does not return directories but.

Archived!

Context

numeric (optional) A user-defined number which identifies the search. Default: 0. To discover the next file to friction match the search criteria, call FileFind with an empty filename. For instance,

vFilename = FileFind (Filename: "*.WPD"; Attributes: Normal!; Context: 1)

finds the starting time occurrence of a file with a WPD extension. The post-obit statement finds the adjacent file to match the same search criteria:

vFilename = FileFind (Filename: ""; Context: 1)

Use different Context values to perform multiple searches simultaneously. If yous perform more i search before the macro ends, you can continue any search past using the advisable Context value. The subsequent search begins where it left off.


FileIsEOF

Purpose

Return Truthful if the insertion point is at the end of a file, False if not.

The access mode must be Read! (see OpenFile).

Example

Appendix A: 8088

Render Value

True/Simulated.

Syntax

boolean := FileIsEOF (FileID: numeric)

Parameters

FileID

numeric See OpenFile.


FileNameDialog

Purpose

Brandish the Open or Save As dialog.

Return Value

The name of the file to open up or save, or "" if Cancel is pressed.

Syntax

cord := FileNameDialog (StyleOptions: enumeration; [CaptionText: cord]; [ButtonText: string]; [InitialFolder: string]; [InitialFileName: string]; [FileTemplate: string]; [RecentFiles: string])

Parameters

StyleOptions

enumeration Specifies the blazon of dialog to open and the options associated with the dialog. Type | between enumerations to combine styles. For example: OpenDialog! | FileMustExist!.

OpenDialog!

Display the Open dialog.

SaveAsDialog!

Brandish the Save Every bit dialog.

FileMustExist!

Use with OpenDialog!. The file selected for Open up must exist.

PromptOnReplace!

Use with SaveAsDialog!. If the file already exists, a prompt is displayed request whether the file should be replaced.

CaptionText

cord (optional) Text displayed in the caption bar. If missing or "", Open or Save As is displayed.

ButtonText

string (optional) Text displayed on the Open button. If missing or "", Open is displayed.

InitialFolder

string (optional) Initial folder to display. If missing or "", the current binder is displayed.

InitialFileName

string (optional) Initial filename to display. If missing or "", FileTemplate is displayed.

FileTemplate

cord (optional) Template for the files to display. If missing or "", *.* files are displayed.

RecentFiles

string (optional) Name of registry subkey where the recent files list is maintained. For example, "HKEY_CURRENT_USER\Software\..." The list tin can comprise up to fifteen filenames. If missing, no history is given. Include the full Registry path where the recent file list is maintained.


FilePosition

Purpose

Return the current marker position or set a new position.

A user can pre-allocate file size past setting the position marker past the end-of-file marker.

Instance

Appendix A: 8088

Return Value

The position of the old position mark, or a negative number if an error occurs.

Syntax

numeric := FilePosition (FileID: numeric; [NewPosition: numeric]; [PositionFrom: enumeration])

Parameters

FileID

numeric Run across OpenFile.

NewPosition

numeric (optional) The number of bytes to move the position marker. Default: 0.

PositionFrom

enumeration (optional) Move the position marker relative to one of the following positions. Default: FromBeginning!

FromBeginning!

FromCurrentPosition!

FromEnd!


FileRead

Purpose

Read text data from an open file.

Example

Appendix A: 8088

Return Value

The number of bytes read, or a negative number if an error occurs.

Syntax

numeric := FileRead (FileID: numeric; Data: variable)

Parameters

FileID

numeric See OpenFile.

Information

variable Starting from the position marker, ane line of data is converted to a WP character cord and returned in this variable.


FileSize

Purpose

Return a file�s size in bytes.

Example

Appendix A: 8088

Return Value

The file size in bytes, or a negative number if an error occurs.

Syntax

numeric := FileSize (Filename: string)

Parameters

Filename

string Include the full path.


FileTruncate

Purpose

Remove all text information after the position marker (see FilePosition).

Example

Appendix A: 8089

Render Value

The truncated file size (bytes) if successful, or a negative number if an error occurs.

Syntax

numeric := FileTruncate (FileID: numeric)

Parameters

FileID

numeric See OpenFile.


FileType

Purpose

Return a file�due south file blazon.

Return Value

Detected file type (get errors from the FileError control). The more mutual file types are listed below. Since over 200 file types are recognized, those not listed are returned as numeric values. The values returned may change in future releases of PerfectScript.

Unknown!

File doesn�t exist, or the file blazon is unknown.

WordPerfect42!

WordPerfect50!

WordPerfect51!

WordPerfect678!

WordPerfectCompound!

WPMac31!

COJava!

WordStar70!

MSWord55!

Word60!

Word97!

RichTextFormat!

AsciiText!

AnsiText!

AmiPro30!

WindowsWrite!

HTML!

SGML!

WPG1!

WPG2!

TIFF!

WMF!

BMP!

GIF!

JPG!

CorelDRAW7!

Excel70!

Excel97!

Lotus123v4!

Show!

SDIF!

Syntax

enumeration or numeric := FileType (Filename: cord)

Parameters

Filename

string Name of file to detect.


FileTypeExtension

Purpose

Render the default filename extension of a file type returned by the FileType command.

Render Value

The default filename extension of FileType (usually 2 or iii characters). If FileType does not have an extension, or if yous specify an invalid file type, an empty string is returned.

Syntax

string := FileTypeExtension (Filetype: enumeration or numeric)

Parameters

Filetype

Eumeration or numeric Type of file for which to return the default filename extension. This value is returned by the FileType control. The following listing contains some of the possible values for FileType. Types not listed can exist specified as numeric values.

WordPerfect42!

WordPerfect50!

WordPerfect51!

WordPerfect678!

WordPerfectCompound!

WPMac31!

COJava!

WordStar70!

MSWord55!

Word60!

Word97!

RichTextFormat!

AsciiText!

AnsiText!

AmiPro30!

WindowsWrite!

HTML!

SGML!

WPG1!

WPG2!

TIFF!

WMF!

BMP!

GIF!

JPG!

CorelDRAW7!

Excel70!

Excel97!

Lotus123v4!

Show!

SDIF!


FileTypeList

Purpose

Return an array (list) of detected file types.

Render Value

An assortment of file types (the same types returned by the FileType command). Associated names are obtained by passing the file types to the FileTypeName command.

Syntax

array := FileTypeList (FileType: enumeration)

Parameters

ListType

enumeration Type of list to obtain.

Detect!

Detected file types.

Source!

File types that are recognized as source file types when calling the FileConvert command.

Destination!

File types that can be destinations when calling the FileConvert command.


FileTypeName

Purpose

Returns the proper name of a file blazon.

Return Value

Printable name of the file type returned by the FileType command.

Syntax

string := FileTypeName (FileType: enumeration or numeric)

Parameters

FileType

enumeration or numeric Type of file for which to render a printable proper name. This value is returned by the FileType control. The following list contains some of the possible values for FileType. Types non listed tin can be specified equally numeric values.

WordPerfect42!

WordPerfect50!

WordPerfect51!

WordPerfect678!

WordPerfectCompound!

WPMac31!

COJava!

WordStar70!

MSWord55!

Word60!

Word97!

RichTextFormat!

AsciiText!

AnsiText!

AmiPro30!

WindowsWrite!

HTML!

SGML!

WPG1!

WPG2!

TIFF!

WMF!

BMP!

GIF!

JPG!

CorelDRAW7!

Excel70!

Excel97!

Lotus123v4!

Evidence!

SDIF!


FileWrite

Purpose

Write text data to a file.

Example

Appendix A: 8088

Render Value

The number of bytes written, or a negative number if an error occurs.

Syntax

numeric := FileWrite (FileID: numeric; Data: string; [NewLine: enumeration]; {[ParameterData: string]})

Parameters

FileID

numeric See OpenFile.

Data

string Text data is converted to the blazon specified when the file is opened. A caret (^) followed by a number is replaced by the corresponding grapheme string in the ParameterData parameter. To write a caret, use two carets (^^).

NewLine

enumeration (optional)

Default

NoNewLine!

NoNewLine!

Inserts an end-of-line mark.

NewLine!

ParameterData

string (optional)

The text data inserted in the data string (see Information parameter). Upward to 10 strings separated by semicolons are immune. Numbering begins with 0. For example,

FileWrite (FileID; Data: "My friend ^0 is ^1 years quondam."; NewLine: NewLine!; ParameterData: {"Dan"; "41"})

writes �My friend Dan is 41 years onetime.� followed past an end-of-line marker.


Floor

Purpose

Return the largest integer that is less than or equal to a specified value (the floor of a number).

Return Value

Integer.

Syntax

numeric := Floor (Value: numeric)

Parameters

Value

numeric Return the flooring of this number.


For

Purpose

A control statement (loop) that executes a specified number of times (see Loop Statements in Chapter 5: Conditional, Loop, and Calling Statements).

The loop executes only if TerminateExp is true, and continues to execute until ControlVariable�s value makes TerminateExp fake. EndFor closes a For statement.

The general form of a For statement is:

For (<ControlVariable>; <InitialValue>;<TerminateExp>; <IncrementExp>)

...statement block...

EndFor

For example, the following statement initializes vTest to one, repeats the argument block while vTest is less than ten, and increments vTest by two after each loop.

For(vTest; one; vTest ten; vTest + two)

...statement cake...

EndFor

Example

Appendix A: 8022

Syntax

For (<ControlVariable> variable; <InitialValue> any; <TerminateExp> boolean; <IncrementExp> whatever)

Parameters

ControlVariable

variable The control variable.

InitialValue

any The value assigned to ControlVariable at the showtime of a loop.

TerminateExp

boolean The loop executes while TerminateExp is truthful.

IncrementExp

any The value to increment ControlVariable after each loop.


ForEach

Purpose

A loop statement that executes a number of times equal to the number of specified expressions (meet Loop Statements in Chapter 5: Conditional, Loop, and Calling Statements).

ControlVariable is assigned the first value before the first loop; the second value before the 2nd loop; the 3rd value earlier the third loop; and and so forth. The statement block uses the value of ControlVariable to direct macro execution. EndFor closes a ForEach statement.

The general form of a ForEach statement is:

ForEach (ControlVariable; {ValueList; ...})

...statement block...

EndFor

For example, the following statement repeats 3 times. The variable vTest is initialized to "Apples" before the first loop, to "Oranges" before the 2nd, and to "Bananas" before the third.

ForEach(vTest; {"Apples"; "Oranges"; "Bananas"})

... statement block ...

EndFor

Example

Appendix A: 8003

Syntax

ForEach (<ControlVariable> variable; {<ValueList> whatsoever})

Parameters

<ControlVariable>

variable The control variable.

<ValueList>

whatever Variables, arrays, constants, or expressions, enclosed in braces and separated by a semicolon.


ForNext

Purpose

A loop argument that executes a specified number of times (run across Loop Statements in Affiliate 5: Provisional, Loop, and Calling Statements).

The loop executes if ControlVariable is less than or equal to FinalValue, and executes until ControlVariable is greater than FinalValue. If you use a negative value in IncrementValue, the loop executes until ControlVariable is less than FinalValue. EndFor closes a ForNext statement.

The general form of a ForNext statement is,

ForNext (ForNext (<ControlVariable>; <InitialValue>; <FinalValue>; <IncrementValue>)

...statement block...

EndFor

The following statement initializes vTest to i, repeats the statement block while vTest is less than or equal to 5, and increments vTest by two after each loop.

ForNext(vTest; 1; five; ii)

...statement block...

EndFor

Example

Appendix A: 8001

Syntax

ForNext (<ControlVariable> variable; <InitialValue> any; <FinalValue> any; [<IncrementValue> any])

Parameters

ControlVariable

variable The control variable.

InitialValue

any The value assigned to ControlVariable at the start of a loop.

FinalValue

any A variable, constant, or expression. The loop executes while FinalValue is greater than ControlVariable, or less than ControlVariable if IncrementValue is a negative value.

IncrementValue

any (optional) The value to increase ControlVariable later on each loop. Default is 1.


Fraction

Purpose

Return the fractional portion of a real number.

Example

Appendix A: 8023

Return Value

A fraction.

vFraction := Fraction(1.5)

Result: vFraction equals 0.5

vResult := Fraction(1.77 * ii)

Effect: vResult = 0.54

Syntax

numeric := Fraction (Value: numeric)

Parameters

Value

numeric A existent number.


FractionalPart

Purpose

Return the partial portion of a numeric value.

vFrac := FractionalPart (3.2)

Result: vFrac = 0.2

Return Value

Fractional portion of a numeric value.

Syntax

numeric := FractionalPart (Value: numeric)

Parameters

Value

numeric A fractional number.


FractionStr

Purpose

Return a fraction string representing a value.

vStr := FractionStr (4.5; 0; MixedFraction!)

Event: vStr = "four 1/2"

vStr := FractionStr (4.v; 8; MixedFraction!)

Outcome: vStr = "4 4/8"

Render Value

Fraction string.

Syntax

string := FractionStr (Value: numeric; [Denominator: numeric]; [Option: enumeration])

Parameters

Value

numeric The numerical value to exist converted.

Denominator

numeric (optional) The denominator (the nearest fraction using this denominator is returned). If missing, or less than or equal to zero, the nearest denominator is used.

Pick

enumeration (optional) Specify the fraction class used for values greater than 1. Default: ImproperFraction!

ImproperFraction!

Numerator is larger than the denominator.

MixedFraction!

A whole number, followed past a proper fraction (numerator is smaller than the denominator).


Function

Purpose

Identify a macro subroutine that can receive one or more values from a calling argument (run into Calling Statements in Chapter v: Provisional, Loop, and Calling Statements).  Office likewise returns a value to the calling statement (caller).

Functions contain one or more statements that execute when the function is called. Different Label statements, functions do not execute unless chosen. A calling statement consists of the function�s proper name, and tin have i or more than parameters that pass values to the function. Render, EndFunc, or EndFunction direct macro execution to the statement that follows the function�s caller. Render likewise returns the outcome of a function functioning, or 0 if no consequence is specified. For example,

y := 5

x := Add(y) // calling statement

Function Add(z)

z := z + 5

Return(z)

EndFunc

assigns the value x to variable x. Add is the proper name of the function, and y contains a value to pass. Variable z has no value until the function is called, when the value of z is function argument assigns 10 to variable z. The adjacent statement returns the value of z to the calling statement, which is then assigned to variable x. If the function did not incorporate a Return statement, or if Return did not return a value, x would be equal to 0.

Address Fashion

In the above example, the value of y does not modify. The function returns the value of z in variable ten. To change the value of a variable passed to a office, precede the calling statement parameter and its corresponding function parameter with an ampersand (&). For example,

y := 5

10 := Add together(&y)

Role Add(&z)

z = z + 5

Render(z)

EndFunc

assigns the value 10 to both ten and y. The ampersand before variable x ways the variable�s address (location in memory) is passed to the function, non the variable�s value. Changes made at the address of 10 are made to the contents of 10.

Arrays

You pass arrays to functions the same mode you pass variables. If y'all are passing the entire array, every assortment element must be assigned a value. If not, a run-time mistake identifies a reference to the undefined chemical element. For case,

Declare w[10]

ForNext(x; 1; 9; 1) // assign only 9 elements

w[10] = x

EndFor

Function Examination(z[ ])

ForNext(10; ane; 10; 1)

x[z] = 10 * ten

EndFor

Render(z[ ]) // the value of x elements returned

EndFunc

y[ ] = Exam(w[ ]) // 10 elements returned in array y[ ]

Type(y[x]) // y[10] equals 100

Type(w[10]) // Run-fourth dimension error: Undefined variable "W[x]"

In the previous example, if you precede the calling statement parameter and the corresponding function parameter with an ampersand (&), 100 is returned in w[10]. No run-fourth dimension fault occurs. You are passing the address of assortment westward[ ], non its value. The value is assigned within the function (see Address Mode higher up). The two statements look like this:

Part Test(&z[ ])

and

y[ ] = Examination(&w[ ])

Pass the value of an array element, the same style you laissez passer a variable. For instance,

Declare due west[10]

ForNext(x; 1; 10; one)

w[ten] = 10

EndFor

Function Test(z)

z := z * 10

Return(z)

EndFunc

y = Test(w[i])

Blazon(y + " - ")

Type(w[one])

The value of y equals x. The value of west[1] equals 1. If you lot precede the calling statement parameter and the respective function parameter with an ampersand (&), the value of y equals x and the value of westward[ane] equals ten. Passing the address of westward[1] causes its value to modify inside the function. The two statements look like this:

Function Test(&z)

and

y = Test(&due west[ane])

The general form of a Function statement is:

Function <Proper name> (<Parameter>; <Parameter>; ... <Parameter>)

...statement block...

EndFunc

The syntax accepts EndFunc or EndFunction.

Example

Appendix A: 8024

Syntax

Role <Name> label ({[<Parameter> any]})

Parameters

<Proper noun>

label The name of a role. Information technology begins with a letter and consists of one or more letters or numbers.

{<Parameter>}

any (optional) Receives a value from a calling argument (come across Calling Statements in Affiliate 5: Provisional, Loop, and Calling Statements). If an ampersand precedes the calling argument variable, an ampersand must precede the corresponding function variable (see Address Mode higher up). Multiple variables are separated by a semicolon.


Function Prototype

Purpose

Verify the syntax of a Function statement (see Office).

If the syntax of a part contained in a Use macro file is incorrect and the office is called from the master macro, y'all get a run-time error only not a compile-fourth dimension error (see Compiler Errors in Chapter 3: Creating Macros). Using Part Image at the start of a main macro ensures that you get a compile- time mistake.

Example

Appendix A: 8024

Syntax

Office Prototype <Proper name> characterization ({[<Parameter> any]})

Parameters

<Proper noun>

characterization The proper noun of the role. It begins with a letter and consists of one or more than letters or numbers.

{<Parameter>}

any (optional) Receive a value from a calling statement (see Calling Statements in Chapter v: Conditional, Loop, and Calling Statements). If an ampersand precedes the calling statement variable, an ampersand must precede the corresponding function variable (run across Address Mode nether Part). Multiple variables are separated past a semicolon.

sauciersalmen.blogspot.com

Source: https://personalpages.bradley.edu/~arn/ime117/psmacros/Chapter_11_ef.htm

0 Response to "Endfor Missing Number"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel