Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 19
Reassigning a Physical File Name to a Logical File
You can also set the physical-block length programmatically using the SET^FILE
ASSIGN^BLOCKLENGTH operation. The following example also sets the block length
to 2048 bytes:
BLOCK^LENGTH := 2048;
CALL SET^FILE(DFILE,
ASSIGN^BLOCKLENGTH,
BLOCK^LENGTH);
If you do not specify a block length, then no blocking is performed.
Reassigning a Physical File Name to a Logical File
You can use an ASSIGN command to reassign a physical file name at run time. To do
this, you must have already associated a logical file name with the FCB as described
earlier in this section under Assigning a Logical File Name.
The following example reassigns the physical file name and sets the physical-block
size:
7> ASSIGN LFILE,DATA1,BLOCK 2048
If you do not reassign a physical file name, then the FCB retains its association with
the file name set up by the ALLOCATE^FCB or ALLOCATE^FCB^D00 DEFINE.
Sample Initialization
The following procedure performs initialization for some SIO files: the input file, the
output file, and an additional disk file.
The names of the input and output files are delivered to the process through the
Startup message. The procedure checks to see whether these names refer to the
same process or terminal file. If so, then the file is assigned read/write access. If the
input and output files are different, then the input file is assigned read-only access and
the output file write-only access.
The access mode of the disk file is not assigned. The user of the program can assign
th
e access mode using an ASSIGN command.
Note. This example is written to execute in both the native and the TNS environments. The
CALL_SET^FILE_ADDRESS_ and CALL_CHECK^FILE_ADDRESS_ DEFINEs are used to
select the appropriate SET^FILE and CHECK^FILE calls, respectively. The same form of the
INITIALIZER call is used for both environments.