GCOBOL-START(3c) GCC COBOL GCOBOL-START(3c)
NAME
START — position file for reading
SYNOPSIS
START
filename
FIRST
LAST
KEY
IS
compare
operator
name
WITH
LENGTH
expr
INVALID
KEY
error-statements
NOT
INVALID
KEY
valid-statements
END-START
DESCRIPTION
START sets the position within filename where the next sequential READ will read a record by applying compare operator (see below) to a key for the file. filename is an FD entry in DATA DIVISION.
When none of FIRST, LAST, or KEY, is specified, START defaults to KEY EQUAL with the primary key of filename as the key. If KEY is used, name specifies the name of a key field or named key for filename . Alternatively, name may specify a field whose leftmost character is at the beginning of a key for filename .
FIRST and LAST are valid for files whose ORGANIZATION is RELATIVE, or INDEXED. For SEQUENTIAL files, one of FIRST or LAST is required. FIRST positions the file at the first record according the file’s key (or, for SEQUENTIAL, at the first physical record); LAST similarly positions the file at the last record. If the file is empty, FIRST and LAST produce an error condition, with FILE-STATUS set according the file’s organization.
LENGTH is valid only for a file with INDEXED organization. The whole key is used unless LENGTH is used, in which case expr is an arithmetic expression resulting in an integer value constituting the size of the key.
In its conditional form, START may include either or both of INVALID KEY and NOT INVALID KEY. error-statements and valid-statements are blocks of statements. If no record exists matching the KEY criteria, error-statements are executed. If a matching record is found, valid-statements are executed.
END-START marks the end of the START statement. It can be required when START appears in a conditional statement.
compare operator:
IS
NOT
EQUAL
TO
<
<=
=
>=
>
LESS
THAN
OR EQUAL
TO
GREATER
THAN
OR EQUAL
TO
Linux June 2023 Linux