ATR
Returns Attribute Value of a Data Element
This string function returns the attribute value of a data element from a format currently in memory.
Syntax
Section titled “Syntax”ATR( name$, elem-number, attr-number [,ERR=line-ref|,ERC=error-code])name$- is a string that specifies the name of a format or data name.
elem-number- is an integer, which represents the data element number in the format whose attributes are to be referenced. The element number must be 0 if a data name is specified.
attr-number- is any integer from 0 through 28, which determines the attribute value to be returned.
line-ref- is the program line number or label to branch to if an error is produced.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”Specifying an elem-number of 0 and an attr-number of 0 retrieves the number of data elements in the format.
The attempt to specify an attr-number other than the positive integers from 0 through 28 results in an ERR=17.
The attempt to reference an invalid format/data name results in an ERR=17.
The attempt to reference a format name that the data dictionary or the current program does not recognize results in an ERR=161.
The attempt to reference a data name, either by name or by element number, that does not exist in the format’s data element table results in an ERR=163.
The attempt to reference a format name without a data element number results in an ERR=17.
The attempt to reference a data name with a data element number results in an ERR=17.
Starting with release 8.2.2, this string function will return the appropriate mask for any data element that has a non-Julian date, phone number, or Social Security number as an attribute.
The following table describes the attribute value retrieved for a given attribute number:
| Attr-number | Attribute value |
|---|---|
| 0 | Data element value |
| 1 | Length |
| 2 | Precision |
| 3 | Numeric type |
| 4 | Field separator |
| 5 | Type input |
| 6 | Pad |
| 7 | Date |
| 8 | Audit |
| 9 | Post-process procedure |
| 10 | Special prompt |
| 11 | Preset value |
| 12 | Valid value |
| 13 | Delete value |
| 14 | Security value |
| 15 | Pre-process procedure |
| 16 | Y/N value |
| 17 | Key indicator |
| 18 | Occurrence value |
| 19 | Documentation code |
| 20 | Position in format |
| 21 | Data element name |
| 22 | Occurrence field spectator |
| 23 | Print length (no comma mask) |
| 24 | Print length (comma mask) |
| 25 | Mask with no commas |
| 26 | Mask with commas |
| 27 | Data description |
| 28 | Language code |
| 29 | Element number of a data name |
Starting with release 8.3.0, specifying a format name and a zero for the element number for the following attribute numbers will return all entries of the specified attribute for the format:
| Attr-number | Attribute value |
|---|---|
| 4 | Field separator |
| 8 | Audit |
| 9 | Post-process procedure |
| 10 | Special prompt |
| 11 | Preset value |
| 12 | Valid value |
| 13 | Delete value |
| 14 | Security value |
| 15 | Pre-process procedure |
| 21 | Data element name |
| 27 | Data description |
Examples
Section titled “Examples”The following examples assume that a format named “DNFFMT” has been successfully INCLUDEd.
LET A$=ATR("#DNFFMT",1,1);retrieves the length attribute of the first data element of the format “DNFFMT”.
LET A$=ATR("#DNFFMT.DATA-ELEMENT-1",0,1);retrieves the length attribute of the data element “DATA-ELEMENT-1” of the format “DNFFMT”.
LET F$="#DNFFMT"LET A$=ATR(F$,0,1);results in an ERR=17 because neither a data name nor an element number were specified.
LET D$="#DNFFMT.DATA-ELEMENT-1";LET A$=ATR(D$,1,5);results in an ERR=17 because a data element’s name, “DATA-ELEMENT-1”, and number, 1, were both referenced.
N = NUM (ATR(F$,0,0))retrieves the number of data elements contained in the format #DNFFMT.
SEP$=ATR("#DNFFMT",0,4)retrieves the field separator elimination table for the format “#DNFFMT”.
NAM$=ATR("#DNFFMT",0,21)retrieves all data element names for the format “#DNFFMT”.
See also
Section titled “See also”FORMAT INCLUDE, FORMAT INIT, FORMAT DEFAULT, and FORMAT DELETE directives
From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF