home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / vargen.zip / VARGEN.PRG
Text File  |  1987-07-19  |  2KB  |  70 lines

  1. * Vargen.prg
  2. * 07/16/87 David L. West, Reinbeck IA
  3. * Input:   Database file name (with extension!)
  4. *          Output file name
  5. *
  6. * Output:  Text file with dBase III code to store the contents of a record
  7. *          to variables named after the fields, and replace the record with
  8. *          the contents of those variables
  9. *
  10. * Comment: Yeah, it ain't pretty, but I got tired of typing STORE this to that,
  11. *          REPLACE this with that, ad infinitum.
  12. *
  13. SET TALK OFF
  14. SET BELL OFF
  15. close databases
  16. do while .t.
  17.  
  18.    clear
  19.    store space(80) to DBFname,outfile
  20.    
  21.    @ 2,1 say "Enter database file name: " get DBFname picture "@!S40"
  22.    @ 3,1 say "Output file name:         " GET OutFile PICTURE "@!S40"
  23.    read
  24.    
  25.    if DBFname=space(80)
  26.       exit
  27.    endif
  28.    store trim(DBFname) to DBFname
  29.    
  30.    if .not. file("&DBFname")
  31.       @ 4,0
  32.       wait " No such database! Press any key ...."
  33.       loop
  34.    else
  35.       use &DbfName
  36.    endif
  37.    clear
  38.    store trim(outfile) to OutFile
  39.    set alternate to &OutFile
  40.    set alternate on
  41.    ? "** Store fields to identically named memvars"
  42.    store 1 to n
  43.    do while len(field(n))#0
  44.       store "STORE "+TRIM(FIELD(N))+" TO M->"+TRIM(FIELD(N)) TO LINE
  45.       ? line
  46.       store n+1 to N
  47.    enddo
  48.    ?
  49.    ?
  50.    ? "** Replace fields with identically named memvars"
  51.    store 1 to n
  52.    do while len(field(n))#0
  53.       store "REPLACE "+TRIM(FIELD(N))+" WITH M->"+TRIM(FIELD(N)) TO LINE
  54.       do while len(field(N))#0 .and. len(line) + (len(field(n))*2)+7 < 144
  55.          store line+","+TRIM(FIELD(N))+" WITH M->"+TRIM(FIELD(N)) to line
  56.          store n+1 to n
  57.       enddo
  58.       ? line
  59.       store n+1 to N
  60.    enddo
  61.    ?
  62.    SET ALTERNATE TO
  63.    SET ALTERNATE OFF
  64.    CLOSE ALTERNATE
  65.    ?
  66.    wait " Finished."
  67.    loop
  68. enddo
  69.