Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

IEDTGTM - Read a marked record

&pagelevel(4)&pagelevel

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 field EAMFILE (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 field EAMDISP (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
existing record

0

EAMRETOK

EAMOK00

Record with
record number

Smaller than line number
of first marked
record

0

EAMRETOK

EAMOK08

First record with
mark

Larger than line number
of last marked record

0

EAMRETOK

EAMOK12

Last record with
mark

Larger than line number
of first marked
record
and
smaller than line number
of last marked record
and
not a line number of a
marked record

0

EAMRETOK

EAMOK04

Next marked
record after
EDTKEY1

Work file is empty or
contains no marked
records


EAMACERR

EAMAC16


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).

n = +1:

the first marked record after the specified line number is read

n = -1:

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

EDTKEY1 =
XXXXXXXX

+1

Record with mark
exists after EDTKEY1

EAMRETOK

EAMOK00

Next record with
mark after
EDTKEY1

EDTKEY1 =
XXXXXXXX

-1

Record with mark
exists before EDTKEY1

EAMRETOK

EAMOK00

Next record with
mark before
EDTKEY1

EDTKEY1 =
XXXXXXXX

+1

No record with mark after
EDTKEY1

EAMRETOK

EAMOK12

Last marked
record

EDTKEY1 =
XXXXXXXX

-1

No record with mark
before EDTKEY1

EAMRETOK

EAMOK08

First marked
record

Work file is
empty or
contains no
marked records


EAMACERR

EAMAC16


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 and EDTAMCB control blocks.

  • Entry of values in the EDTKEY1 buffer

  • Provision of storage space for the buffers EDTKEY and EDTREC

  • 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     :     IEDTGTM

Parameter list         :     A (EDTGLCB, EDTAMCB, EDTKEY1, EDTKEY,

EDTREC)

Call parameter

Return parameter

EDTGLCB:EGLUNIT
EGLVERS
EGLCCSN
EDTGLCB:EGLRETC
EGLRMSG
EDTAMCB:EAMUNIT
EAMVERS
EAMFLAG
EAMFILE
EAMDISP
EAMLKEY1
EAMPKEY
EAMPREC
EDTAMCB:EAMMARK
EAMLKEY
EAMLREC

EDTKEY1
EDTKEY
EDTREC


EDTKEY
EDTREC


Return parameters on successful record access:

Alongside the EGLRETC field in EDTGLCB (EGLMRET = EAMRETOK), EDT specifies the following parameters:

RecordEDTREC
Record lengthEAMLREC in EDTAMCB
Line numberEDTKEY (always 8 bytes in length)
Length of line numberEAMLKEY in EDTAMCB (always 8 bytes)

Record mark

EAMMARK in EDTAMCB

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);