Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 17
Setting Up File Access
Specifying the Logical-Record Length
Use the ASSIGN REC command to specify the logical-record length at run time. The
record-size parameter specifies the length. The following example specifies a
logical-record length of 256 bytes:
3> ASSIGN INPUT^FILE,,REC 256
Use the SET^FILE ASSIGN^RECORDLENGTH operation to programmatically set the
logical-record length. You set the new-value parameter to the number of bytes. The
following example sets a logical-record length of 256 bytes:
RECORD^LENGTH := 256;
CALL SET^FILE(INFILE,
ASSIGN^RECORDLENGTH,
RECORD^LENGTH);
If you do not specify the record length, the system provides a default value of 132
bytes for all file types except disk files. The default record length for a disk file is set
when you create the file.
Section 5, Communicating With Disk Files, discusses file records in detail.
Specifying the File Code
You can assign an application-dependent file code to a file. Setting the file code
affects the subsequent OPEN^FILE call as follows:
If the file already exists, the specified file code must match the code of the existing
file or the open will fail.
If the file does not already exist and the OPEN^FILE procedure is called with the
AUTO^CREATE flag set, then a file is created with the specified file code.
Codes in the range 100 through 999 are reserved.
Set the file code at run time using the ASSIGN CODE command. The file-code
parameter specifies the file code. The following example sets the file code to 101, the
code for an EDIT file:
4> ASSIGN LFILE,, CODE 101
Set the file code programmatically using the SET^FILE ASSIGN^FILECODE operation.
The following example also assigns code 101 to a file:
LITERAL EDIT^FILE = 101;
.
.
CALL SET^FILE(DFILE,
ASSIGN^FILECODE,
EDIT^FILE);
If you do not specify a file code, the system assigns a file code to the file. The
SIO-assigned file code is 101 if you have supplied a block buffer of at least 1024 bytes;
it is 0 otherwise.