File Functions
The following functions and properties can be used for text files.
Function/Property | Description | ||
ACCESSEDDATE |
Returns the date when the file has been last accessed (readonly). The returned value is a numeric with the length 8 in the date format "yyyymmdd". |
||
Use: |
|||
to place (for instance) the returned ACCESSEDDATE value in the specified variable: <Variable> := <File id>.ACCESSEDDATE |
|||
ACCESSEDTIME |
Returns the time when the file has been last accessed (readonly). The returned value is a numeric with the length 6 in the date format "hhmmss". |
||
Use: |
|||
to place (for instance) the returned ACCESSEDTIME value in the specified variable: <Variable> := <File id>.ACCESSEDTIME |
|||
ADDREC |
Adds a record to an index or relative io file. It is not allowed to use the same <File id> both for this function and for a READFILE and/or WRITEFILE instruction at the same time. |
||
Use: |
|||
<File id>.ADDREC (<Record layout>) |
|||
APPEND |
Normally in a transaction the first call to the WRITEFILE command will overwrite an existing file with the same filename. If this first call is preceded by a call to <File id>.Append() this first call to WRITEFILE will append the record to an existing file. If no file exists beforehand the file will be created normally. |
||
Use: |
|||
<File id>.APPEND ([Exclusive]) |
|||
EXCLUSIVE | Keep the file open Since the file will not be opened and closed perpetually when it is accessed, this statement improves the performance. Though, using this option also means that the concerned file cannot be used for other processes at the same time. |
||
CLOSE |
Closes the file. It is recommended to use this option for closing a file before calling it inside the logic. The reason why you should do this is that that file might be in use (by another object/ end user/ ...), which would cause sharing conflicts. |
||
Use: |
|||
<File id>.CLOSE (<Option>) |
|||
<Option> = <Space> | SAVE | DELETE | RENAME, <New file> | LOCK |
|||
<Space> |
Save the file. |
||
SAVE |
Save the file. |
||
DELETE |
Delete the file. |
||
RENAME |
When closing the file, it will be stored as <New file>. |
||
<New file> |
New name to be assigned to the file. |
||
LOCK |
Locks the file until the program has finished, and also flushes this file to disk (so that if there might be a crash the data won't be lost). If the report crashes, and this report also contains a SAVERECOVERY, the file will be unlocked automatically. |
||
CONTAINSCOMP |
Forces the sort routine to treat the file as computational (reading a fixed number of bytes). |
||
Use: |
|||
<File id>.CONTAINSCOMP () |
|||
COPYFILE |
Copies the file contents to the <Destination>. |
||
Use: |
|||
<Fileid>.COPYFILE (<Destination>) |
|||
<Destination> |
Expression that contains the path for the file to which the copy of the file that is specified
through the <File id> must be assigned. |
||
CREATE |
Creates an empty file. If there is already a file with the same file name, then that file will be deleted. |
||
Use: |
|||
<File id>.CREATE ([EXCLUSIVE]|[TEMP]) [RESULTOKTO <Result>] |
|||
EXCLUSIVE |
Keep the file open. |
||
TEMP |
Create a temporary file. A temporary file will be created with the filename set to the filename of the <FileId> used to wich a unique number has been added. The file will be created Exclusive and remain open for changing. When closed with <FileId>.Close() the temporary file will be deleted. When close with <FileId>.Close(SAVE) the file will be saved using the original filename of <FileId> overwriting any existing file with that name. |
||
RESULTOKTO <Result> |
Stores the ResOk result in the variable <Result>. |
||
CREATEDDATE |
Returns the date when the file has been created(readonly). The returned value is a numeric with the length 8 in the date format "yyyymmdd". |
||
Use: |
|||
to place (for instance) the returned CREATEDDATE value in the specified variable: <Variable> := <File id>.CREATEDDATE |
|||
CREATEDTIME |
Returns the time when the file has been created (readonly). The returned value is a numeric with the length 6 in the date format "hhmmss". |
||
Use: |
|||
to place (for instance) the returned CREATEDTIME value in the specified variable: <Variable> := <File id>.CREATEDTIME |
|||
CURRENTRECNO |
Stores the current record number. |
||
Use: |
|||
To move the last record that is read from the file to a <Variable>: |
|||
DELETEFILE |
Deletes the file. |
||
Use: |
|||
<Fileid>.DELETEFILE () |
|||
DELETEREC |
Removes the current record from an indexed or relative IO file. The record will not be removed physically, but it will be set to SI-HIGHVALUE (ASCII 255). For a search through an index there will not be any results returned. It is not allowed to use the same <File id> both for this function and for a READFILE and/or WRITEFILE instruction at the same time. |
||
Use: |
|||
<File id>.LOCATE (<Index>, <Operator>, <Value>) | <File
id>.LOCATE (POSITION, <Record no>) |
|||
EOF |
Returns a boolean value that indicates whether the end of the file is reached (TRUE) or not (FALSE). The value changes from "FALSE" to "TRUE" when an attempt is made to read behind the last record in the file. |
||
Use: |
|||
<File id>.EOF |
|||
EXISTS |
Returns a boolean value that indicates whether the file exists (TRUE) or not (FALSE). |
||
Use: |
|||
<File id>.EXISTS |
|||
FILENAME |
Returns the current filename as a String value.. |
||
Use: |
|||
<File id>.FILENAME |
|||
GETFILECONTENT |
Returns the total file content as a Realstring value as is. No conversion of any kind is perfomed on the content. |
||
Use: |
|||
to place (for instance) the returned file content into the variable that is specified as <Destination>: <Destination> := <Fileid>.GETFILECONTENT |
|||
GETFILESIZE |
Returns the size of the file as an integer. When the file is not found -1 will be returned. |
||
Use: |
|||
to place (for instance) the returned file size into the variable that is specified as <Destination>: <Destination> := <File id>.GETFILESIZE |
|||
ISLOCKED |
Returns "TRUE" if the file is currently locked or "FALSE" if the file is not locked. |
||
Use: |
|||
<File id>.ISLOCKED |
|||
ISOPEN |
Returns a boolean value that indicates whether the file is currently opened (TRUE) or closed (FALSE). |
||
Use: |
|||
<File id>.ISOPEN |
|||
LOCATE |
Searches for a record in the file. It will also set the system item RESOK ("TRUE" if the record was found). The record will not be placed into a buffer, but there will be an update of the property .CURRENTRECNO. It is not allowed to use the same <File id> both for this function and for a READFILE and/or
WRITEFILE instruction at the same time. Note: Older migrated code used a different syntax than described below which only allowed a single key, this older syntax required the operator to be entered in single quotes as a string literal. <File id>.LOCATE(<Index>, <Operator>, <Value>) |
||
Use: |
|||
for indexed files: |
|||
<File id>.LOCATE (<Index>, <Operator> <Value>[, <Operator> <Value>[, ... ]]) |
|||
<Index> |
The name that is specified as identifier for the index. |
||
<Operator> |
One of the characters "<", "<=", "=", ">" or ">=" to be entered without quotes. |
||
<Value> |
The value to search for in the file |
||
Examples: | Fid.LOCATE(Index_firstname, = 'Joanneke') Fid.LOCATE(Index_customer, = 'Joanneke', = 'de Vrijer') |
||
for relative files: |
|||
<File id>.LOCATE (POSITION, <Record no>) |
|||
<Record no> |
The record number. The record number for the first record is "1". |
||
LOCKREC | Locks an individual record within a file. | ||
Use: | |||
<File id>.LOCKREC (<Record no>) | |||
<Record no> |
The record number to lock. The first record in the file is number "1". | ||
MODIFIEDDATE |
Returns the date when the file has been modified (readonly). The returned value is a numeric with the length 8 in the date format "yyyymmdd". |
||
Use: |
|||
to place (for instance) the returned MODIFIEDDATE value in the specified variable: <Variable> := <File id>.MODIFIEDDATE |
|||
MODIFIEDTIME |
Returns the time when the file has been modified (readonly). The returned value is a numeric with the length 6 in the date format "hhmmss". |
||
Use: |
|||
to place (for instance) the returned MODIFIEDTIME value in the specified variable: <Variable> := <File id>.MODIFIEDTIME |
|||
MOVEFILE |
Moves the file to the <Destination>. In difference with the COPYFILE function, the file that is
specified in the <File id> will not be retained in its original location. |
||
Use: |
|||
<File id>.MOVEFILE (<Destination>) |
|||
<Destination> |
Expression that contains the new path for the <File id> file. |
||
OPEN |
Opens the specified file for reading. |
||
Use: |
|||
<File id>.OPEN ( [NOWAIT] [,] [EXCLUSIVE] ) |
|||
NOWAIT |
Continue when the file is not present. |
||
EXCLUSIVE |
Keep the file open. |
||
READ |
Reads 1 line in the file and queues that line in a <Layout>. If there is no index specified, the records are read in the order in which they were entered. It is not allowed to use the same <File id> both for this function and for a READFILE and/or WRITEFILE instruction at the same time. |
||
Use: |
|||
To read in the order in which the records are entered: <File id>.LOCATE (<Index>, <Operator> <Value>) | <File
id>.LOCATE (POSITION, <Record no>)
File_rel.create ()
File_cust.open () loop File_cust.read (Rec_customer) if not File_cust.eof File_rel.addrec (Rec_customer) else File_rel.close () File_cust.close () break endif endloop |
|||
READMODE |
With readmode the reading behaviour of the READFILE command can be changed.
|
||
Use: | |||
<File id>.READMODE := <0|1|2> |
|||
Example: | File_cust.readmode := 1 | ||
SETFILECONTENT |
Writes the content value to the file. If the file already exists then it will be replaced. |
||
Use: |
|||
<File id>.SETFILECONTENT (<Content>) |
|||
<Content> |
Expression (Realstring) that represents the content that must be written to the file. |
||
STOREREC | This commands perfoms a normal UpdateRec () command except when the filepointer is at the end of the file. In that case it will perform the AddRec () command and add e new record to the end of the file. | ||
Use: | |||
<File id>.STOREREC (<File record>) | |||
<File record> |
The record to store in the file . | ||
UNLOCKREC | Unlocks a previous locked record in a file. | ||
Use: | |||
<File id>.UNLOCKREC (<Record no>) | |||
<Record no> |
The record number of the previously locked record to unlock. | ||
UPDATEREC |
Updates the current record in an indexed or relative IO file. It is not allowed to use the same <File id> both for this function and for a READFILE and/or WRITEFILE instruction at the same time. |
||
Use: |
|||
<File id>.UPDATEREC (<File record>) |
|||
<File record> |
The record to write in the file |