home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
dbase
/
vargen
/
vargen.prg
Wrap
Text File
|
1987-07-19
|
2KB
|
70 lines
* Vargen.prg
* 07/16/87 David L. West, Reinbeck IA
*
* Input: Database file name (with extension!)
* Output file name
*
* Output: Text file with dBase III code to store the contents of a record
* to variables named after the fields, and replace the record with
* the contents of those variables
*
* Comment: Yeah, it ain't pretty, but I got tired of typing STORE this to that,
* REPLACE this with that, ad infinitum.
*
SET TALK OFF
SET BELL OFF
close databases
do while .t.
clear
store space(80) to DBFname,outfile
@ 2,1 say "Enter database file name: " get DBFname picture "@!S40"
@ 3,1 say "Output file name: " GET OutFile PICTURE "@!S40"
read
if DBFname=space(80)
exit
endif
store trim(DBFname) to DBFname
if .not. file("&DBFname")
@ 4,0
wait " No such database! Press any key ...."
loop
else
use &DbfName
endif
clear
store trim(outfile) to OutFile
set alternate to &OutFile
set alternate on
? "** Store fields to identically named memvars"
store 1 to n
do while len(field(n))#0
store "STORE "+TRIM(FIELD(N))+" TO M->"+TRIM(FIELD(N)) TO LINE
? line
store n+1 to N
enddo
?
?
? "** Replace fields with identically named memvars"
store 1 to n
do while len(field(n))#0
store "REPLACE "+TRIM(FIELD(N))+" WITH M->"+TRIM(FIELD(N)) TO LINE
do while len(field(N))#0 .and. len(line) + (len(field(n))*2)+7 < 144
store line+","+TRIM(FIELD(N))+" WITH M->"+TRIM(FIELD(N)) to line
store n+1 to n
enddo
? line
store n+1 to N
enddo
?
SET ALTERNATE TO
SET ALTERNATE OFF
CLOSE ALTERNATE
?
wait " Finished."
loop
enddo