FATTR() Function - Get Field Attribute Information

For BBj-specific information, see FATTR() Function - BBj.

Syntax

(1)

FATTR(string{,ERR=lineref})

(2)

FATTR(string,""{,ERR=lineref})

FATTR(string,"",""{,ERR=lineref})

(3)

FATTR(string,field_name,attribute_name{,ERR=lineref})

(4)

FATTR(string,field_name{,ERR=lineref})

FATTR(string,field_name,""{,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

    string

    String template

    field_name

    Name of a field contained in the string template.

    user_defined_attribute

    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","")

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)

2

Flag bits

$80$ = variable length field

$40$ = field terminator used

$20$ = padded field

$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. This value represents the "field number" that would be used in an MKEYED file definition if the template were treated as a record descriptor.

8-9

Offset of field since prior variable length field.

10-11

Field length.

12-*

User attributes.

See Also

Functions - Alphabetical Listing