home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 01e / makefile.zip / MAKEFILE.PRG next >
Text File  |  1988-04-06  |  3KB  |  84 lines

  1. ** MAKEFILE.PRG - File creation utility using QS arrays.
  2. PARAMETERS finalfile,initndx,termndx                      
  3. PRIVATE arrayexpr,fldnum,thiselem,field_name,field_type,field_len,field_dec
  4. **
  5. ** Copyright Steve Titterud 1988
  6. ** Permission for non-commercial use granted.
  7. **
  8. ** All activity presumed in currently selected work area.
  9. **
  10. ** Will work regardless of how the values are loaded into CREATOR[],
  11. ** whether through hard-wired code in your program, or interactively with user.
  12. **
  13. ** THIS ROUTINE PRESUMES ALL DATA PASSED TO BE VALID; ERROR-CHECK FIRST!!!
  14. **
  15. arrayexpr = "CREATOR[thiselem,fldnum]"
  16. **
  17. ** This expression will be macro-expanded for each field and each record
  18. ** in the STRUCTURE EXTENDED file which will be used to create the needed file.
  19. **
  20. ** From DECLARE CREATOR[#,4] where 4 columns are field_name,...,field_dec
  21. ** and where ALL files' structural data is stored in this array.
  22. **
  23. ** # above refers to the total number of fields in all files to be created,
  24. ** and fldnum refers to the field numbers in the STRU EXTE file (1-4).
  25. **
  26. ** Each file to be created then occupies a series of elements in CREATOR[],
  27. ** starting with initndx and ending with termndx for each file needed.
  28. **
  29. ** Thus MAKEFILE.PRG is called successively for each file needed, 
  30. ** each time with new parameters for that specific file: its name (finalfile),
  31. ** the starting element (initndx), and ending element (termndx) in CREATOR[]
  32. ** which define its structure.
  33. **
  34. finalfile=ltrim(rtrim(finalfile))
  35. **
  36. ** is BEGETTER.EXT here? if so, zap it; if not, create it
  37. **
  38. if .not. file("BEGETTER.EXT")
  39.    create BEGETTER.EXT
  40.    use BEGETTER.EXT
  41. else
  42.    use BEGETTER.EXT
  43.    zap
  44. endif   
  45. **
  46. ** grab elements one at a time within range, store to automem var's names
  47. ** then issue REPLACE AUTOMEM to create that record
  48. **
  49. for thiselem=initndx to termndx
  50.    **
  51.    ** field name?
  52.    **
  53.    fldnum=1
  54.    field_name=&arrayexpr
  55.    **
  56.    ** field type?
  57.    **
  58.    fldnum=2
  59.    field_type=&arrayexpr
  60.    **
  61.    ** field length?
  62.    **
  63.    fldnum=3
  64.    field_len=&arrayexpr
  65.    **
  66.    ** field decimal places?
  67.    **
  68.    fldnum=4
  69.    field_dec=&arrayexpr
  70.    **
  71.    ** add the new record...
  72.    **
  73.    append automem
  74. next thiselem
  75. ** close BEGETTER.EXT; insert erasure command here or in calling program if
  76. ** you want to get rid of it; presumably, if it is used only on first startup
  77. ** of a system, not needed again; but if used repeatedly to create temporary
  78. ** files, you might want to leave it hanging around
  79. use
  80. create &finalfile. from BEGETTER.EXT
  81. ** close new file
  82. use
  83. return
  84.