__DBCOPYXSTRUCT()
Copy current database structure into a definition file
- Syntax
- __dbCopyXStruct( <cFileName> ) --> lSuccess
- Arguments
- <cFileName> is the name of target definition file to create. (.dbf) is the default extension if none is given.
- Returns
- __dbCopyXStruct() return (.F.) if no database is USED in the current work-area, (.T.) on success, or a run-time error if the file create operation had failed.
- Description
- __dbCopyXStruct() create a new database named with a pre-defined structure (also called "structure extended file"):
Field name | Type | Length | Decimals |
|
FIELD_NAME | C | 10 | 0 |
FIELD_TYPE | C | 1 | 0 |
FIELD_LEN | N | 3 | 0 |
FIELD_DEC | N | 3 | 0 |
- Each record in the new file contains information about one field in the original file. CREATE FROM could be used to create a database from the structure extended file.
- For prehistoric compatibility reasons, Character fields which are longer than 255 characters are treated in a special way by writing part of the length in the FIELD_DEC according to the following formula (this is done internally):
- FIELD->FIELD_DEC := int( nLength / 256 )
- FIELD->FIELD_LEN := ( nLength % 256 )
- Later if you want to calculate the length of a field you can use the following formula:
- nLength := IIF( FIELD->FIELD_TYPE == "C", ;
- FIELD->FIELD_DEC * 256 + FIELD->FIELD_LEN, ;
- FIELD->FIELD_LEN )
- COPY STRUCTURE EXTENDED command is preprocessed into __dbCopyXStruct() function during compile time.
- Examples
- // Open a database, then copy its structure to a new file,
- // Open the new file and list all its records
- USE Test
- __dbCopyXStruct( "TestStru" )
- USE TestStru
- LIST
- Status
Ready
- Compliance
- __dbCopyXStruct() works exactly like CA-Clipper's __dbCopyXStruct()
- Platforms
- All
- Files
- Library is rdd
- See Also