This access function makes it possible to search for a marked record starting at a specific line number (EDTKEY1
).
The direction of the search can also be specified.
It is only possible to search for marked records. It is not possible to search for a specific mark.
Searches can be performed in the work files 0..22
. No marked records can be read in a work file in which a file has been opened for real processing by means of @OPEN (format 2). The access attempt is rejected with a return code.
Searching for a marked record
In order to search for a marked record it is necessary to specify the following:
Work file (
$0..$22
) in the fieldEAMFILE
(EDTAMCB
):
Work file in which the marked record is to be read.Line number of a file record in the buffer
EDTKEY1
(the record does not have to exist).Displacement
n (0,+1,-1)
in the fieldEAMDISP
(EDTAMCB
):
Specification of the search direction (other positive values for displacement are handled like+1
, and other negative values are handled like-1
)Character set in which the record is to be made available, in the field
EGLCCSN
(EDTGLCB
)
Two types of search are possible:
Search for a specific line number
Search for the next marked record relative to a specified line number
Reading a marked record with a specific line number
Displacement specification: n = 0
If the value 0 is specified for the displacement (EAMDISP
) then the record with the specified line number (EDTKEY1
) is read. If this record is not present or if the record has no marks then the next marked record (possibly the first or last record) is read and transferred.
Summary of the return codes and the read record:
EDTKEY1 | EAMDISP | EGLMRET | EAMSR1 | EDTREC |
Line number of an |
|
|
| Record with |
Smaller than line number |
|
|
| First record with |
Larger than line number |
|
|
| Last record with |
Larger than line number |
|
|
| Next marked |
Work file is empty or |
|
|
If the search is successful, EDT passes the line number of the record that was actually read in EDTKEY
together with the record mark in EAMMARK
(EDTAMCB
).
For the meaning of the return codes, see section “EDTGLCB - Global EDT control block”.
Reading the next marked record
Displacement specification n = +1
or -1
The next marked record before or after a specific line number is searched for (EDTKEY1
).
| the first marked record after the specified line number is read |
| the first marked record before the specified line number is read |
If no further marked records are present in the specified direction then the first or last marked record is read and transferred.
Summary of the return codes and the read record:
EDTKEY1 | EAMDISP | EGLMRET | EAMSR1 | EDTREC |
|
Record with mark |
|
| Next record with |
|
Record with mark |
|
| Next record with |
|
No record with mark after |
|
| Last marked |
|
No record with mark |
|
| First marked |
Work file is |
|
|
If the search is successful, EDT passes the line number of the record that was actually read in EDTKEY
together with the record mark in EAMMARK
(EDTAMCB
).
For the meaning of the return codes, see section “EDTGLCB - Global EDT control block”.
Call
The following specifications are required (see overview):
Entry of values in the required fields in the
EDTGLCB
andEDTAMCB
control blocks.Entry of values in the
EDTKEY1
bufferProvision of storage space for the buffers
EDTKEY
andEDTREC
Call of the entry point address
IEDTGTM
with the parameter list
Overview
(For the control blocks, see section “EDTGLCB - Global EDT control block”).
Entry point address |
Parameter list
|
Call parameter | Return parameter | ||
EDTGLCB: | EGLUNIT EGLVERS EGLCCSN | EDTGLCB: | EGLRETC EGLRMSG |
EDTAMCB: | EAMUNIT EAMVERS EAMFLAG EAMFILE EAMDISP EAMLKEY1 EAMPKEY EAMPREC | EDTAMCB: | EAMMARK EAMLKEY EAMLREC |
|
|
Return parameters on successful record access:
Alongside the EGLRETC
field in EDTGLCB
(EGLMRET
= EAMRETOK
), EDT specifies the following parameters:
Record | EDTREC |
Record length | EAMLREC in EDTAMCB |
Line number | EDTKEY (always 8 bytes in length) |
Length of line number | EAMLKEY in EDTAMCB (always 8 bytes) |
Record mark |
|
If the buffer length (EAMPREC)
is not sufficient to accommodate the record, EAMACERR
is entered for EGLMRET
and EAMAC12
is entered for EGLSR1
. The record is truncated. The actual length read is entered in the EAMLREC
field in AMCB
. In compatibility mode (as in EDT V16.6B), the buffer length required to read the record in full is stored here.
In Unicode mode, however, it is necessary to specify the number of bytes actually transferred since multi-byte coding always requires the record to be truncated between two valid characters and, consequently, fewer bytes may be transferred than are specified in EAMPREC.
Call in the C program
Required include files:
#include <stdio.h>
#include <iedtgle.h>
The control block EDTAMCB
is declared and initialized as follows (the value 4096
here was selected as an example of the maximum expected record length):
iedamcb amcb = IEDAMCB_INIT; char key1[8]; char key[8]; char rec[4096]; ambc.length_key1 = 8; amcb.length_key_outbuff = 8; amcb.length_rec_outbuff = 4096;
The specifications for the other parameters are user-dependent. If, for example, the
next marked record after the record with line number 123.4 in work file 22 is searched for:
strncpy(amcb.filename,"$22 ",8); strncpy(key1,"01234000",8); amcb.displacement = 1;
In the C program, the IEDTGTM
function is called as follows:
IEDTGTM(&glcb,&amcb,key1,key,rec);