Accessing Field-level Data in a Specific Record

To access field level data in a specific record, the recordset indexing capability must be used to select a single record. The SORT function and recordset filters are useful in selecting and ordering the recordset so that the appropriate record can be selected.


TrdRec := RECORD
  INTEGER4 Trd_bal;
  INTEGER4 Trd_hc;
PersonRec := RECORD
  STRING20 FirstName;
  STRING20 LastName;
  DATASET(TrdRec) Trd;
Person := DATASET([{'Fred','Jones',[{1,2,3},{2,4,5}]},
Trades := Person.Trd;
ValidMoney(n) := n > 0;
ValidBalTrades := trades(ValidMoney(trades.trd_bal));
HighestBals := SORT(ValidBalTrades,-trades.trd_bal);
Highest_HC := EVALUATE(HighestBals[1],trades.trd_hc);
    //return trd_hc field of the trade with the highest balance
    // could also be coded as (using indexing):
    // Highest_HC := HighestBals[1].trades.trd_hc;

    //output that Highest_HC for each person
    //This output operates at the scope of the Person record
    // EVALUATE is needed to get the value from a Trades record
    // because Trades is a Child of Person

See Also: SORT