FATTR() Function - Get Field Attribute Information
For this topic's original documentation, see FATTR()
Function - Get Field Attribute Information.
BBj-Specific Information
Syntax
(1) |
FATTR(template{,ERR=lineref}) |
(2) |
FATTR(template,""{,ERR=lineref}) |
(3) |
FATTR(template,fieldname,attributename{,ERR=lineref}) |
(4) |
FATTR(template,fieldname{,ERR=lineref}) |
Description
The FATTR() function returns information about the specified string template. For additional information on string templates, see the String Template in the User's Reference Guide.
-
The first syntax returns a string template definition.
-
The second syntax returns the names of fields contained in the defined string template. Each field name is delimited with a line-feed character ($0A$), including a line-feed character at the end of the string.
-
The third syntax returns the value of a user-defined attribute of a specified field name in the defined string template.
-
The fourth syntax returns encoded information about a specified field in the defined string template.
Parameter
Description
template
String template
fieldname
Name of a field contained in the string template.
attributename
User-defined attribute to search for in field_name field.
ERR=lineref
Branch to be taken if an error occurs during execution.
Examples
A$ is a templated string and the following is its template definition:
DIM A$:"TYPE:I(1),KEYSIZ:I(1),RECS:I(4),RECSIZ:I(2),NAME:C(64*=)"
Example 1
The following returns a template description string that may be used in a DIM statement:
LET B$=FATTR(A$)
Example 2
The following returns a list of template field names:
LET B$=FATTR(A$,"")
LET B$=FATTR(A$,"","")
Example 3
The following searches the user-defined portion of RECSIZ for the keyword "mask" and returns the value:
DIM A$:"RECSIZ:I(2):access=5 mask=##,##0:"
LET B$=FATTR(A$,"RECSIZ","mask")
Example 4
The following returns template information about the "RECSIZ" field:
LET B$=FATTR(A$,"RECSIZ")
LET B$=FATTR(A$,"RECSIZ","")
LET B$=FATTR(A$,"RECSIZ",0)
See the Field Attribute Format table below for additional information.
Field Attribute Format
The FATTR() function can be used to determine the attributes for each field in a template. The attributes are returned in a string with the following format:
Byte |
Description |
1 |
Field type 1 = char (C) 2 = num (N) 3 = integer (I) 4 = unsigned integer (U) 5 = IEEE floating point (F) 6 = BCD floating point (D) 7 = Business floating point (B) 8 = C float (X) 9 = C double (Y) 10 = ADJN (A) 11= Variable binary (O) |
2 |
Flag bits $80$ = variable length field $40$ = field terminator used $20$ = padded field $10$ = variable length with escaped terminator $04$ = long swapped $02$ = word swapped $01$ = byte swapped |
3 |
Field terminator or pad character (if applicable). |
4-5 |
Dimension of repeating field (or $0001$ if not repeating) |
6-7 |
Field number based on use of linefeed terminators. As long as this field is not a BLOB type, and no BLOB types appear before this field in the record, this value represents the "field number" that would be used in an MKEYED key definition if the template were treated as a record descriptor. |
Original format |
|
8-9 |
Offset of field since prior variable length field. |
10-11 |
Field length. |
12-* |
User attributes. |
Extended format returned with FATTR(template$,fieldname$,1) |
|
8-11 |
Offset of field since prior variable length field. |
12-15 |
Field length. |
16-* |
User attributes. |