Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 75
Using Alternate Keys With a Key-Sequenced File
! Set the compare length to the length of the
! primary key and pad the value with blanks, in case
! the full length was not entered:
COMPARE^LEN := PARTSIZE;
SBUFFER[COUNT^READ] ':=' [PARTSIZE*[" "]];
! Set the positioning mode to approximate:
POSITIONING^MODE := APPROX;
"d", "D" ->
! Prompt for part description:
PRINT^BLANK;
SBUFFER ':=' "Enter Part Description: " -> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Set key specifier to "DE":
KEY^SPEC := "DE";
! Set positioning mode to generic:
POSITIONING^MODE := GENERIC;
! Set the compare length equal to the number of
! bytes entered:
COMPARE^LEN := COUNT^READ;
OTHERWISE ->
PRINT^STR("Invalid key");
RETURN;
END;
! Position to the selected record:
CALL KEYPOSITION(PARTFILE^NUM,SBUFFER,KEY^SPEC,
COMPARE^LEN,POSITIONING^MODE);
IF <> THEN CALL FILE^ERRORS(PARTFILE^NUM);