$Decode

From m204wiki
Revision as of 13:18, 20 April 2013 by Alex (talk | contribs) (Automatically generated page update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The $DECODE function performs a table lookup and returns a decoded character string value. $DECODE is useful for printing descriptive information on reports when the records themselves contain only coded values.

$DECODE conserves space and minimizes the keystrokes required for requests by retaining only codes for fields. $DECODE takes two arguments:

$DECODE('table_name',resolve)

where

  • table_name is the name of a table.
  • resolve contains the code that is to be decoded.

Example

The state field contains a 2-character code. Full state names are printed.

BEGIN STATE: FOR EACH VALUE OF STATE IN ORDER STATE.VAL: FIND ALL RECORDS FOR WHICH STATE = VALUE IN STATE END FIND NO.IN.EACH: COUNT RECORDS IN STATE.VAL SKIP 1 LINE PRINT $DECODE ('STATE', VALUE IN STATE) - WITH COUNT IN NO.IN.EACH AT COLUMN 30 END FOR END