home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a040 / 2.ddi / SHRWARE4.ARC / MSAOPEN.INC < prev    next >
Encoding:
Text File  |  1988-06-03  |  4.4 KB  |  185 lines

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