home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / TEMPLGEN / ADVANCED.GEN next >
Encoding:
Text File  |  1990-02-10  |  3.6 KB  |  154 lines

  1. <<* Advanced.gen *>>
  2. <<#
  3. title "FoxPro Advanced Application"
  4.  
  5. <<* Declare global variables *>>
  6.  
  7. string fmain,fproc,fpath,fname,fext
  8. string fmtmain,fmtpath,fmtname,fmtext
  9. string prgpath,fileprefix,datafile,fldprefix
  10. logical ismultials
  11. integer errnum,errfmt
  12. logical safetywason
  13.  
  14.  
  15. #>>
  16.  
  17. <<* General modules *>>
  18.  
  19. <<#include 'Profle.inc'#>>  <<* Contains 
  20.  
  21. <<* Format Screen modules *>>
  22.  
  23. <<#include 'Profrm.inc'#>> 
  24.  
  25. <<* Specific modules *>>
  26.  
  27. <<#include 'Proproc.inc'#>> 
  28.  
  29. <<* Contains main MENU(s) *>>
  30.  
  31. <<*<<#include 'Catmenu.inc'#>>*>>
  32.  
  33. <<#include 'Promain.inc'#>>
  34. <<#include 'Proopen.inc'#>>
  35. <<#include 'Proedit.inc'#>>
  36. <<#include 'Prorepo.inc'#>>
  37. <<#include 'Prolabe.inc'#>>
  38. <<#
  39.  
  40. <<* Function to get program name *>>
  41.  
  42. function GetPrgName( prompt : string ) : string
  43. string fspec,fpath,fname,fext
  44. begin
  45.   input prompt to fspec
  46.   if fspec
  47.     filespec( fspec,fpath,fname,fext )
  48.     fspec := fname + '.PRG'  <<* Force a '.PRG' extension *>>
  49.   endif
  50.  
  51.   RETURN fspec
  52. end <<* GetPrgName *>>
  53.  
  54. <<* Function to get format file name *>>
  55.  
  56. function GetFmtName( prompt : string ) : string
  57. string fmtspec,fmtpath,fmtname,fmtext
  58. begin
  59.   input prompt to fmtspec
  60.   if fmtspec
  61.     filespec( fmtspec,fmtpath,fmtname,fmtext )
  62.     fmtspec := fmtname + '.FMT'  <<* Force a '.FMT' extension *>>
  63.   endif
  64.  
  65.   RETURN fmtspec
  66. end <<* GetFmtName *>>
  67.  
  68. <<* Intialize environment *>>
  69.  
  70. procedure initGlobals
  71. begin
  72. <<* set tabs to true *>>
  73.     select database 1
  74.     filespec( dbfnam,fpath,datafile,fext ) <<* Init 'datafile' *>>
  75.     select all      <<* Reset all scoping *>>
  76.     ismultials :=(dbftotal >1) <<* Using more than 1 Database? *>>
  77.     set lmargin to 0   <<* No left margin offset *>>
  78. end <<* InitGlobals *>>
  79.  
  80. <<*  Generate the main body of the procedure file *>>
  81.  
  82. Procedure GenMainPrg
  83. begin
  84.   <<* fmain includes pathname *>>
  85.   IF OpenFile(fmain,'MAIN program for ' +datafile + '.DBF'
  86.      GenMainBody
  87.   end
  88. end <<* GenMainPrg *>>
  89.  
  90. Procedure GenPrograms
  91. begin
  92.      GenOpenBody 
  93.      GenEditBody
  94.      GenReportBody 
  95.      GenLabelBody
  96. end <<* genPrograms *>>
  97.  
  98. Procedure GenProcedures
  99. string fspec,filename
  100. integer ptype
  101. begin
  102.      GenProcStandard
  103.      GenProcSecond
  104. end<<* GenProcedures *>>
  105.  
  106. begin <<* MAIN *>>
  107.   if table
  108.        fmain := GetPrgName( "Enter FILENAME of program to Generate" )
  109.        fmtname := GetFmtName( "Enter FILENAME of format file to GENERATE" )
  110.        if substr(Fmain,3,1) <> '.'
  111.               fileprefix := lower(substr(Fmain,1,3)) <<* 1st three letters as prefix *>>
  112.        endif 
  113.        if substr(Fmain,2,1) <> '.'
  114.            fileprefix := lower(substr(Fmain,1,2))
  115.        else
  116.            fileprefix := lower(substr(Fmain,1,1))
  117.        endif
  118.        if fmain <> ''
  119.            if safety
  120.                 set safety to false
  121.                 safetywason := true
  122.            endif
  123.            errnum := rewrite( fmain )
  124.            if errnum = 0
  125.               InitGlobals
  126.               GenMainPrg
  127.               GenPrograms
  128.               GenProcedures
  129.               if fmtname
  130.                   errfmt := rewrite( fmtname )
  131.                   if errfmt = 0
  132.                       GenBrowseFormat
  133.                   endif
  134.               endif
  135.            elseif errnum = 4096
  136.               wait 'Cannot generate an active program'
  137.            else
  138.               wait 'Cannot open file'
  139.            endif
  140.  
  141.  
  142.            if safetywason
  143.                 set safety to true
  144.            endif
  145.        endif 
  146.        wait 'Foxpro Advanced Application completed.'
  147.   else
  148.     wait "No FoxView Table is available "
  149.   endif
  150. end <<* MAIN *>>
  151. #>>
  152.  
  153. <<* EOF: Foxpro Advanced Application *>>
  154.