Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

GETR - Get record "reverse"

Macro type:

R for PARMOD=24
O for PARMOD=31

The GETR macro reads the next record of the file in the direction of the beginning of the file, i.e. the file is read in reverse.

If a record outside the file is requested, the user is given control via EOFADDR (see the EXLST macro, EOFADDR operand, "EXLST - Define exit address list").

The program can switch from GET to GETR and vice versa at any time, without the file having first to be positioned to beginning-of-file or end-of-file.

If a GET macro which returned a record with the primary or secondary key value Kn is followed by a GETR macro referring likewise to the primary key or the same secondary key, respectively, then this GETR call returns the record with the next lower primary or secondary key value Kn-1 (Kn-1 < Kn).

If the file contains records with duplicate primary key values, GETR returns the records on the “last in, first out” (LIFO) principle, i.e. the first record to be returned from a group of records which have the same key is the most recent record written to the file.

If a file is read with the aid of a secondary key and if it contains records with identical values for this secondary key, then GETR returns the records in the reverse order to that in which the secondary key values were created.

If the GETR macro is preceded by a SETL KEY macro, the record to which the file was positioned via SETL KEY is returned.

Format

Operation

Operands

GETKY

fcbadr / (1)
  [,area / (0)]
  [,LOCK / NOLOCK]

[,AIX = NO /
        YES,KEYNAME = name /
        YES,KEYNMAD = adr]

[,PARMOD = 24 / 31]

Operand descriptions

fcbaddr

Address of the FCB associated with the file to be processed. If the file is to be read with the aid of a secondary key, the 31-bit interface of this FCB must be available.

(1)
The FCB address is stored in register 1.

area

Address of the area to which the record is to be transferred. This operand is ignored in locate mode.

(0)
The address of the area to which the record is to be transferred is stored in register 0.

LOCK

The block or record lock is to remain active after the macro has been executed (explicit lock).

NOLOCK
No explicit lock is set.

AIX

Specifies whether the record is to located via its primary key or via a secondary key.

= NO
The record is located via its primary key (default value).

= YES
This may be specified only if

      • the 31-bit interface of the macro is generated (via the operand PARMOD=31 or the macro GPARMOD 31) and

      • the macro refers to a 31-bit FCB.

The record is located via the secondary key specified in the operand KEYNAME or KEYNMAD.

KEYNAME = name

Specifies the name of the secondary key via which the record is to be located.
“name” must be the name of a secondary key defined for the current file. The names of all secondary keys defined for a file can be determined by means of the SHOWAIX macro or the SHOW-INDEX-ATTRIBUTES command.

KEYNMAD = addr

Specifies the symbolic address (the name) of a field in which the user has stored the name of the secondary key via which the record is to be located.
When the macro is executed, the field with the symbolic address “addr” must contain the name of a secondary key defined for the current file.

PARMOD

Specifies the generation mode for the macro.

Default value:

the value predefined for the generation mode by means of the GPARMOD macro or preset by the assembler.

= 24
The object code generated can run only in the 16-Mb address space
(24-bit addressing only).

= 31
The object code generated can run in the 2-Gb address space
(24-bit or 31-bit addressing).

Programming note

The GETR macro overwrites the contents of registers 0, 1, 14 and 15.