GETRFA

Retrieve the current position in a file

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
xcall GETRFA(channel, rfa[, krf])

Arguments

channel

The number of the open channel. (n)

rfa

The variable that will be loaded with the file position (or RFA). (a6)

krf

(optional) The variable that will be loaded with the key of reference of the last READ or FIND on an ISAM file. (n)

Discussion

Tip

GETRFA is available only for consistency with DBL version 4. We suggest you use the GETRFA qualifier on I/O statements such as READ, FIND, and so forth, instead of using the GETRFA subroutine.

The GETRFA subroutine retrieves the position of the last record accessed in a file. All read and write operations update this position. For example, after a STORE, the GETRFA subroutine retrieves the RFA of the stored record, not the last record read. You can also retrieve the RFA of the record just stored using the GETRFA qualifier on the STORE statement.

Important

See the Important note in Error trapping for information about inconsistencies that may occur after an I/O error is encountered.

The return value (stored in rfa) is stored in binary form to be used as an argument to the POSRFA subroutine. The data type of this binary value must not change before POSRFA uses it.

Important

The contents of rfa are a special binary value and must be preserved. Be careful in doing assignments or moving the contents into another variable.

If an RFA refers to a deleted record, a “Deleted record” error ($ERR_DELREC) will be generated when a read is attempted.

See also

Examples

The following subroutine creates a temporary tag file to sort data from an ISAM file that is in a nonkey field. It reads through the file searching for records with a nonblank entry in the nonkey field. It then creates a temporary tag file and saves the RFA position of the ISAM file and the nonblank field. It sorts the temporary file using the nonblank field as the sort key, then extracts the appropriate records from the ISAM file in sorted order to pass to a print subroutine.

subroutine report
.define ISMCHN          ,10
.define TAGCHN          ,11
.define TAGFILE         ,"tagfile"
record ism_rec
    key                 ,a10
    ism_fld             ,a5
record tag_rec
    tag_rfa             ,a6
    tag_sort            ,a5
proc
    open(ISMCHN, i:i, "isam")
    open(TAGCHN, o, TAGFILE)
    repeat
      begin
        reads(ISMCHN, ism_rec, done1)
        if (ism_fld)                            ;If nonblank...
          begin
            xcall getrfa(ISMCHN, tag_rfa)
            tag_sort = ism_fld
            puts(TAGCHN, tag_rec)               ;Save RFA in tag file
          end
      end
done1,
    close TAGCHN
    sort(input=TAGFILE, key=tag_sort, record=tag_rec, 
  &      options="recsize=11/e")                ;Note that the /e “exact” switch
    open(TAGCHN, i, TAGFILE)                    ; is necessary since the RFA is
    repeat                                      ; a binary value
      begin
        gets(TAGCHN, tag_rec, done2)
        read(ISMCHN, ism_rec, RFA:tag_rfa)
        xcall print_it(ism_rec)
      end
done2,
    close TAGCHN
    close ISMCHN
    return
endsubroutine