I have a form that a user defines a sructure for a table. These values are stored in a list and I wish to use these values and create a table, then import the data file they have chosen.
I assume you mean "how do you create a table programmatically". For that, look up the "Create table - sql" command and simply use &variablename for each field name.
Let's say field1 is an integer in table1 (so you have table1.field1).
You would put this in your .prg:
field1=table1.field1
field1type=table.fieldtype
You could also do a for/next with N being equal to the number of records in your field descriptions table and create a string of fields separated by commas in order to allow for unlimited/unknown field counts.
append blank
REPLACE field1 with "Sammy Sample"
REPLACE field2 with 534.34
REPLACE field3 with .T.
REPLACE field4 with "HELLO WOLRD from Sammy Sample"
REPLACE field5 with DATE()
BROWSE
Where "myTableinfo" is an array as defined in AFIELDS() - see your version of FoxPro for the details. The size of the row is version dependent.
I just thought of something else from way back when.
Do this from the command prompt.
use anytable
copy structure extended to newtable
Take a look at the fields it creates.
Your work table that your users are adding info to should mirror these field layouts (not the data -- the structure "field_name", "Field_type", etc.).
After you add a record to this table, you've really added a complete field description. You put the field name like "Lastname" in the field_name field, etc.
Now, simply issue a CREATE FROM newtable....
command and it will create a new table with the structure you need. These are old commands I haven't used in a long time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.