home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / TEMPLGEN / PROOPEN.INC < prev    next >
Encoding:
Text File  |  1989-10-23  |  2.7 KB  |  119 lines

  1. <<* Proopen.inc *>>
  2.  
  3. <<procedure GenOpenBody>>
  4. <<string strg>>
  5. <<integer first>>
  6. <<begin>>
  7. <<genln>>
  8.  
  9. * --- Procedure to open databases and indexes
  10.  
  11. PROCEDURE {fileprefix}_open
  12.  
  13. * --- Initialize global variables
  14.  
  15. choice = 0 
  16. mcount = 0 
  17. <<first := 0>>
  18. <<forall databases>>
  19.  
  20. * --- Open database file
  21.  
  22.     <<filespec( dbfnam,fpath,fname,fext )>>
  23.     <<fname := fname + '.' + fext>>
  24.     <<strg := chr( dbfcount + 64 )>>
  25. SELECT {strg}
  26. mcount = {dbfcount}
  27. IF .NOT. FILE( {"}{fname}{"} )
  28.     fname = GETFILE('DBF','Locate '+{'}{fname}{'}+':')
  29.     IF fname == ""
  30.         noopen = .T.
  31.         RETURN
  32.     ENDIF
  33.     dbname(mcount) = {"}{fname}{"} 
  34.     USE (fname)
  35.     <<if first = 0>>
  36.     IF .NOT. (FILE({"}{fileprefix}_help.dbf{"}) .AND. FILE({"}{fileprefix}_help.fpt{"}))
  37.         DO domemo
  38.     ENDIF
  39.     USE (fname)
  40.     <<endif>>
  41. ELSE
  42.     dbname(mcount) = {"}{fname}{"} 
  43.     <<if dbfals = ''>>
  44.     USE {fname}
  45.         <<if first = 0>>
  46.     IF .NOT. (FILE({"}{fileprefix}_help.dbf{"}) .AND. FILE({"}{fileprefix}_help.fpt{"}))
  47.         DO domemo
  48.     ENDIF
  49.     USE {fname}
  50.         <<endif>>
  51.     <<else>>
  52.     USE {fname} ALIAS {dbfals}
  53.         <<if first = 0>>
  54.     IF .NOT. (FILE({"}{fileprefix}_help.dbf{"}) .AND. FILE({"}{fileprefix}_help.fpt{"}))
  55.         DO domemo
  56.     ENDIF
  57.     USE {fname} ALIAS {dbfals}
  58.         <<endif>>
  59.     <<endif>>
  60. <<first:=1>>
  61. ENDIF
  62.  
  63.     <<if ndxtotal > 0>>
  64.  
  65. * --- Open corresponding index file(s)
  66.  
  67.         <<forall indexes>>
  68.             <<filespec( ndxnam,fpath,fname,fext )>>
  69.             <<fname := fname + '.' + fext>>
  70. IF .NOT. FILE( {"}{fname}{"} )
  71.     choice = 1 
  72.     DO alert2 WITH choice,{"}{fname}{"}+msg_cr_idx
  73.     IF choice = 1
  74.         INDEX ON {ndxkey} TO {fname}                     
  75.     ELSE
  76.         noopen = .T.
  77.         RETURN
  78.     ENDIF
  79. ENDIF
  80.         <<endfor>>
  81. hasindex(mcount) = .T. 
  82.         <<genln( 'SET INDEX TO ',GetIndexNames(1) )>>
  83.         <<popmarg>>
  84.     <<endif>>
  85. <<endfor>>
  86. <<select all>>
  87. <<if reltotal > 0>>    <<*Any relations in entire system?*>>
  88.  
  89. * --- Establish relations between database files
  90.  
  91. <<#
  92.     forall databases
  93.         if reltotal > 0
  94.             genln( 'SELECT ',CHR( dbfcount+64 ) )
  95.         endif
  96.         forall relations
  97.             if forcount = 1
  98.                 genln( 'SET RELATION TO ',relkey,' INTO ',relals )
  99.             else
  100.                 genln( 'SET RELATION TO ',relkey,' INTO ',relals, ' ADDITIVE') 
  101.             endif
  102.         endfor
  103.     endfor
  104. endif
  105. #>>
  106.  
  107. * --- Select current workarea
  108.  
  109. temparea = STR(dbfarea)
  110. SELECT &temparea
  111.  
  112. * --- move record pointer to establish relations (if any)
  113. GOTO RECNO()
  114. RETURN
  115. <<END>> <<*GenOpenBody*>>
  116.  
  117. <<* EOF: Proopen.inc *>>                                
  118.                
  119.