Xbasic

A5_FIELD_INFO Function

Syntax

Field_Info as P = a5_field_info(C tablename ,C fieldname )

Arguments

Field_Info

A dot variable with these elements.

Element

Description

.decimals

The number of character positions allowed for decimals.

.longtype

The field type as it appears in the Restructure Table dialog box.

.name

The name of the field.

.decimals

The number of character positions allowed for decimals.

.shorttype

a single character code for the field type.

.width

The width of the field in characters.

tablename

The name of the table containing the field.

fieldname

The name of the field you are interested in.

Description

Returns info about a field in a table.

Discussion

The function A5_FIELD_INFO() returns information about a field in a table. The table does not have to be open.

Example

? a5_field_info("customer", "lastname")
= decimals = 0.000000
Longtype = "Character"
name = "lastname"
Shorttype = "C"
width = 20.000000

Note : There are several ways to get info about a field. If the table is open then you can get a pointer to a field and use the <FIELD>.TYPE_GET()and <FIELD>.WIDTH_GET()methods of the field object.

t = table.open("customer")
f = t.field_get("firstname")
? f.type_get()
= "C"
? f.width_get()
= 20.000000
t.close()

If the table is closed, you can also use the TABLE.EXTERNAL_FIELD_NAME_GET()method to return a CR-LF delimited string of info about ALL of the fields in the table. The advantage of A5_FIELD_INFO() is that it works on a table that does not have to be open, and you do not have to extract the info from a long string that is returned by the TABLE.EXTERNAL_FIELD_NAME_GET() method.

See Also