home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / ppstpx.zip / OM1.TPX < prev    next >
Text File  |  1993-06-08  |  15KB  |  394 lines

  1. #!------------------------------------------------------------------------------
  2. #!
  3. #!      OM1.TPX
  4. #!
  5. #!      Batch     Sequential record processing of a file.
  6. #!      External  Document external procedure call
  7. #!      Print     Print a report from memory
  8. #!      Screen    Process a screen
  9. #!      Source    Process embedded source
  10. #!      ToDo      Return immediately (for incomplete procedures)
  11. #!
  12. #!------------------------------------------------------------------------------
  13. #!
  14. #PROCEDURE(Batch,'Update or delete a batch of records'),SCREEN
  15. #!------------------------------------------------------------------------------
  16. #!
  17. #!                           The Batch Template
  18. #!
  19. #!------------------------------------------------------------------------------
  20. #PROTOTYPE('')
  21. #INSERT(%StandardHeader)
  22. #DISPLAY(' ')
  23. #PROMPT('Range &Limit Field',FIELD),%KeyRangeField
  24. #PROMPT('Range &Value Field',FIELD),%RangeValue
  25. #PROMPT('Record Filter',@S180),%RecordFilter
  26. #PROMPT('Action for Batch',OPTION),%BatchAction
  27. #PROMPT('Change',RADIO)
  28. #PROMPT('Delete',RADIO)
  29. #PROMPT('No Action',RADIO)
  30. #PROMPT('Sho&w Record Counter',CHECK),%RecordCounter
  31.  
  32. %Procedure       %ProcedureType
  33.  
  34. #IF(%RecordCounter)
  35. RecordCounter    LONG
  36. #ENDIF
  37.  
  38. #INSERT(%LocalPPSVariables)                    #<! Declare Variables PPS
  39.  
  40. %LocalData
  41. %ScreenStructure
  42. %PulldownStructure
  43. #EMBED('Data Section')
  44.  
  45.   CODE
  46.   ProcedureName = '%Procedure'                 #<!Fill ProcedureName var. PPS
  47.   #EMBED('Setup Procedure')
  48.   #FIX(%File,%Primary)
  49.   #INSERT(%FileMgrStart)                       #<!Insert File Manager. PPS
  50.   #IF(%BatchAction = 'Change')
  51.     #SET(%BatchTitleString, ('Updating '& %Primary & ' Records'))
  52.   #ELSIF(%BatchAction = 'Delete')
  53.     #SET(%BatchTitleString, ('Deleting '& %Primary & ' Records'))
  54.   #ELSE
  55.     #SET(%BatchTitleString, ('Processing '& %Primary & ' Records'))
  56.   #ENDIF
  57.   ScreenTitle = CENTER('%BatchTitleString',LEN(ScreenTitle)) #<!Assign title
  58.   StatusString = CENTER('Select Ok to Process Records',LEN(StatusString))
  59.   OPEN(Screen)                                   !Open the screen
  60.   #IF(%PullDownStructure)
  61.   OPEN(%PullDown)                              #<!Open the pulldown menu
  62.   #ENDIF
  63.   DISPLAY
  64.   #EMBED('Setup Screen')
  65.   CheckOpen(%Primary)                          #<!Ensure %Primary file is open
  66.   #INSERT(%OpenSecondaryFiles)
  67.   LOOP
  68.     CASE SELECTED()                            #<!Jump to field setup routine
  69.     #INSERT(%ScreenSetupRoutines)
  70.     END                                        #<!End CASE
  71.     ACCEPT                                     #<!Enable the mouse and keyboard
  72.     #FOR(%HotKey)
  73.     CASE KEYCODE()
  74.       #FOR(%HotKey)
  75.     OF %HotKey                                 #<!User defined HotKey
  76.       %HotKeyProc                              #<!HotKey Procedure
  77.       #ENDFOR
  78.     #INSERT(%FileMgrView)                      #!Insert File Manager View PPS
  79.     END
  80.       #BREAK
  81.     #ENDFOR
  82.     CASE FIELD()                               #<!Jump to field edit routine
  83.  
  84.     OF ?Ok                                       !On the OK button
  85.   #FOR(%ScreenField)
  86.     #IF(%ScreenFieldUse = '?Ok')
  87.       #IF(%ScreenFieldEdit)
  88.       %ScreenFieldEdit                           #<!Field Edit procedure
  89.       #ENDIF
  90.     #ENDIF
  91.   #ENDFOR
  92.       BREAK
  93.  
  94.     OF ?Cancel                                   !On Cancel button
  95.   #FOR(%ScreenField)
  96.     #IF(%ScreenFieldUse = '?Cancel')
  97.       #IF(%ScreenFieldEdit)
  98.       %ScreenFieldEdit                           #<!Field Edit procedure
  99.       #ENDIF
  100.     #ENDIF
  101.   #ENDFOR
  102.   #IF(%PullDownStructure)
  103.       CLOSE(%PullDown)                         #<!Close the Pulldown Menu
  104.   #ENDIF
  105.       BREAK                                      ! Changed return to break PPS
  106.  
  107.   #FOR(%ScreenField)
  108.     #IF(%ScreenFieldUse <> '?Cancel')
  109.       #IF(%ScreenFieldUse <> '?Ok')
  110.         #IF(%ScreenFieldEdit)
  111.     OF %ScreenField                            #<!Edit %ScreenEditField field
  112.       %ScreenFieldEdit
  113.         #ENDIF
  114.       #ENDIF
  115.     #ENDIF
  116.   #ENDFOR
  117.     #INSERT(%PullDownEditRoutines)
  118.     END                                        #<!End CASE
  119.   END                                          #<!End LOOP
  120.   DISABLE(?Ok)                                 #<!Disable the Ok and
  121.   DISABLE(?Cancel)                             #<! cancel buttons
  122.   #IF(%KeyRangeField)
  123.   %KeyRangeField = %RangeValue                 #<!Fill the range fields
  124.   #ENDIF
  125.   #EMBED('Before file SET()')
  126.   #INSERT(%BatchSetOrder)
  127.   #IF(%RecordCounter = %Null)
  128.     #IF(%BatchAction = 'Delete')
  129.       #SET(%ActionString, 'Deleting')
  130.     #ELSIF(%BatchAction = 'Change')
  131.       #SET(%ActionString, 'Changing')
  132.     #ENDIF
  133.   StatusString = CENTER('%ActionString Records',LEN(StatusString))
  134.   #ELSE
  135.   RecordCounter = 0
  136.   #ENDIF
  137.   #EMBED('Before LOOP')
  138.   DISPLAY
  139.   LOOP
  140.     NEXT(%Primary)
  141.     #EMBED('NEXT Record Error Check')
  142.     #INSERT(%FilterRecord)
  143.     #INSERT(%GetSecondaryRecords)               #!Get lookup records
  144.     #FOR(%Formula)
  145.       #IF(UPPER(%FormulaClass) <> 'FILTER')
  146.     #INSERT(%GenerateFormula)
  147.       #ENDIF
  148.     #ENDFOR
  149.     #EMBED('Within LOOP')
  150.   #IF(%BatchAction = 'Delete')
  151.     DELETE(%Primary)
  152.   #ELSIF(%BatchAction = 'Change')
  153.     PUT(%Primary)
  154.   #ENDIF
  155.     #EMBED('PUT/DELETE Record Error Check')
  156.     #INSERT(%DisplayCounter)
  157.   END
  158.   #IF(%PullDownStructure)
  159.   CLOSE(%PullDown)                             #<!Close the Pulldown Menu
  160.   #ENDIF
  161. #EMBED('End of Procedure')
  162. #INSERT(%FileMgrExit)                          #!Insert File Manager Exit PPS
  163. #!
  164. #!***************************************************************************
  165. #GROUP(%DisplayCounter)                          #!Display record counter.
  166.   #IF(%RecordCounter)
  167. RecordCounter += 1
  168.     #IF(%BatchAction = 'Delete')
  169.       #SET(%ActionString, 'Deleted')
  170.     #ELSE
  171.       #SET(%ActionString, 'Changed')
  172.     #ENDIF
  173. StatusString = CENTER(RecordCounter & ' Records %ActionString',LEN(StatusString))
  174. DISPLAY(?StatusString)
  175.   #ENDIF
  176. #!
  177. #!***************************************************************************
  178. #GROUP(%BatchSetOrder)                           #! Issue SET() command.
  179. #IF(%KeyRangeField)
  180. SET(%PrimaryKey,%PrimaryKey)
  181. #ELSIF(%PrimaryKey)
  182. SET(%PrimaryKey)
  183. #ELSE
  184. SET(%Primary)
  185. #ENDIF
  186. #!
  187. #!***************************************************************************
  188. #GROUP(%FilterRecord)                           #! Filter a record
  189. #IF(%KeyRangeField)                             #!
  190. IF %KeyRangeField <> %RangeValue               #<!If not in Range
  191.   BREAK                                        #<!  Break out of the LOOP
  192. END                                            #<!End IF
  193. #ENDIF
  194. #IF(%RecordFilter)
  195. IF ~(%RecordFilter)                            #<!If Filter condition not met
  196.   CYCLE                                        #<! Return to top of the LOOP
  197. END                                            #<!End IF
  198. #ELSE
  199.   #FOR(%Formula)
  200.     #IF(UPPER(%FormulaClass) = 'FILTER')
  201.       #IF(%FormulaType <> 'COMPUTED')
  202. IF ~(%FormulaCondition)                        #<!If Filter condition not met
  203.   CYCLE                                        #<! Return to top of the LOOP
  204. END                                            #<!End IF
  205.       #ELSE
  206. IF ~(%FormulaComputation)                      #<!If Filter condition not met
  207.   CYCLE                                        #<! Return to top of the LOOP
  208. END                                            #<!End IF
  209.       #ENDIF
  210.       #BREAK
  211.     #ENDIF
  212.   #ENDFOR
  213. #ENDIF
  214. #!
  215. #PROCEDURE(TODO,'Return immediately (for incomplete procedures)')
  216. #!------------------------------------------------------------------------------
  217. #!
  218. #!                            The ToDo Template
  219. #!
  220. #!        The Todo Template generates code for all procedures
  221. #!        which may be called, but which have not yet been designed.
  222. #!
  223. #!        This template is reqired and must not be removed.
  224. #!
  225. #!------------------------------------------------------------------------------
  226. %Procedure       PROCEDURE
  227.    CODE
  228.    GLO:Message2 = 'Procedure Not Yet Defined'
  229.    ShowWarning
  230.    RETURN                                      #<!Return to caller
  231. #!
  232. #PROCEDURE(External,'Document external procedure call')
  233. #!------------------------------------------------------------------------------
  234. #!
  235. #!                         The External Template
  236. #!
  237. #!        This template allows the redefinition of a Todo procedure
  238. #!        for any external procedures which may be called.
  239. #!        This allows you to specify that this particular procedure
  240. #!        is not a Todo procedure and no Todo code will be generated.
  241. #!
  242. #!        There is no source code for this procedure.  See the template
  243. #!        help for more information.
  244. #!
  245. #!------------------------------------------------------------------------------
  246. #!
  247. #PROCEDURE(Source,'Process embedded source code')
  248. #!------------------------------------------------------------------------------
  249. #!
  250. #!                           The Source Template
  251. #!
  252. #!      All source statements, except the PROCEDURE (or FUNCTION)
  253. #!      and CODE statements must be entered as embedded source.
  254. #!
  255. #!------------------------------------------------------------------------------
  256. #INSERT(%StandardHeader)
  257. #PROMPT('Parameter List',@S100),%ParameterList
  258.  
  259. %Procedure       %ProcedureType%ParameterList
  260.  
  261. #INSERT(%LocalPPSVariables)                    #<! Declare Variables PPS
  262.  
  263. %LocalData
  264. #EMBED('Data Section')
  265.   CODE
  266.   ProcedureName = '%Procedure'                 #<!Fill ProcedureName var. PPS
  267.   #INSERT(%FileMgrStart)                       #<!Insert File Manager. PPS
  268. #EMBED('All Executable Source Code')
  269. #INSERT(%FileMgrExit)                          #!Insert File Manager Exit PPS
  270. #!
  271. #PROCEDURE(Screen,'Process a screen'),SCREEN,PULLDOWN
  272. #!------------------------------------------------------------------------------
  273. #!
  274. #!                           The Screen Template
  275. #!
  276. #!------------------------------------------------------------------------------
  277. #PROTOTYPE('')
  278. #INSERT(%StandardHeader)
  279. %Procedure       PROCEDURE
  280.  
  281. #INSERT(%LocalPPSVariables)                    #<! Declare Variables PPS
  282.  
  283. %LocalData
  284. %ScreenStructure
  285. %PulldownStructure
  286. #EMBED('Data Section')
  287.  
  288.   CODE
  289.   ProcedureName = '%Procedure'                 #<!Fill ProcedureName var. PPS
  290.   #FIX(%File,%Primary)
  291.   #INSERT(%FileMgrStart)                       #<!Insert File Manager. PPS
  292.   #EMBED('Setup Procedure')
  293.   OPEN(Screen)                                 #<!Open the screen
  294.   #IF(%PullDownStructure)
  295.   OPEN(%PullDown)                              #<!Open the pulldown menu
  296.   #ENDIF
  297.   #EMBED('Setup Screen')
  298.   LOOP                                         #<!Loop through the fields
  299.     #INSERT(%GenerateFormulas)
  300.     #EMBED('Top of Accept Loop')
  301.     CASE SELECTED()                            #<!Jump to field setup routine
  302.     #INSERT(%ScreenSetupRoutines)
  303.     END                                        #<!End CASE
  304.     ACCEPT                                     #<!Enable the mouse and keyboard
  305.     #FOR(%HotKey)
  306.     CASE KEYCODE()
  307.       #FOR(%HotKey)
  308.     OF %HotKey                                 #<!User defined HotKey
  309.       %HotKeyProc                              #<!HotKey Procedure
  310.       #ENDFOR
  311.       #INSERT(%FileMgrView)                    #!Insert File Manager View PPS
  312.     END
  313.       #BREAK
  314.     #ENDFOR
  315.     CASE FIELD()                               #<!Jump to field edit routine
  316.     #INSERT(%ScreenEditRoutines)
  317.     #INSERT(%PullDownEditRoutines)
  318.     END                                        #<!End CASE
  319.   END                                          #<!End LOOP
  320.   #IF(%PullDownStructure)
  321.   CLOSE(%PullDown)                             #<!Close the Pulldown Menu
  322.   #ENDIF
  323. #EMBED('End of Procedure')
  324. #INSERT(%FileMgrExit)                          #!Insert File Manager Exit PPS
  325. #!
  326. #PROCEDURE(Print,'Print a report from memory'),REPORT
  327. #!------------------------------------------------------------------------------
  328. #!
  329. #!                           The Print Template
  330. #!
  331. #!   This procedure template is designed to print a report from the data
  332. #!   currently in memory.  It does not access any files, does not calculate
  333. #!   any totals, and does not support any group breaks.  It does support
  334. #!   Formula fields, calculated once before printing anything.
  335. #!
  336. #!------------------------------------------------------------------------------
  337. #PROTOTYPE('')
  338. #INSERT(%StandardHeader)
  339. %Procedure       PROCEDURE                     #<!%ProcedureDescription
  340.  
  341. #INSERT(%LocalPPSVariables)                    #<! Declare Variables PPS
  342.  
  343. %LocalData
  344. %ReportStructure
  345. #EMBED('Data Section')
  346.  
  347.   CODE
  348.   #IF(%ReportLabel)
  349.     #SET(%ErrorMessage,(%Procedure & ' ERROR:'))
  350.     #ERROR(%ErrorMessage)
  351.     #ERROR('  Multi-Up Labels must use the REPORT Template')
  352.   #ENDIF
  353.   ProcedureName = '%Procedure'                 #<!Fill ProcedureName var. PPS
  354.   #EMBED('Setup Procedure')
  355.   #INSERT(%FileMgrStart)                       #<!Insert File Manager. PPS
  356.   OPEN(%Report)                                #<!Prepare to print report
  357.   #EMBED('After Report OPEN before Formulas')
  358.   #FOR(%Formula)                                #!All computed fields before
  359.     #IF(%FormulaType = 'COMPUTED')              #! conditional fields
  360.   %Formula = %FormulaComputation               #<!%FormulaDesription
  361.     #ENDIF
  362.   #ENDFOR
  363.   #FOR(%Formula)                                #!All computed fields before
  364.     #IF(%FormulaType = 'CONDITION')             #! conditional fields
  365.   IF %FormulaCondition                         #<!%FormulaDesription
  366.     %Formula = %FormulaTrue                    #<!If true
  367.   ELSE
  368.     %Formula = %FormulaFalse                   #<!If false
  369.   END
  370.     #ENDIF
  371.   #ENDFOR
  372.   #EMBED('After Formulas before Title page')
  373.   #IF(%ReportTitle)                             #!Print Title Page
  374.   PRINT(%ReportPre:%ReportTitle)               #<!Print Title Page
  375.   #ENDIF
  376.   %ReportDetailPre
  377.   #IF(%ReportDetail)
  378.   PRINT(%ReportPre:%ReportDetail)              #<!Print Detail band
  379.   #ENDIF
  380.   %ReportDetailPost
  381.   #IF(%ReportGrand)                             #!Print grand totals band
  382.   PRINT(%ReportPre:%ReportGrand)               #<!Print grand totals band
  383.   #ENDIF
  384.   #EMBED('After Grand Totals before Final Page')
  385.   #IF(%ReportFinal)                             #!Print final page
  386.   PRINT(%ReportPre:%ReportFinal)               #<!Print final page
  387.   #ENDIF
  388.   #EMBED('After Final Page before CLOSE')
  389.   CLOSE(%Report)
  390. #EMBED('End of Procedure')
  391. #INSERT(%FileMgrExit)                          #!Insert File Manager Exit PPS
  392. #!
  393. #CHAIN('OM2.TPX')
  394.