$Code: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Mlarocca moved page $CODE to $Code: Lower case change)
No edit summary
Line 1: Line 1:
<p>The $CODE function, along with $DECODE, provides an encoding/decoding facility in User Language. $CODE and $DECODE operate on code tables that are defined, created, and controlled by the system manager. These tables can be searched but not changed by User Language functions.        </p>
<p>The $Code function, along with $DECODE, provides an encoding/decoding facility in User Language. $Code and $DECODE operate on code tables that are defined, created, and controlled by the system manager. These tables can be searched but not changed by User Language functions.        </p>
<p>$CODE and $DECODE search tables that are external to a <var class="product">Model&nbsp;204</var> file. These tables are independent of a field's CODED/NON-CODED attribute, which affects how the field is stored internally in the <var class="product">Model&nbsp;204</var> file.  </p>
<p>$Code and $DECODE search tables that are external to a <var class="product">Model&nbsp;204</var> file. These tables are independent of a field's CODED/NON-CODED attribute, which affects how the field is stored internally in the <var class="product">Model&nbsp;204</var> file.  </p>
<p>The $CODE function takes two arguments: </p>
<p>The $Code function takes two arguments: </p>
<ul>
<ul>
<li>The first argument contains the name of the table to be searched. </li>
<li>The first argument contains the name of the table to be searched. </li>
</li>
</li>
<li>$CODE returns the code for the character string value contained in the second argument. A null value is returned if the string is not contained within the table or if the table does not exist. A nonexistent table also causes the nonfatal message:</li>
<li>$Code returns the code for the character string value contained in the second argument. A null value is returned if the string is not contained within the table or if the table does not exist. A nonexistent table also causes the nonfatal message:</li>
<p class="code"><var>INVALID CODE TABLE IDENTIFIER=X</var>.
<p class="code"><var>INVALID CODE TABLE IDENTIFIER=X</var>.
</p></li>
</p></li>
Line 12: Line 12:
<p>This request prompts the user for the full name of a state but performs the record search on the coded value for that state.</p>
<p>This request prompts the user for the full name of a state but performs the record search on the coded value for that state.</p>
<p class="code">BEGIN
<p class="code">BEGIN
       %STCD = $CODE ('STATE', $READ ('ENTER STATE NAME'))
       %STCD = $code ('STATE', $READ ('ENTER STATE NAME'))
GET.RECS: FIND ALL RECORDS FOR WHICH
GET.RECS: FIND ALL RECORDS FOR WHICH
             STATE = %STCD
             STATE = %STCD

Revision as of 13:57, 15 July 2014

The $Code function, along with $DECODE, provides an encoding/decoding facility in User Language. $Code and $DECODE operate on code tables that are defined, created, and controlled by the system manager. These tables can be searched but not changed by User Language functions.

$Code and $DECODE search tables that are external to a Model 204 file. These tables are independent of a field's CODED/NON-CODED attribute, which affects how the field is stored internally in the Model 204 file.

The $Code function takes two arguments:

  • The first argument contains the name of the table to be searched.
  • $Code returns the code for the character string value contained in the second argument. A null value is returned if the string is not contained within the table or if the table does not exist. A nonexistent table also causes the nonfatal message:
  • INVALID CODE TABLE IDENTIFIER=X.

Example

This request prompts the user for the full name of a state but performs the record search on the coded value for that state.

BEGIN %STCD = $code ('STATE', $READ ('ENTER STATE NAME')) GET.RECS: FIND ALL RECORDS FOR WHICH STATE = %STCD END FIND FOR EACH RECORD IN GET.RECS . . .