Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modify structure with clipper

Status
Not open for further replies.

SM777

Technical User
Mar 7, 2001
208
GB
is there a clipper function which will modify the structure of a dbf?


Cheers.
 
not that I know of.
we always modify the structure of an empty dbf and append the data back into it.

See if this helps any.

ofile = substr(ofile,1,7)
copy structure extended to temp
select 0
openfile("TEMP", .t.)
addrecord()
replace field_name with "D_1", field_type with "C", field_len with 2, field_dec with 0
addrecord()
replace field_name with "D_2", field_type with "C", field_len with 3, field_dec with 0
select (ofile)
use
select temp
use
create newdap.dbf from temp
if file('TEMP.DBF')
erase temp.dbf
endif
openfile('NEWDAP', .t.)
append from (ofile)
use
store (ofile)+'.DBF' to mdfile
delete file (mdfile)
rename newdap.dbf to (mdfile)
select 0
openfile(ofile,how)

Kris
 
There are two functions you can use to modify a DBF structure in Clipper (5.2e). They are DBSTRUCT and DBCREATE. DBSTRUCT returns an array containing the structure of the active workarea's DBF. You can then make the adjustments you wish to this array and use DBCREATE to create a new DBF with the modified structure. Check the NG files for more information on these functions.
An important note should be considered. The new DBF will be empty and should have a different name from the original. To fill the new DBF, just do an APPEND FROM the old DBF. Just remember that any differences in structure will not be transfered and be left blank in the new DBF.

I hope this helps you. [pc2]
 
Hmm, some of my dbf's have a hundred or so fields. I don't know if the arrays will handle it!

Thanks for the response guys. I'll give it a try.

 
A clipper array can handle up to 4096 elements. Your databases should not cause a problem.
 
Hi.

I wrote a wee program to convert databases from Escudos to Euros which involved reading the structure of said databases and allowing alteration from within the program. It was written in haste and may need some re-coding but if you drop your email I can send you the code.

Regards.
 
I would like to give shadow my menu in MENUMODAL system in Clip 5.3, if any one could give idea or send me same code about it.

many tanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top