home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / ppstpx.zip / OM9.TPX < prev    next >
Text File  |  1993-06-09  |  14KB  |  349 lines

  1. #!------------------------------------------------------------------------------
  2. #!
  3. #!      OM9.TPX
  4. #!
  5. #!      %StandardHeader
  6. #!      %GenerateFormulas
  7. #!      %GenerateFormula
  8. #!      %OpenPrimary
  9. #!      %OpenSecondaryFiles
  10. #!      %GetSecondaryRecords
  11. #!      %ScreenSetupRoutine
  12. #!      %PulldownEditRoutines
  13. #!------------------------------------------------------------------------------
  14. #!
  15. #GROUP(%StandardHeader)
  16. #!------------------------------------------------------------------------------
  17. #!
  18. #!                            Standard Header
  19. #!
  20. #!  The following statements are inserted after every PROCEDURE statement
  21. #!
  22. #!------------------------------------------------------------------------------
  23. OMIT('╝')
  24. ╔════════════════════════════════════════════════════════════════════════════╗
  25. ║ %Procedure - %ProcedureDescription           #<!Generated Procedure        ║
  26. ╚════════════════════════════════════════════════════════════════════════════╝
  27. #GROUP(%GenerateFormulas)
  28. #!------------------------------------------------------------------------------
  29. #!
  30. #!                            Generate Formulas
  31. #!
  32. #!  The formula editor generates computed fields and conditional fields.
  33. #!  Computed fields assign the value of a numeric or string expression to a
  34. #!  variable.  Conditional fields evaluate a logical expression, then assign
  35. #!  the value of a true expression or a false expression to a variable.  The
  36. #!  order of formulas is important because formulas may produce intermediate
  37. #!  values used in later formulas.
  38. #!
  39. #!  Each formula has an optional class.  If the symbol %CodePosition is
  40. #!  null, every formula is generated.  If %CodePosition is not null, only
  41. #!  formulas with matching classes are generated.
  42. #!
  43. #!------------------------------------------------------------------------------
  44.   #FOR(%Formula)
  45.     #IF((UPPER(LEFT(%FormulaClass)) = UPPER(%CodePosition) OR %CodePosition = %NULL))
  46.       #IF(%FormulaType = 'COMPUTED')
  47. %Formula = %FormulaComputation                 #<!%FormulaDescription
  48.       #ELSIF(%FormulaType = 'CONDITION')
  49. IF %FormulaCondition                           #<!%FormulaDescription
  50.   %Formula = %FormulaTrue
  51.         #IF(%FormulaFalse)
  52. ELSE
  53.   %Formula = %FormulaFalse
  54.         #ENDIF
  55. END
  56.       #ENDIF
  57.     #ENDIF
  58.   #ENDFOR
  59. #GROUP(%GenerateFormula)
  60. #!------------------------------------------------------------------------------
  61. #!
  62. #!                            Generate Formula
  63. #!
  64. #!  The formula editor generates computed fields and conditional fields.
  65. #!  Computed fields assign the value of a numeric or string expression to a
  66. #!  variable.  Conditional fields evaluate a logical expression, then assign
  67. #!  the value of a true expression or a false expression to a variable.  The
  68. #!  order of formulas is important because formulas may produce intermediate
  69. #!  values used in later formulas.
  70. #!
  71. #!  This group will generate a single formula.  If more than one formula
  72. #!  is needed, it should be placed in a template #FOR statement:
  73. #!
  74. #!                   #FOR(%Formula)
  75. #!                     #INSERT(%GenerateFormula)
  76. #!                   #ENDFOR
  77. #!
  78. #!  Or, if only a selected formula class is needed:
  79. #!
  80. #!                   #FOR(%Formula)
  81. #!                     #IF(%FormulaClass <> 'FILTER')
  82. #!                       #INSERT(%GenerateFormula)
  83. #!                     #ENDIF
  84. #!                   #ENDFOR
  85. #!
  86. #!------------------------------------------------------------------------------
  87.      #IF(%FormulaType = 'COMPUTED')
  88. %Formula = %FormulaComputation                 #<!%FormulaDescription
  89.      #ELSE
  90. IF %FormulaCondition                           #<!%FormulaDescription
  91.   %Formula = %FormulaTrue
  92.        #IF(%FormulaFalse)
  93. ELSE
  94.   %Formula = %FormulaFalse
  95.        #ENDIF
  96. END
  97.      #ENDIF
  98. #!------------------------------------------------------------------------------
  99. #!
  100. #!                                Open Primary
  101. #!
  102. #!  To avoid a long delay when loading a program, each procedure opens the
  103. #!  files it uses.  Opening an open file takes negligible time.  %FileMode
  104. #!  contains the parameters of the OPEN statement that controls how a file
  105. #!  is accessed (read, write, etc.) and shared (share, exclusive, etc.)
  106. #!
  107. #!------------------------------------------------------------------------------
  108. #GROUP(%OpenPrimary)
  109. #INSERT(%FileMgrStart)                         #<!Insert File Manager. PPS
  110. #!CheckOpen(%Primary)                          #<!Ensure %Primary file is open
  111. #!------------------------------------------------------------------------------
  112. #!
  113. #!                          Get Secondary Records
  114. #!
  115. #!  There is a secondary file for every active relationship of the primary
  116. #!  file.  A relationship is active for a given procedure if any field in
  117. #!  the secondary file is in use by the screen, report, or formula editor.
  118. #!
  119. #!------------------------------------------------------------------------------
  120. #GROUP(%GetSecondaryRecords)                    #!Get all lookup records
  121.   #FOR(%Secondary)                              #! for fields in the list box
  122.       #IF(%SecondaryType = 'MANY:1')            #!Check for lookup files
  123.         #FIX(%File,%SecondaryTo)
  124.         #FIX(%Relation,%Secondary)
  125.         #FOR(%RelationKeyField)
  126. %RelationKeyField = %RelationKeyFieldLink      #<!Assign linking field value
  127.         #ENDFOR
  128. GET(%Secondary,%RelationKey)                   #<!Lookup record
  129.         #FIX(%File,%Secondary)
  130. IF ERRORCODE() THEN CLEAR(%FilePre:Record).    #<!Clear record if unsuccessful
  131.       #ENDIF
  132.   #ENDFOR
  133. #!------------------------------------------------------------------------------
  134. #!
  135. #!                         Open Secondary Files
  136. #!
  137. #!  This group will open any secondary files within the file schematic.
  138. #!
  139. #!------------------------------------------------------------------------------
  140. #GROUP(%OpenSecondaryFiles)
  141.   #FOR(%Secondary)
  142.   #IF(%FileMgr)                                #! If File Manager is used
  143.                                                #! then use the FileManager
  144.                                                #! procedure.
  145.      FileMgr('OPEN',ProcedureName,LocalFileMgrLvl,%Secondary,'%Secondary')#<!Ensure %Secondary file is open
  146.   #ELSE                                        #! If not used then use the
  147.                                                #! standard Clarion CheckOpen.
  148.                                                #! PPS
  149.      CheckOpen(%Secondary)                     #<!Ensure %Secondary file is open
  150.   #ENDIF
  151.   #ENDFOR
  152. #!------------------------------------------------------------------------------
  153. #!
  154. #!                          Screen Setup Routine
  155. #!
  156. #!  The following statements generate Setup routines to be placed in the
  157. #!  CASE SELECTED() structure.
  158. #!
  159. #!------------------------------------------------------------------------------
  160. #GROUP(%ScreenSetupRoutines)
  161.    #FOR(%ScreenField)
  162.      #IF(%ScreenFieldSetup)
  163. OF %ScreenField                                #<!Setup %ScreenSetupField field
  164.     %ScreenFieldSetup
  165.      #ENDIF
  166.    #ENDFOR
  167. #!------------------------------------------------------------------------------
  168. #!
  169. #!                          Screen Edit Routine
  170. #!
  171. #!  The following statements generate Edit routines to be placed in the
  172. #!  CASE FIELD() structure.
  173. #!
  174. #!
  175. #!------------------------------------------------------------------------------
  176. #GROUP(%ScreenEditRoutines)
  177.   #FOR(%ScreenField)
  178.     #IF(%ScreenFieldEdit)
  179. OF %ScreenField                                #<!Edit %ScreenEditField field
  180.   %ScreenFieldEdit
  181.     #ENDIF
  182.   #ENDFOR
  183.   #FOR(%PulldownField)
  184.     #IF(%PulldownFieldProc)
  185. OF %PulldownField                              #<!For a selected menu item
  186.   %PulldownFieldProc                           #<! execute its procedure
  187.     #ENDIF
  188.   #ENDFOR
  189. #!------------------------------------------------------------------------------
  190. #!
  191. #!                         Pulldown Field Routine
  192. #!
  193. #!  The following statements generate Edit routines to be placed in the
  194. #!  CASE FIELD() structure for Pulldown.
  195. #!
  196. #!
  197. #!------------------------------------------------------------------------------
  198. #GROUP(%PulldownEditRoutines)
  199.   #FOR(%PulldownField)                          #! add all procedure or
  200.     #IF(%PulldownFieldType = 'PROCEDURE')       #! source code calls
  201. OF %PulldownField                               #<!For a Pulldown field
  202.   %PulldownFieldProc                            #<! execute its procedure
  203.     #ENDIF
  204.   #ENDFOR
  205.  
  206. #! PPS
  207. #!------------------------------------------------------------------------------
  208. #!
  209. #!                               PPS Local Variables
  210. #!
  211. #!  The following statements declare the local variables required for
  212. #!  various PPS template additions.
  213. #!
  214. #!------------------------------------------------------------------------------
  215. #GROUP(%LocalPPSVariables)
  216.                                                 #<! PPS Variables
  217. ProcedureName    STRING(80)                     #<! Procedure name holder
  218. LocalFileMgrLvl    byte                         #<! Local file manager level
  219.  
  220. #! PPS
  221. #!------------------------------------------------------------------------------
  222. #!
  223. #!                       File Manager Global Variables
  224. #!
  225. #!  The following statements declare the global variables required for the
  226. #!  file manager.
  227. #!
  228. #!------------------------------------------------------------------------------
  229. #GROUP(%GlobalFileMgrVars)
  230.  
  231. FileManagerQueue QUEUE,pre(fmq)                 #<! File Management QUEUE
  232. record             group
  233. ProcName              string(80)                #<! Procedure file opened in
  234. FileName              string(8)                 #<! File to be opened
  235. FileMgrLvl            byte                      #<! Current File manager level
  236.                    .
  237.                  .
  238.  
  239. #! PPS
  240. #!------------------------------------------------------------------------------
  241. #!
  242. #!                       File Manager Start Up Procedure Calls
  243. #!
  244. #!  The following statements are required to start the file management.
  245. #!
  246. #!------------------------------------------------------------------------------
  247. #GROUP(%FileMgrStart)
  248.  
  249.   #IF(%FileMgr)                                #! If File Manager is used
  250.                                                #! then use the FileManager
  251.                                                #! procedure.
  252.   FileMgr('LEVEL',ProcedureName,|              #<!Fill LocalFileMgrLvl. PPS
  253.           LocalFileMgrLvl)
  254.   #IF(%File)                                   #<!If files exist then
  255.   FileMgr('OPEN',ProcedureName,|
  256.           LocalFileMgrLvl,%Primary,'%Primary') #<!Ensure %Primary file is open
  257.   #ENDIF                                       #<!End if files exist
  258.   alert(AltMinus)                                !Alert View hot key
  259.   #ELSE                                        #! If not used then use the
  260.                                                #! standard Clarion CheckOpen.
  261.                                                #! PPS
  262.      CheckOpen(%Primary)                       #<!Ensure %Primary file is open
  263.   #ENDIF
  264.  
  265. #! PPS
  266. #!------------------------------------------------------------------------------
  267. #!
  268. #!                       File Manager Exit Procedure Calls
  269. #!
  270. #!  The following statements are required to exit the file manager for a
  271. #!  procedure.
  272. #!
  273. #!------------------------------------------------------------------------------
  274. #GROUP(%FileMgrExit)
  275.  
  276.   #IF(%FileMgr)                                #! If File Manager is used
  277.                                                #! then use the FileManager
  278.                                                #! procedure.
  279.   FileMgr('EXIT',ProcedureName,|
  280.           LocalFileMgrLvl)                     #<!Close all files. PPS
  281.   #ENDIF
  282.  
  283. #! PPS
  284. #!------------------------------------------------------------------------------
  285. #!
  286. #!                       File Manager View Keycode Processing
  287. #!
  288. #!  The following statements are required to call the file manager view
  289. #!  procedure.
  290. #!
  291. #!------------------------------------------------------------------------------
  292. #GROUP(%FileMgrView)
  293.  
  294.   #IF(%FileMgr)                                 #! If File Manager is used
  295.                                                 #! then call the FileManager
  296.                                                 #! procedure.
  297.       OF AltMinus
  298.          #INSERT(%DisableFields)                #!Disable all fields PPS
  299.          FileMgr('VIEW')                         !Call the File Manager View
  300.          #INSERT(%EnableFields)                 #!Enable all fields PPS
  301.  
  302.   #ENDIF
  303.  
  304. #! PPS
  305. #!------------------------------------------------------------------------------
  306. #!
  307. #!                       All field disable code
  308. #!
  309. #!  The following statements are required to disable all fields and pulldown
  310. #!  fields.
  311. #!
  312. #!------------------------------------------------------------------------------
  313. #GROUP(%DisableFields)
  314.  
  315.  #FOR(%ScreenField)
  316.       #IF(%ScreenField)
  317.       disable(%ScreenField)
  318.       #ENDIF
  319.  #ENDFOR
  320.  
  321.  #FOR(%PulldownField)
  322.       #IF(%PulldownField)
  323.       disable(%PulldownField)
  324.       #ENDIF
  325.  #ENDFOR
  326.  
  327. #! PPS
  328. #!------------------------------------------------------------------------------
  329. #!
  330. #!                       All field enable code
  331. #!
  332. #!  The following statements are required to enable all fields and pulldown
  333. #!  fields.
  334. #!
  335. #!------------------------------------------------------------------------------
  336. #GROUP(%EnableFields)
  337.  
  338.  #FOR(%ScreenField)
  339.       #IF(%ScreenField)
  340.       enable(%ScreenField)
  341.       #ENDIF
  342.  #ENDFOR
  343.  
  344.  #FOR(%PulldownField)
  345.       #IF(%PulldownField)
  346.       enable(%PulldownField)
  347.       #ENDIF
  348.  #ENDFOR
  349.