Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!aplcen!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!att!mcdchg!ddsw1!michael From: michael@ddsw1.MCS.COM (Michael Duebner) Newsgroups: comp.databases Subject: Re: Clarification to Simple File Transfers Message-ID: <1989Dec2.204211.17943@ddsw1.MCS.COM> Date: 2 Dec 89 20:42:11 GMT References: <25771FA1.20234@paris.ics.uci.edu> Reply-To: michael@ddsw1.MCS.COM (Michael Duebner) Organization: AERA Tech Services, Buffalo Grove, IL Lines: 60 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 Brought to you by Super Global Mega Corp .com