Harbour Reference Guide

 

__dbStructFilter()

Filter a database structure array

Syntax

__dbStructFilter( <aStruct>, [<aFieldList>] ) --> aStructFiltered

Arguments

<aStruct> is a multidimensional array with database fields structure, which is usually the output from DBSTRUCT(), where each array element has the following structure:

PositionDescriptiondbstruct.ch
1cFieldNameDBS_NAME
2cFieldTypeDBS_TYPE
3nFieldLengthDBS_LEN
4nDecimalsDBS_DEC

<aFieldList> is an array where each element is a field name. Names could be specified as uppercase or lowercase.

Returns

__dbStructFilter() return a new multidimensional array where each element is in the same structure as the original <aStruct>, but the array is built according to the list of fields in <aFieldList>. If <aFieldList> is empty, __dbStructFilter() return reference to the original <aStruct> array.

Description

__dbStructFilter() can be use to create a sub-set of a database structure, based on a given field list.

Note that field names in <aStruct> MUST be specified in uppercase or else no match would be found.

SET EXACT has no effect on the return value.
Examples
      LOCAL aStruct, aList, aRet
      aStruct := { { "CODE",  "N",  4, 0 }, ;
                   { "NAME",  "C", 10, 0 }, ;
                   { "PHONE", "C", 13, 0 }, ;
                   { "IQ",    "N",  3, 0 } }
      aList := { "IQ", "NAME" }
      aRet := __dbStructFilter( aStruct, aList )
                        // { { "IQ", "N", 3, 0 }, { "NAME", "C", 10, 0 } }

      aRet := __dbStructFilter( aStruct, {} )
      ? aRet == aStruct // .T.

      aList := { "iq", "NOTEXIST" }
      aRet := __dbStructFilter( aStruct, aList )
                        // { { "IQ", "N", 3, 0 } }

      aList := { "NOTEXIST" }
      aRet := __dbStructFilter( aStruct, aList )   // {}


      // Create a new file that contain part of the original structure
      LOCAL aStruct, aList, aRet
      USE TEST
      aStruct := DBSTRUCT()
      aList := { "NAME" }
      DBCREATE( "OnlyName.DBF", __dbStructFilter( aStruct, aList ) )
Status

Ready

Compliance

__dbStructFilter() is a Harbour extension. CA-Clipper has an internal undocumented function named __FLEDIT() that does exactly the same thing. The new name gives a better description of what this function does.

Platforms

All

Files

Header file is dbstruct.ch Library is rdd

See Also

 




[Source Forge]

Other Docs Categories

Advantage Database RDD
Array
Binary conversion
Classes
Code Block
Console input
Conversion
Conversion Tools
DOS
Data input and output
Database
Database Tools
Date
Dos Tools
Environment
Error recovery
Events
File management
GT
Harbour Tools
Internal
Low Level
Math
Misc
Miscellaneous
Nation
Object manipulation
Operating System Specific
Parameter Checks
String Tools
Strings
TBrowse Method
TBrowse class
Terminal
Time
Utility
Variable Management

 

Last updated on 2001/06/26