home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / TEMPLGEN / AP1OPEN.INC < prev    next >
Encoding:
Text File  |  1988-02-10  |  3.9 KB  |  163 lines

  1. <<* APPOPEN.INC *>>
  2. <<#pragma
  3.  
  4. function GetPromptRow : integer
  5. integer maxrow,row,col,fldlablen,templen
  6. begin
  7.   maxrow := 0
  8.   select all
  9.   forall fields
  10.     fldlablen := len( fldlab )
  11.     if fldtyp = 'B'     <<*BOX types*>>
  12.       row := fldrow + flddec - 1
  13.     elsif fldtyp = 'T'  <<*TEXT types*>>
  14.       if not fldhor     <<*Vertical*>>
  15.         row := fldrow + fldlablen - 1
  16.       else
  17.         row := fldrow
  18.       endif
  19.     else  <<*all other types*>>
  20.       row := fldrow
  21.       col := fldcol
  22.       if not fldsid     <<*Stacked GET*>>
  23.         row := row + 1
  24.       else
  25.         col := col + fldlablen
  26.       endif
  27.       if col + fldwid > SCREENWIDTH   <<*Check for wraparound GETS*>>
  28.         templen := fldwid - (SCREENWIDTH - col)
  29.         if SCREENWIDTH - col > 0
  30.           repeat
  31.             row := row + 1
  32.             templen := templen - (SCREENWIDTH - col)
  33.           until templen <= 0
  34.         endif
  35.       endif
  36.     endif
  37.     if maxrow < row
  38.       maxrow := row
  39.     endif
  40.   endfor
  41.   maxrow := maxrow + 4   <<*Compute PromptRow*>>
  42.   if maxrow > 23         <<*Don't go off the screen!*>>
  43.     maxrow := 23
  44.   endif
  45.   RETURN maxrow
  46. end <<*GetPromptRow*>>
  47. #>>
  48.  
  49.  
  50. <<procedure GenOpenBody>>
  51. <<integer promptrow>>
  52. <<string  strg>>
  53. <<begin>>
  54.   <<promptrow := GetPromptRow>>
  55. * ---INKEY() constant values.
  56. PgDn = CHR(3)
  57. PgUp = CHR(18)
  58. Returnkey = CHR(13)
  59. DelRecord = CHR(7)
  60. *
  61. * ---SET COLOR TO values.
  62. ScreenAtr = {"}{ScreenColor}"
  63. StatusAtr = {"}{StatusColor}"
  64. WindowAtr = {"}{WindowColor}"
  65. PromptAtr = {"}{PromptColor}"
  66. HiliteAtr = {"}{HiliteColor}"
  67. *
  68. * ---Initialize global variables.
  69. STORE 0 TO LastRec,oldrecnum,recnum,menuchoice
  70. STORE " " TO choice,expr
  71.     <<if ismultipage>>
  72. pageno = 1
  73.       <<select all>>
  74. PageMax = {pagtotal}
  75.       <<if ismultials>>
  76.         <<select database 1>>
  77. dbfpagemax = {pagtotal}
  78.       <<endif>>
  79.     <<endif>>
  80. PromptRow = {promptrow}
  81. PromptBar = REPLICATE( CHR( 196 ),80 )
  82. <<forall databases>>
  83. *
  84. * ---Open database file.
  85.   <<filespec( dbfnam,fpath,fname,fext )>>
  86.   <<strg := chr( dbfcount + 64 )>>
  87. SELECT {strg}
  88. IF .NOT. FILE( {"}{fname}.DBF{"} )
  89.    ? [{"}{fname}.DBF{"} not found]
  90.    WAIT
  91.    QUIT
  92. ENDIF
  93.   <<if dbfals = ''>>
  94. USE {fname}
  95.   <<else>>
  96. USE {fname} ALIAS {dbfals}
  97.   <<endif>>
  98.   <<if ndxtotal > 0>>
  99. *
  100. * ---Open INDEX file(s).
  101.     <<forall indexes>>
  102.       <<filespec( ndxnam,fpath,fname,fext )>>
  103.       <<fname := fname + '.' + GetIndexExt>>
  104. IF .NOT. FILE( {"}{fname}{"} )
  105.    ? [Creating index {"}{fname}{"}...]
  106.    INDEX ON {ndxkey} TO {fname}
  107. ENDIF
  108.     <<endfor>>
  109.     <<genln( 'SET INDEX TO ',GetIndexNames(1) )>>
  110.   <<endif>>
  111. <<endfor>>
  112. <<select all>>
  113. <<if reltotal > 0>>   <<*Any relations in entire system?*>>
  114. *
  115. * ---SET RELATION(s).
  116. <<#
  117.   forall databases
  118.     if reltotal > 0
  119.       genln( 'SELECT ',chr( dbfcount+64 ) )
  120.     endif
  121.       forall relations
  122.         if forcount = 1
  123.           genln( 'SET RELATION TO ',relkey,' INTO ',relals )
  124.         else
  125.           genln( 'SET RELATION TO ',relkey,' INTO ',relals,' ADDITIVE' )
  126.         endif
  127.       endfor
  128.   endfor
  129. endif
  130. #>>
  131. <<select database 8>>  <<*Is SELECT H being used?*>>
  132. <<if dbfnam = ''>>     <<*No, so let's do some fancy stuff...*>>
  133. *
  134. * ---Open CONDITIONS file.
  135. IF .NOT. FILE( {"}{fileprefix}_COND.DBF{"} )
  136.    ? [Creating {"}{fileprefix}_COND.DBF{"} file...]
  137.    COPY TO {fileprefix}_XXXX STRUCTURE EXTENDED
  138.    SELECT H
  139.    USE {fileprefix}_XXXX
  140.    ZAP
  141.    APPEND BLANK
  142.    REPLACE FIELD_NAME WITH "CONDEXPR"
  143.    REPLACE FIELD_TYPE WITH "C"
  144.    REPLACE FIELD_LEN  WITH 128
  145.    APPEND BLANK
  146.    REPLACE FIELD_NAME WITH "CONDAREA"
  147.    REPLACE FIELD_TYPE WITH "C"
  148.    REPLACE FIELD_LEN  WITH 1
  149.    USE
  150.    CREATE {fileprefix}_COND FROM {fileprefix}_XXXX
  151.    DELETE FILE {fileprefix}_XXXX.DBF
  152. ENDIF
  153. SELECT H
  154. USE {fileprefix}_COND
  155. <<endif>>
  156. *
  157. * ---Initialize database variables for current workarea.
  158. DO {fileprefix}_AREA
  159. *
  160. <<end>> <<*GenOpenBody*>>
  161.  
  162. <<* EOF: APPOPEN.INC *>>
  163.