Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding Fields To Tables
Message
 
To
29/10/2002 01:29:48
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00716324
Message ID:
00716327
Views:
11
In addition to the other replies, you can write a program, go through a list of DBFs (if this is your case) and do something like ** Be sure to back up **
set safety off
FOR i = 1 to alen(adir())
use (ADIR(i)) exclusive        && open file for exclusive use
copy to tmp structure extended && Create a DBF structure file
copy all to dbfBack            && Copy the data to a backuo
use                            && Close cuurent dbf being modified
erase (ADIR(i))                && I think this works
use tmp exclusive              && open the structure dbf
append blank                   && Add a record for field description
repl field_name with "NewField",field_type with "C",field_len with 30 && etc
create (ADIR(i)) from tmp      && Created a header with new field with original name
use (ADIR(i)) exclusive        && open empty file with new field
append from dbfBack            && Add the data - new field is empty
use                            && CLose
ENDFOR
BE SURE TO TEST THIS ON ONE FILE FIRST - I DIDN'T :)


>I have about 100 copies of an app I need to add new fields to some tables in each app.
>
>Can I add a new field, specifying its name, type etc to a table via some code without having to go into the table structure and doing it manually on each table?
>
>Thank you!
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform