xHarbour Reference Documentation > Function Reference |
Loads structural information of a database into an array.
DbStruct() --> aStructure
DbStruct() returns a two-dimensional array of four columns, filled with structural information of a database.
The DbStruct() function returns a two-dimensional array with FCount() elements. Each element, again, contains a sub-array with four elements holding information about each field of the database open in the current work area. The elements in the sub-arrays can be accessed using #define constants found in the DBSTRUCT.CH file.
Constants for the DbStruct() array
Constant | Value | Meaning |
---|---|---|
DBS_NAME | 1 | Field name |
DBS_TYPE | 2 | Field type |
DBS_LEN | 3 | Field length |
DBS_DEC | 4 | Field decimals |
See also: | AFields(), COPY STRUCTURE EXTENDED, CREATE FROM, DbCopyStruct(), DbCopyExtStruct(), DbCreate() |
Category: | Database functions |
Header: | DbStruct.ch |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example is the code for a useful command line utility // that lists the database structure in a shell window. #include "DbStruct.ch" PROCEDURE Main( cDbfFile ) LOCAL aStruct IF Empty( cDbfFile ) .OR. .NOT. File( cDbfFile ) CLS ? "Usage: dbstruct.exe <dbf file>" QUIT ENDIF USE (cDbfFile) aStruct := DbStruct() AEval( aStruct, {|a| QOut( PadR( a[DBS_NAME], 10 ), ; a[DBS_TYPE] , ; Str( a[DBS_LEN ], 3 ), ; Str( a[DBS_DEC ], 3 ) ; ) } ) USE RETURN
http://www.xHarbour.com