xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DbStruct()

Loads structural information of a database into an array.

Syntax

DbStruct() --> aStructure

Return

DbStruct() returns a two-dimensional array of four columns, filled with structural information of a database.

Description

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
ConstantValueMeaning
DBS_NAME1Field name
DBS_TYPE2Field type
DBS_LEN3Field length
DBS_DEC4Field decimals

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe