home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / CLATPL.ZIP / CLARION1.TPX < prev    next >
Text File  |  1993-07-26  |  13KB  |  372 lines

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