HPlogo Using KSAM XL and KSAM 64 > Chapter 5 Reading File Data

Sequential Access by Partial Key Value

MPE documents

Complete PDF
Table of Contents
Index

E0300 Edition 4 ♥
E0394 Edition 3

The FFINDBYKEY intrinsic can be used to point to those records that contain a common portion of a key field. The intrinsic parameters (key value, key length, and relational operator) identify the partial value to be matched, the number of characters to be compared in the key field, and whether the record should equal the value or be greater than the value.

Only the common portion of the key is specified in the key value field. For example, to list all records with a zip code beginning with 943 but ending in any combination of numbers, 943 is entered in the key value field.

The key length parameter identifies the portion of the key field to be used in the comparison. For example, to list all records with a zip code beginning with 943, a key length of 3 would be specified. This means that only the first three characters of the five-character field are used in the comparison.

The relational operator limits the operation to only those records that meet the criteria. The relational operators that can be specified are 0 (equal to), 1 (greater than), and 2 (equal to or greater than). Figure 5-3 "Partial Key Search Sample" searches for the first occurrence of a record containing a partial key of "M0".

Figure 5-3 Partial Key Search Sample

  fby_keyvalue   := 'M0';
  fby_keylocation := 1;
  fby_keylength  := 2;
  fby_relop    := 0;
  .
  .
  .
  FFINDBYKEY(filenum,fby_keyvalue,fby_keylocation,fby_keylength,
    fby_relop);
  .
  .
  .
  lgth := FREAD(filenum,fr_record,fr_tcount);

To read all records containing "M0", a series of freads would be issued and a comparison made in the program to see when the key field did not contain "M0" or the end of the file reached.




Sequential Access by Primary and Alternate Key


Random Access of a Single Record