FILE [ HP Transact Documentation Update Notice ] MPE/iX 5.5 Documentation
HP Transact Documentation Update Notice
FILE
Reads, writes, updates, sorts, and otherwise operates on MPE files.
Syntax
FILE(modifier) file-name[,option-list];
FILE specifies operations on any MPE file defined in the SYSTEM
statement. The operations that FILE performs are determined by the
following verb modifiers:
CLOSE Closes the specified file. (See Syntax Option 1.)
CONTROL Performs an FCONTROL operation. (See Syntax Option
2.)
OPEN Opens specified file. (See Syntax Option 3.)
READ Reads record from specified file. (See Syntax
Option 4.)
SORT Sorts specified file. (See Syntax Option 5.)
UPDATE Replaces current record in specified file. (See
Syntax Option 6.)
WRITE Writes record to specified file. (See Syntax
Option 7.)
Several of the above FILE operations can be performed by other Transact
verbs.
For: FILE(CLOSE) Use: CLOSE
FILE(READ) GET or FIND
FILE(UPDATE) UPDATE
FILE(WRITE) PUT
The Transact verbs in the right column are more general; they apply to
data sets and KSAM files as well as to MPE files. They also provide more
options, but they are not as efficient as the FILE verb for simple MPE
file operations.
Statement Parts
modifier For the meaning of particular modifiers, see the
syntax options below.
file-name The name of the file as defined in the SYSTEM
statement, including the back reference indicator
(*) if applicable. A file is opened automatically
the first time it is referenced.
option-list The allowed options for option-list are unique to
each syntax option.
Syntax Options
(1) FILE(CLOSE) file-name;
FILE(CLOSE) closes the file identified by file-name. If $PRINT is
specified as the file name, the print file TRANLIST is closed.
(2) FILE(CONTROL) file-name,CODE=number[,PARM=item-name[(subscript)]];
FILE(CONTROL) specifies that the FCONTROL operation designated by
CODE=number is to be performed. The value of number must be an unsigned
integer (See the FCONTROL intrinsic description in the MPE Intrinsics
Manual for the meaning of number.) Any value supplied or returned by the
FILE(CONTROL) operation uses the data register field identified by
PARM=item-name. The item-name may be subscripted if an array item
is being referenced. (See "Array Subscripting" in Chapter 3.)
FILE(CONTROL) is the only statement that performs the FCONTROL functions
on an MPE file.
To set a time-out interval for a DATA, INPUT, or PROMPT verb, use CODE=4
and let item-name equal the number of seconds of the time-out interval.
In this case, file-name is the name of a dummy file defined in the SYSTEM
STATEMENT. At run time, you should set up a file equation, FILE file-name
= $STDLIST, using the dummy file specified in your program.
The FILE(CONTROL) statement only applies to the next access to the
terminal, so it should appear immediately before the data entry statement
to which it applies. (See the example at the end of this subsection.)
(3)FILE(OPEN) file-name,LIST=(item-name1:item-name2);
FILE(OPEN) opens the file identified by file-name. It is required only
with the FILE(SORT) operation. It structures the list register with
item-name1 through item-name2 for the subsequent sort. This operation is
required only if the file already exists and it is to be sorted by the
system.
FILE(OPEN) is the only statement that opens an MPE file.
(4) FILE(READ) file-name,LIST=(item-name1:item-name2);
FILE(READ) reads a single record from the file identified by file-name
and moves the record contents to the portion of the data register
corresponding to item-name1 through item-name2 in the list register. At
the completion of the operation, the status register contains either the
number of characters read or -1 to indicate end-of-file.
(5) FILE(SORT) file-name {,SORT=(item-name1:item-name2)
};
{,SORT=(item-name1[(ASC)][,item-name2[(ASC)]]...)};
[(DES)] [(DES)]
FILE(SORT) executes the HP 3000 SORT utility to sort an existing file.
The sort instruction can consist of (1) a range of items in the order
that they are to be sorted (ascending order only), or (2) a list of items
or sub items in the order that they are to be sorted and a specification
of ascending (default) or descending order.
Provided that the access mode of SORT is defined for the file, an
end-of-file is automatically written into the file before the sort, and
the file is rewound following the sort. The temporary sort file is
purged upon exit of the Transact program.
MPE files can also be sorted with the FIND statement, but FILE(SORT) is
more efficient.
(6) FILE(UPDATE) file-name,LIST=(item-name1:item-name2);
FILE(UPDATE) replaces the current record in the file identified by
file-name. The record contents are defined by item-name1 through
item-name2 in the list register.
(7) FILE(WRITE) file-name,LIST=(item-name1:item-name2);
FILE(WRITE) writes a single record to the file identified by file-name.
The record contents are defined by item-name1 through item-name2 in the
list register. At the completion of the operation, the status register
contains 0 if the operation was successful or an undefined value if the
operation was not successful.
Examples
The FILE(CONTROL) statement causes FCONTROL operation 7 to be performed;
that is, it spaces the tape forward to the tape mark. The value it
returns is placed in the data register field specified by LNUM. (See the
MPE Intrinsics Manual for more information regarding FCONTROL.)
SYSTEM TEST,
BASE=INVTRY,
FILE=TAPE(WRITE(NEW),80,1,5000),...;
.
.
FILE(CONTROL) TAPE,
CODE=7,
PARM=LNUM;
This example maps the data register for a subsequent FILE(SORT).
ITEM A X(10):
B X(20):
C X(15);
:
FILE(OPEN) DATAFILE,
LIST=(A:C);
This example is a complete program that can be used to familiarize
yourself with setting a time-out interval before a data entry statement.
Note that there are two loops, one nested in the other, with time-out
applied only to the second PROMPT statement. The following file equate
must be set at run time for the following program:
:FILE TERM=$STDLIST
SYSTEM TIMEO, FILE=TERM;
DEFINE(ITEM) TIME-OUT I(4):
NUMBER I(4);
LEVEL;
PROMPT TIME-OUT;
LEVEL;
FILE(CONTROL) TERM,CODE=4,PARM=TIME-OUT;
PROMPT NUMBER;
IF STATUS = -4 THEN DISPLAY "TIME OUT!";
MPE/iX 5.5 Documentation