Click or drag to resize

DbStruct Function (Usual)

X#
Create an array containing the structure of a database file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION DbStruct(
	uArea AS USUAL
) AS ARRAY
Request Example View Source

Parameters

uArea
Type: Usual
Specifies the work area name or number for a table from which the value must be retrieved.

Return Value

Type: Array
The structure of the database file in an array whose length is equal to the number of fields in the database file.
Each element of the array is a subarray containing information for one field.
The subarrays have the following format: Constant Attribute DBS_NAME cName DBS_TYPE cType DBS_LEN nLength DBS_DEC nDecimals DBS_ALIAS cAlias If there is no database file in use in the work area, DBStruct() will generate a runtime error.
Remarks
DBStruct() operates like COPY STRUCTURE EXTENDED by creating an array of structure information rather than a database file of structure information.
There is another function, DBCreate(), that can create a database file from the structure array. By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying it within an aliased expression
Examples
This example opens two database files, then creates an array containing the database structure using DBStruct() within an aliased expression.
The field attributes are then listed using AEval():
X#
1LOCAL aStruct
2USE customer NEW
3USE invoices NEW
4aStruct := Customer->DBStruct()
5AEval(aStruct, {|aField|QOut(aField[DBS_NAME]),;
6QOut(aField[DBS_TYPE]), QOut(aField[DBS_LEN]),;
7QOut(aField[DBS_DEC]), QOut(aField[DBS_ALIAS])})
See Also