How to Modify a Table's Structure Programmatically in FoxProLast reviewed: August 22, 1995Article ID: Q135320 |
The information in this article applies to:
SUMMARYThis article shows by example how to change the structure of a data table programmatically.
MORE INFORMATIONModifying the structure of a pre-existing data table in FoxPro is not possible in the run-time environment because the Modify Structure command is not supported. To modify a table structure, you must:
Sample CodeFollowing is sample code that creates a table programmatically and copies its structure to an array. It then changes the length of one of the fields, and creates a table from the edited array. * Create Table myTable CREATE TABLE myTable; (firstname C(20),; lastname C(20),; city C(20))INSERT INTO myTable VALUES("Eric","Cardenas","Sydney") LIST STRUCTURE LIST COPY TO myTemp * Store structure into an array =AFIELDS(arrTable) Change length of first_name to 30 arrTable[1,3] = 30 setSAFETY = SET("SAFETY") SET SAFETY OFF CREATE TABLE myTable; FROM ARRAY arrTableAPPEND FROM myTemp LIST STRUCTURE LIST SET SAFETY &setSAFETY
Using the COPY STRUCTURE EXTENDED CommandIf you want to add or delete a field, it may be useful to us the COPY STRUCTURE EXTENDED command, and then work with the structure .DBF file. The COPY STRUCTURE EXTENDED command makes a table that has four fields: Field_name, Field_type, Field_len, and Field_dec. Each record of the table corresponds to a field in the original table.
Step-by-Step Example
|
Additional reference words: FoxWin 2.60a structure modifying
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |