[comp.databases] Clarification to Simple File Transfers

ajauch@bonnie.ics.uci.edu (Alexander Edwin Jauch) (12/02/89)

This is a carification to my previous posting about moving an ASCII download
file into Dbase III plus.

I would like to know how to change the structure of a database from *within*
a running program.  I guess I wasn't clear about this, because I got one letter
advising me to use the modify structure command.  I believe this command puts
you into the full screen editor mode (that's what happens on my machine).
Can you use this command to allow the *program* to change the structure of a
database?  I don't think so, but what do I know!  That is the problem, how to
allow a program to alter the structure of a database.

If this is not possible, please refer to my previous question for a complete
discription of my problem to see if you see some workaround.

Thanks For Your Help
Alex Jauch
UCI, AIS
ajauch@bonnie.ics.uci.edu

michael@ddsw1.MCS.COM (Michael Duebner) (12/03/89)

In article <25771FA1.20234@paris.ics.uci.edu> ajauch@bonnie.ics.uci.edu (Alexander Edwin Jauch) writes:
>This is a carification to my previous posting about moving an ASCII download
>file into Dbase III plus.
>
>I would like to know how to change the structure of a database from *within*
>a running program.  I guess I wasn't clear about this, because I got one letter
>advising me to use the modify structure command.  I believe this command puts
>you into the full screen editor mode (that's what happens on my machine).
>Can you use this command to allow the *program* to change the structure of a
>database?  I don't think so, but what do I know!  That is the problem, how to
>allow a program to alter the structure of a database.
>
>If this is not possible, please refer to my previous question for a complete
>discription of my problem to see if you see some workaround.
>
>Thanks For Your Help
>Alex Jauch
>UCI, AIS
>ajauch@bonnie.ics.uci.edu

Yes, this also can be completed, albeit its not quite that simple as using a
full screen editor to modify the database structure.

There are 2 basic steps to moving your data, under program control, to a new
structure.

a)	You have to define the new database (.dbf) which is to include all
of those fields that will be necessary as part of the new application.  You
may include completely new fields but do not have to include all of the old
fields from the source database file.

b)	Create a routine to copy the records from the source to the new
database (see example).

-------------------Sample Code-------------------------
sele a
use newdata
zap		(make sure the new structure is empty)
sele b
use srcdata     
sele a
do while .not. eof()
	sele a
	append blank
	replace newdata_field with b->srcdata_field
	skip	(next record in new database)
	sele b
	skip	(next record in source database)
enddo

of course you can calculate/define new fields as you go along.

I hope this is of some help to you.  I used to do quite a bit of programing
in dBase III but nowadays spend my waking hours programing in FOCUS,
therefore my memory may be somewhat faded.


Michael Duebner	                UUCP : michael@ddsw1.MCS.COM
Tech Svc, Buffalo Grove, IL             	708/541-6550