The command computes a checksum for the contents of a file.
Return Value
The checksum is computed on the file contents, and returned.
Parameters
Filename:
filename The file to compute the checksum on. This file is opened as a binary file, and a cumulative checksum is computed on every byte of data in the file.
Options:
enumeration The checksum type to compute. Different types of checksums return checksums that are less prone to error than others. If missing, CheckSum32! Is used.
CheckSum16! Compute a 16 bit checksum. This is the 16 bit checksum used internally by the PerfectFit shared code. The checksum in the loword of the return value.
CheckSum32! Compute a 32 bit checksum. This is the 32 bit checksum used interally by the PerfectFit shared code.
CRC_16! Compute a 16 bit checksum based on the CRC 16 polynomial. The checksum in the loword of the return value.
CCITT! Compute a 32 bit checksum based on the CCITT polynomial.
AUTODIN_II! Compute a checksum based on the AUTODIN_II polynomial.
Seed: numeric A checksum from a previous piece of data that is used as a starting point for the checksum. This allows long streams of data to be computed, by passing the checksum from the previous piece of data into the Seed parameter of a subsequent piece. On the first piece of data, ommit this parameter, or specify as a 0. If missing, an initial seed is used that depends on the value of the Options parameter above.
enumeration or numeric := FileConvert
Syntax
(SourceFilename: string; [SourceFileType: enumeration]; DestinationFilename: string; DestinationFileType: enumeration or numeric)
Description
Converts a file of one type to a file of another type. The available file types depends on the converters installed by the user. Not all conversions are available on all systems.
A file can be converted only to a similar file type (documents to documents, graphics to graphics, and so on).
Return Value
The common return values indicate the status of the command. Any value not equal to Success! is an error. Other error values are returned as numeric values. Enumeration values have been defined for many of the common error values. The same enumerations are returned from the command as the enumerations returned from the FileConvertError() command. See the return value for that command for the return enumeration types for this command.
DocumentCorrupt! Document appears to be corrupted.
EntriesNotConverted! Several entities were not convertible.
FileLocked! The file is locked.
FileNotSpreadsheet! The file is not a spreadsheet.
IgnoringDetectedType! Detected file format is set to be ignored.
InAndOutSame! Input and output filenames were the same (they must be different).
Incompatible! Destination file type is incompatible with the source file type.
IncorrectSourceFormat! Input file is not format specified.
InvalidDestination! Invalid destination filename.
InvalidDestinationName! Invalid drive/path on output filename.
InvalidDestinationSpec! Invalid drive/path on output filespec.
InvalidSource! Invalid source filename.
InvalidSourceData! Invalid data found in input file.
InvalidSourceName! Invalid drive/path on input filename.
InvalidSourceSpec! Invalid drive/path on input filespec.
NoConvertibleData! No convertible data was received.
NoDriver! Conversion driver not available for requested conversion. It may need to be installed.
NoFileDescriptors! No available file descriptors.
NoGraphicConverter! No graphics converter to call.
OutOfFileMemory! Out of file memory
OutOfMemory! Out of memory
Success! Successful conversion.
ThirdPartyError! Unknown error in Third Party Conversion
UnknownGraphic! Graphics file type cannot be converted.
UnknownType! File type unknown.
UnknownTypeDetected! Unknown file format detected.
UnknownTypeSpecified! Unknown file format entered.
UnsupportedFormat! Unsupported file format detected.
Parameters
SourceFilename: string Name of file to convert.
SourceFileType: enumeration (optional) Type of source file to convert. If missing, AutoDetect! is used. Many of the file types returned by 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!
WordPerfect6789! This the same as the obsolete enumeration WordPerfect678!
WordPerfect6x!
WordPerfect7!
WordPerfect8!
WP6xText! This file contains WordPerfect word character text data only. This is not a WordPerfect documnet, but just the text data from a WordPerfect document in word characters.
WordPerfectCompound!
WPMac31!
WordStar70!
MSWord55!
Word60!
Word97!
RichTextFormat!
AsciiText!
AsciiDelimited!
AsciiCRLFtoSRT!
AnsiText
AnsiDelimited!
AnsiCRLFtoSRT!
AmiPro30!
WindowsWrite!
WPG1!
WPG2!
TIFF!
WMF!
BMP!
GIF!
JPG!
CorelDRAW7!
CorelDRAW8!
CorelDRAW9!
Excel70!
Excel97!
Lotus123v4!
AdobePhotoshop!
CorelDRAWClipart!
CorelPHOTOPaint7!
KodacPhotoCD!
PCPaintBrush!
QuattroPro6!
QuattroPro7!
QuattroPro78!
QuattroPro8!
SDIF!
UnicodeText!
DestinationFilename: string Name of the output file.
DestinationFileType: enumeration or numeric Type of file to convert 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!
CorelPHOTOPaint7!
Lotus123v4!
PCPaintBrush!
PresentationsShow!
SDIF!
UnicodeText!
WordPerfect9!
WordPerfect50!
WordPerfect51!
WordPerfect6789! This is the same as the obsolete enumeration WordPerfect678!
WP6xText! The file contains WordPerfect word character text data only. This is not a WordPerfect document, only text data from a WordPerfect document in word characters.
WordPerfectCompound!
WordStar70!
MSWord55!
Word60!
Word97!
RichTextFormat!
AsciiText!
AsciiDelimited!
AsciiGenericWP!
AnsiText
AnsiDelimited!
AnsiGenericWP!
AmiPro30!
WindowsWrite!
WPG1!
WPG2!
TIFF!
WMF!
BMP!
GIF!
JPG!
string := FileConvertError
Syntax
(ErrorCode: enumeration or numeric)
Description
Returns the name of a file conversion error.
Return Value
A value indicating the status of the command. Printable name of the error returned by the FileConvert command. If the return value is not equal to Success!, an error occurred. Enumeration values have been defined for many of the common error values.
Parameters
ErrorCode: enumeration or numeric Error code for which to return a name, returned by the FileType command. The more common values follow. Specify other error values as numeric values.
InAndOutSame! Input and output filenames were the same (they must be different).
NoDriver! Conversion driver not available for requested conversion. It may need to be installed.
UnknownType! File type unknown.
UnknownGraphic! Graphic file type cannot be converted.
InvalidSource! Invalid source filename.
InvalidDestination! Invalid destination filename.
Incompatible! Destination file type is incompatible with the source file type.
Success! Success
UnknownTypeSpecified! Unknown file format entered
UnknownTypeDetected! Unknown file format detected
InvalidSourceSpec! Invalid drive/path on input filespec
InvalidSourceName! Invalid drive/path on input filename
InvalidDestinationSpec! Invalid drive/path on output filespec
InvalidDestinationName! Invalid drive/path on output filename
UsupportedFormat! Unsupported file format detected
DetectDriverMissing! Detection driver unavailable
ThirdPartyError! Unknown error in ThirdParty Conversion
OutOfMemory! Out of memory
OutOfFileMemory! Out of memory
IncorrectSourceFormat! Input file is not format specified
FileLocked! The file is locked
DiskFull! Out of disk space
NoFileDescriptors! No available file descriptors
NoGraphicConverter! No graphics converter to call
DocumentCorrupt! Document appears to be corrupted
IgnoringDetectedType! Detected file format is set to be ignored
FileNotSpreadsheet! File is not a spreadsheet
EntriesNotConverted! Several Entities were not convertable
NoConvertableData! No convertible data was received
InvalidSourceData! Invalid data found in input file
numeric := FileError
Example
Description
Return the error associated with the last file command.
Return Value
Returns the error type; The entire return value may be compared to the following enumerations:
Success!
UnknownError!
Error!
The following enumerations may be returned in the loword of the return value:
Find a file that matches user-defined search criteria (filename and DOS attributes).
Return Value
Success! File found
CancelConditionAsserted! Cancel condition was asserted
ErrorConditionAsserted! Error condition was asserted
NotFoundConditionAsserted! Not Found condition was asserted
UserDefinedCondition! This value defines the base value for assertions of user-defined conditions. See the Assert command for more information about the value of user-defined condition codes.
Parameters
Filename: string (optional) Include the full path. If missing, the next matching file is found (see Context below).
Directory! In addition to files, directories are also returned. This does not return directories only.
Archive!
SkipDotDirs! When the attributes include Directory!, "." and ".." directories are skipped and not returned.
SearchSubDirs! Search sub-directories for files that match the specified attributes.
MatchAnyAttribute! Files are returned that have at least one of the specified attributes. The files may include attributes other than the specified attributes.
MinimumAttributes! Files are returned that have all the specified attributes. The files may include attributes other than the specified attributes.
ExactAttributes! Files are returned that have all the specified attributes. The files may not include other attributes.
Context: numeric (optional) A user-defined number which identifies the search. Default: 0. To find the next file to match the search criteria, change the context to 1. For example,
finds the first occurrence of a file with a WPD extension. The following statement finds the next file to match the same search criteria:
vFilename = FileFind (Filename: ""; Context: 1)
Use different Context values to perform multiple searches simultaneously. If you perform more than one search before the macro ends, you can continue any search by using the appropriate Context value. The subsequent search begins where it left off.
boolean := FileFlushData
Syntax
(FileID: numeric)
Description
When a file is written to by the FileWrite command, the operating system will sometimes buffer the data and not actually write it to the disk until later. This command flushed the buffered data to the disk, forcing it to be written to the disk.
Return Value
True if the command was successful. If not, False. If could return False if the FileID parameter does not specify an open file, or if the file is not open for write.
Parameters
FileID: numeric The ID of the file to flush the data for. This value is returned fro the FileOpen command.
filename := FileGetLongName
Syntax
([Filename: filename])
Description
This command returns the full long name of a filename.
Return Value
The long filename for a short filename containing the short 8.3 DOS name format.
Parameters
Filename:
filename The short 8.3 filename form of the file.
filename := FileGetShortName
Syntax
([Filename: filename])
Description
This command returns the short 8.3 DOS form of a filename.
Return Value
The short filename for a long filename containing the long name format.
Parameters
Filename:
filename The long filename form of the file.
boolean := FileIsEOF
Example
Syntax
(FileID: numeric)
Description
Return True if the insertion point is at the end of a file, False if not.
Display the Open or Save As dialog. The parent of this dialog is maintained by the macro and is initially set to the application that started the macro. The dialog may be attached to a different application or window by setting a new default parent with the SetDefaultParent command.
Return Value
The name(s) of the file(s) to open or save, or "" if Cancel is pressed.
Parameters
StyleOptions: enumeration (optional) Specifies the type of dialog to open and the options associated with the dialog. Type | between enumerations to combine styles. For example: OpenDialog! | FileMustExist!. If missing, OpenDialog! and PerfectFitDialog! are used.
OpenDialog! Display the Open dialog.
SaveAsDialog! Display the Save As dialog.
DirectoryDialog! The displayed dialog is a directory selection dialog, not a file selection dialog. If FileMustExist! is also specified, the directory must already exist.
WindowsDialog! The displayed dialog is the Windows common dialog.
EnhancedDialog! The displayed dialog is the Corel PerfectFit Enhanced custom dialog. The EnhancedDialog! Enumeration replaces the PerfectFitDialog! Enumeration.
FileMustExist! Use with OpenDialog!. The file selected for Open must exist.
MultipleFiles! Allow the selection of multiple files or directories. The return value is a list of files or directories, separated by a string (see Separator parameter below).
PromptOnReplace! Use with SaveAsDialog!. If the file already exists, a prompt is displayed asking whether the file should be replaced.
CaptionText: string (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 folder is displayed.
InitialFileName: string (optional) Initial filename to display. If missing or "", FileTemplate is displayed.
FileTemplate: string (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 can contain up to fifteen filenames. If missing, no history is given. Include the full Registry path where the recent file list is maintained.
Separator: string (optional) String that separates multiple files or directories. If missing, ";" is used.
Parent:
string
(optional) Used for setting the parent of the dialog: The parameter is the region name or window handle of the window that is the parent of the file name dialog. If missing, the default parent is determined by the macro system based on the application that started the macro, and if a new default parent has been specified by the SetDefaultParent command.
Return the current marker position or set a new position.
A user can pre-allocate file size by setting the position marker past the end-of-file marker.
Return Value
The position of the old position marker, or a negative number if an error occurs.
Parameters
FileID: numeric See 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!
numeric := FileRead
Example
Syntax
(FileID: numeric; Data: variable)
Description
Read text data from an open file.
Return Value
The number of bytes read, or a negative number if an error occurs.
Parameters
FileID: numeric See OpenFile.
Data: variable Starting from the position marker, one line of data is converted to a WP character string and returned in this variable.
numeric := FileSize
Example
Syntax
(Filename: string)
Description
Return a file's size in bytes.
Return Value
The file size in bytes, or a negative number if an error occurs.
Parameters
Filename: string Include the full path.
numeric := FileTruncate
Example
Syntax
(FileID: numeric)
Description
Remove all text data after the position marker (see FilePosition).
Return Value
The truncated file size (bytes) if successful, or a negative number if an error occurs.
Parameters
FileID: numeric See OpenFile.
enumeration or numeric := FileType
Syntax
(Filename: string)
Description
Return a file's type; If there is an error in determining file type, several special enumerations are returned to indicate the error.
Success! (This value is never returned, but maybe used as a check to determine if an error has occurred. All error enumerations are less than this value.)
OpenReadError! (An error occurred opening or reading the file)
OutOfMemory! (An out of memory condition occurred)
PasswordProtected! (The specified file is password protected)
Return Value
Detected file type (get errors from the FileError command). The more common 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 type is unknown.)
AdobePhotoshop!
CorelDRAW8!
CorelPHOTOPaint7!
KodakPhotoCD!
Paradox!
PCPaintBrush!
PresentationsMaster!
PresentationsMaster3!
QuattroPro6!
QuattroPro78!
UnicodeText!
XML!
Zip!
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!
CorelDRAW9!
Excel70!
Excel97!
Lotus123v4!
PresentationsShow!
PresentationsShow3!
SDIF!
Parameters
Filename: string Name of file to detect.
string := FileTypeExtension
Syntax
(Filetype: enumeration or numeric)
Description
Return the default filename extension of a file type returned by the FileType command.
Return Value
The default filename extension of FileType (usually two or three characters). If FileType does not have an extension, or if you specify an invalid file type, an empty string is returned.
Parameters
Filetype: Enumeration or numeric Type of file for which to return the default filename extension. This value is returned by the FileType command. The following list contains some of the possible values for FileType. Types not listed can be specified as numeric values.
WordPerfect42!
WordPerfect50!
WordPerfect51!
WordPerfect6789!
WordPerfectCompound!
WPMac31!
COJava!
WordStar70!
MSWord55!
Word60!
Word97!
RichTextFormat!
AsciiText!
AnsiText!
AmiPro30!
WindowsWrite!
HTML!
SGML!
WPG1!
WPG2!
TIFF!
WMF!
BMP!
GIF!
JPG!
CorelDRAW7!
CorelDRAW9!
Excel70!
Excel97!
Lotus123v4!
SDIF!
PresentationsShow3!!
XML!
Zip!
array := FileTypeList
Syntax
(FileType: enumeration)
Description
Return an array (list) of detected file types.
Return Value
An array of file type enumerations (the same types returned by the FileType command). Associated names are obtained by passing the file types to the FileTypeName command.
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.
CorelDRAW9!
Notes
In previous versions of PerfectScript, when there was no data to be returned, a single element array with either a numeric value of 0 or a string value of "" was returned. Now, when there is no data to be returned, an empty array is returned.
The Destination! enumeration and the Source! enumeration can not be used together.
string := FileTypeName
Syntax
(FileType: enumeration or numeric)
Description
Returns the name of a file type.
Return Value
Printable name of the file type returned by the FileType command. If the specified file type is not recognized, an empty string ("") is returned.
Parameters
FileType: enumeration or numeric Type of file for which to return a printable name. This value is returned by the FileType command. The following list contains some of the possible values for FileType. Types not listed can be specified as numeric values.
The number of bytes written, or a negative number if an error occurs.
Parameters
FileID: numeric See OpenFile.
Data: string Text data is converted to the type specified when the file is opened. A caret (^) followed by a number is replaced by the corresponding character string in the ParameterData parameter. To write a caret, use two carets (^^).
FlushData! Force the data to be flushed to the disk after this operation.
ParameterData: string (optional) The text data inserted in the data string (see Data parameter). Up to 10 strings separated by semicolons are allowed. Numbering begins with 0. For example,
FileWrite (FileID; Data: "My friend ^0 is ^1 years old."; NewLine: NewLine!; ParameterData: {"Dan"; "41"})
writes "My friend Dan is 41 years old." followed by an end-of-line marker.
enumeration := FileWriteLine
Syntax
([FileID: numeric]; [Options: enumeration])
Description
This command will write a blank line to the file specified by the FileID. This is the same as calling FileWrite with an empty string and specifying NewLine! To the NewLine parameter.
Return Value
The number of bytes of data written to the file. An enumeration may also be returned. Error! is returned if there was an error writing a blank line to the file.
Parameters
FileID:
numeric The ID of the file to write an empty line to. This value is returned from the FileOpen command.
Options: enumeration Options controlling additional actions performed by this command. If missing, BufferData! Is used.
BufferData! Allow the operating system to buffer the data.
FlushData! Force the data to be flushed to the disk after this operation.
numeric := Floor
Syntax
(Value: numeric)
Description
Return the largest integer that is less than or equal to a specified value (the floor of a number).
A control statement (loop) that executes a specified number of times.
The loop executes only if TerminateExp is true, and continues to execute until ControlVariable's value makes TerminateExp false. 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 statement block while vTest is less than ten, and increments vTest by two after each loop.
For(vTest; 1; vTest < 10; vTest + 2)
...statement block...
EndFor
Parameters
ControlVariable: variable The control variable.
InitialValue: any The value assigned to ControlVariable at the start of a loop.
TerminateExp: boolean The loop executes while TerminateExp is true.
IncrementExp: any The value to increment ControlVariable after each loop.
ForEach
Example
Syntax
(<ControlVariable> variable; {<ValueList> any})
Description
A loop statement that executes a number of times equal to the number of specified expressions.
ControlVariable is assigned the first value before the first loop; the second value before the second loop; the third value before the third loop; 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 three times. The variable vTest is initialized to "Apples" before the first loop, to "Oranges" before the second, and to "Bananas" before the third.
ForEach(vTest; {"Apples"; "Oranges"; "Bananas"})
... statement block ...
EndFor
Parameters
<ControlVariable> variable The control variable.
<ValueList> any Variables, arrays, constants, or expressions, enclosed in braces and separated by a semicolon.
A loop statement that executes a specified number of times.
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 following statement initializes vTest to one, repeats the statement block while vTest is less than or equal to five, and increments vTest by two after each loop.
ForNext(vTest; 1; 5; 2)
...statement block...
EndFor
Example
In this example, IncrementValue equals -1 and counts backward:
ForNext(x;16; 1)
Prompt(x) Wait(3)
EndFor
In this example, IncrementValue equals 1 and counts forward:
ForNext(x; 1; 16)
Prompt(x) Wait(3)
EndFor
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 increment ControlVariable after each loop. If you do not specify another value, this value will be either 1 or -1, based on the calculation.
Value: numeric The numerical value to be 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.
Option: enumeration (optional) Specify the fraction form used for values greater than 1. Default: ImproperFraction!
ImproperFraction! Numerator is larger than the denominator.
MixedFraction! A whole number, followed by a proper fraction (numerator is smaller than the denominator).
numeric := FractionalPart
Syntax
(Value: numeric)
Description
Return the fractional portion of a numeric value.
Example
vFrac := FractionalPart (3.2)
Result: vFrac = 0.2
Return Value
Fractional portion of a numeric value.
Parameters
Value: numeric A fractional number.
Function <Name> label
Syntax
({[<Parameter> any]})
Description
Identify a macro subroutine that can receive one or more values from a calling statement. Function also returns a value to the calling statement (caller).
Functions contain one or more statements that execute when the function is called. Unlike Label statements, functions do not execute unless called. A calling statement consists of the function's name, and can have one or more parameters that pass values to the function. Return, EndFunc, or EndFunction direct macro execution to the statement that follows the function's caller. Return also returns the result of a function operation, or 0 if no result is specified. For example,
y := 5
x := Add(y) // calling statement
Function Add(z)
z := z + 5
Return(z)
EndFunc
assigns the value 10 to variable x. Add is the 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 5 (the value of variable y). The first function statement assigns 10 to variable z. The next statement returns the value of z to the calling statement, which is then assigned to variable x. If the function did not contain a Return statement, or if Return did not return a value, x would be equal to 0.
Address Mode
In the above example, the value of y does not change. The function returns the value of z in variable x. To change the value of a variable passed to a function, precede the calling statement parameter and its corresponding function parameter with an ampersand (&). For example,
y := 5
x := Add(&y)
Function Add(&z)
z = z + 5
Return(z)
EndFunc
assigns the value 10 to both x and y. The ampersand before variable x means the variable's address (location in memory) is passed to the function, not the variable's value. Changes made at the address of x are made to the contents of x.
Arrays
You pass arrays to functions the same way you pass variables. If you are passing the entire array, every array element must be assigned a value. If not, a run-time error identifies a reference to the undefined element. For example,
Declare w[10]
ForNext(x; 1; 9; 1) // assign only 9 elements
w[x] = x
EndFor
Function Test(z[ ])
ForNext(x; 1; 10; 1)
x[z] = x * 10
EndFor
Return(z[ ]) // the value of 10 elements returned
EndFunc
y[ ] = Test(w[ ]) // 10 elements returned in array y[ ]
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-time error occurs. You are passing the address of array w[ ], not its value. The value is assigned inside the function (see Address Mode above). The two statements look like this:
Function Test(&z[ ])
and
y[ ] = Test(&w[ ])
Pass the value of an array element, the same way you pass a variable. For example,
Declare w[10]
ForNext(x; 1; 10; 1)
w[x] = x
EndFor
Function Test(z)
z := z * 10
Return(z)
EndFunc
y = Test(w[1])
Type(y + " - ")
Type(w[1])
The value of y equals 10. The value of w[1] equals 1. If you precede the calling statement parameter and the corresponding function parameter with an ampersand (&), the value of y equals 10 and the value of w[1] equals 10. Passing the address of w[1] causes its value to change inside the function. The two statements look like this:
Function Test(&z)
and
y = Test(&w[1])
The general form of a Function statement is:
Function <Name> (<Parameter>; <Parameter>; ... <Parameter>)
...statement block...
EndFunc
The Syntax accepts EndFunc or EndFunction.
Parameters
<Name> label The name of a function. It begins with a letter and consists of one or more letters or numbers.
{<Parameter> } any (optional) Receives a value from a calling statement. If an ampersand precedes the calling statement variable, an ampersand must precede the corresponding function variable (see Address Mode above). Multiple variables are separated by a semicolon.
Function Prototype <Name> label
Example
Syntax
({[<Parameter> any]})
Description
Verify the syntax of a Function statement (see Function).
If the syntax of a function contained in a Use macro file is incorrect and the function is called from the main macro, you get a run-time error but not a compile-time error. Using Function Prototype at the start of a main macro ensures that you get a compile-time error.
Parameters
<Name> label The name of the function. It begins with a letter and consists of one or more letters or numbers.
{<Parameter> } any (optional) Receive a value from a calling statement. If an ampersand precedes the calling statement variable, an ampersand must precede the corresponding function variable (see Address Mode under Function). Multiple variables are separated by a semicolon.