home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR36 / C7101.ZIP / CLARION.TPL < prev    next >
Text File  |  1994-02-01  |  18KB  |  352 lines

  1. #!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
  2. #!│                               Clarion.TPL              │Version: 3007.000│
  3. #!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
  4. #!│Structure             Type       Description                              │
  5. #!│────────────────────  ─────────  ─────────────────────────────────────────│
  6. #!│-None-                PROGRAM    Standard Procedure Code                  │
  7. #!│-None-                MODULE     Standard Module Code                     │
  8. #!├──────────────────────────────────────────────────────────────────────────┤
  9. #!│ CLARION.TPL is the first of a chain of template files that contain the   │
  10. #!│ standard Clarion procedure templates.  These templates generate CUA      │
  11. #!│ compliant, text-based applications.  Other files in the template chain   │
  12. #!│ are PullDown.TPX, Menu.TPX, and so forth.                                │
  13. #!│                                                                          │
  14. #!│ Initial screen, report, and action images are contained in corresponding │
  15. #!│ application files with an extension of .APP (e.g. CLARION.APP).          │
  16. #!│                                                                          │
  17. #!│ Template Listing (In CHAIN Order)                                        │
  18. #!│                                                                          │
  19. #!│   Clarion.TPL     Module       Initialize a module                       │
  20. #!│                   Program      Initialize a program                      │
  21. #!│   PullDown.TPX    Pulldown     Execute a procedure from a pulldown menu  │
  22. #!│   Menu.TPX        Menu         Execute a procedure from a pop-up menu    │
  23. #!│   Browse.TPX      Browse       Browse records directly from a file       │
  24. #!│   List.TPX        List         List a file's records from a memory queue │
  25. #!│   Lookup.TPX      Lookup       Setup procedure to lookup a field         │
  26. #!│   Validate.TPX    Validate     Edit procedure to lookup a field          │
  27. #!│   Select.TPX      Select       Load a selected record into memory        │
  28. #!│   Form.TPX        Form         Update a record with a form               │
  29. #!│   MultiPg.TPX     MultiPage    Update a file with a multiple page entry  │
  30. #!│   PageOf.TPX      PageOf       Data entry 'Page' used with the MultiPage │
  31. #!│   Child.TPX       Child        Update a batch of Child records           │
  32. #!│   Report.TPX      Report       Print a report                            │
  33. #!│   Print.TPX       Print        Print a report from memory                │
  34. #!│   Redirect.TPX    Redirect     Select destination for a report           │
  35. #!│   View.TPX        View         View a selected text file in a listbox    │
  36. #!│   Batch.TPX       Batch        Sequential record processing of a file.   │
  37. #!│   File.TPX        File         Select a file from a directory listing    │
  38. #!│   Screen.TPX      Screen       Process any screen                        │
  39. #!│   Source.TPX      Source       Process any source code                   │
  40. #!│   External.TPX    External     Document external procedure call          │
  41. #!│   ToDo.TPX        Todo         Undefined procedure code                  │
  42. #!│   FileCtrl.TPX    #GROUPs      Associated with File Opening/Closing      │
  43. #!│   Relation.TPX    #GROUPs      Associated with R/I Changes/Deletes       │
  44. #!│   ScrnFlds.TPX    #GROUPs      Associated with Screen Edit/Setup Code    │
  45. #!│   BrwsGrps.TPX    #GROUPs      Associated with BROWSE type procedures    │
  46. #!│   ChldGrps.TPX    #GROUPs      Associated with CHILD procedures          │
  47. #!│   FormGrps.TPX    #GROUPs      Associated with FORM type procedures      │
  48. #!│   MiscGrps.TPX    #GROUPs      Used in various places in the CHAIN       │
  49. #!│   RptGrps.TPX     #GROUPs      Associated with REPORT type procedures    │
  50. #!│   Warnings.TPX    #GROUPs      WARNINGS issued (for easy customization)  │
  51. #!│   CPD21.TPX       Form21       Version 2.1-Style Form Procedure          │
  52. #!│                   Menu21       Version 2.1-Style Menu Procedure          │
  53. #!│                   MemForm21    Version 2.1-Style MemForm Procedure       │
  54. #!│                   Table21      Version 2.1-Style Table Procedure         │
  55. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  56. #!│Version   Comments                                                        │
  57. #!│────────  ────────────────────────────────────────────────────────────────│
  58. #!│3007.000  Release of CDD3 version 3007 templates                          │
  59. #!└──────────────────────────────────────────────────────────────────────────┘
  60. #!
  61. #PROGRAM
  62. #!
  63. #!┌────────────────────────────────────────────────────────┬─────────────────┐
  64. #!│                                #PROGRAM                │Version: 3007.000│
  65. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  66. #!│The Program template generates the PROGRAM statement, MAP structure, FILE │
  67. #!│structures, and global declarations for a Clarion program.  This template │
  68. #!│also blanks the screen and calls the first procedure.  There is only one  │
  69. #!│#PROGRAM segment in a template file chain.                                │
  70. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  71. #!│Version   Comments                                                        │
  72. #!│────────  ────────────────────────────────────────────────────────────────│
  73. #!│3007.000  Release of CDD3 version 3007 templates                          │
  74. #!└──────────────────────────────────────────────────────────────────────────┘
  75. #!
  76. #PROMPT('Enable &Shared Files',CHECK),%SharedFiles
  77. #PROMPT('Enable Mouse Support',CHECK),%MouseSupport
  78. #PROMPT('Enhanced Background?',CHECK),%EnhancedBackground
  79. #PROMPT('Close Unused &Files?',CHECK),%CloseFiles
  80. #PROMPT('If &File Not Found',OPTION),%FileNotFound
  81. #PROMPT('Create',RADIO)
  82. #PROMPT('Halt',RADIO)
  83. #PROMPT('Program &Author',@S30),%Author
  84. #!
  85. #IF(%SharedFiles)
  86.   #SET(%AccessMode,'42h')
  87. #ELSE
  88.   #SET(%AccessMode,'22h')
  89. #ENDIF
  90.                 TITLE('%Program')
  91. OMIT('╝')
  92. ╔════════════════════════════════════════════════════════════════════════════╗
  93. ║  Program - %Program                          #<!                           ║
  94. ║  Author  - %Author                           #<!                           ║
  95. ╚════════════════════════════════════════════════════════════════════════════╝
  96.                  PROGRAM
  97.  
  98.                  INCLUDE('KEYCODES.EQU')
  99.                  INCLUDE('CLARION.EQU')
  100.                  INCLUDE('ERRORS.EQU')
  101.  
  102.                  MAP
  103. #IF(%CloseFiles)
  104.                    CheckOpen(FILE),BYTE
  105. #ELSE
  106.                    CheckOpen(FILE)
  107. #ENDIF
  108.                    DiskError(<STRING>),BYTE
  109.                    ShowWarning
  110.                    %ModuleStructures
  111.                    #EMBED('Inside Global MAP')
  112.                  END
  113.  
  114.                  EJECT('File Layouts')
  115.  
  116. %GlobalData
  117. #EMBED('Before File Declarations')
  118.  
  119. #FOR(%AppFiles)
  120.   #FIX(%File,%AppFiles)
  121.  OMIT('┘')
  122. ┌────────────────────────────────────────────────────────────────────────────┐
  123. │File:   %File                                 #<!                           │
  124. │Prefix: %FilePre                              #<!                           │
  125.   #IF(%FileDescription)
  126. │Desc:   %FileDescription                      #<!                           │
  127.   #ENDIF
  128. │Driver: %FileType                             #<!                           │
  129.   #IF(%FileTypeParameter)
  130. │  Code: %FileTypeParameter                    #<!                           │
  131.   #ENDIF
  132.   #IF(%FileOwner)
  133. │Owner:  %FileOwner                            #<!                           │
  134.   #ENDIF
  135.   #IF(%FileCreate)
  136. │File Create On                                #<!                           │
  137.   #ELSE
  138. │File Create Off                               #<!                           │
  139.   #ENDIF
  140.   #FOR(%Key)
  141. ├────────────────────────────────────────────────────────────────────────────┤
  142.     #IF(%Key=%FilePrimaryKey)
  143. │Key:    %Key (Primary)                        #<!                           │
  144.     #ELSE
  145. │Key:    %Key                                  #<!                           │
  146.     #ENDIF
  147.     #IF(%KeyDescription)
  148. │Desc:   %KeyDescription                       #<!                           │
  149.     #ENDIF
  150.     #IF(%KeyAuto)
  151. │Auto Increment                                #<!                           │
  152.     #ENDIF
  153.     #IF(%KeyDuplicate)
  154. │Key ALLOWS Duplicates                         #<!                           │
  155.     #ELSE
  156. │Key DOES NOT Allow Duplicates                 #<!                           │
  157.     #ENDIF
  158.     #FOR(%KeyField)
  159.       #IF(%KeyFieldSequence = 'ASCENDING')
  160. │Field (Ascending):  %KeyField                 #<!                           │
  161.       #ELSE
  162. │Field (Descending): %KeyField                 #<!                           │
  163.       #ENDIF
  164.     #ENDFOR
  165.   #ENDFOR
  166. └────────────────────────────────────────────────────────────────────────────┘
  167. %FileStructure
  168. #ENDFOR
  169.  
  170. AddRecord        EQUATE(1)                     #<!  Add a new record
  171. ChangeRecord     EQUATE(2)                     #<!  Change the current record
  172. DeleteRecord     EQUATE(3)                     #<!  Delete the current record
  173. SelectRecord     EQUATE(4)                     #<!  Select the current record
  174. #EMBED('Data Section')
  175.  
  176.  
  177.   CODE
  178.   #EMBED('Setup Program')
  179.   LOADSYMBOLS                                  #<!Display graphic mouse
  180.   #IF(%EnhancedBackground)
  181.   SETNOBLINK                                   #<!Enable enhanced colors
  182.   #ENDIF
  183.   #IF(%HelpFile)
  184.   HELP('%HelpFile')                            #<!Open the help file
  185.   #ENDIF
  186.   #IF(%StyleFile )
  187.   GETSTYLES('%StyleFile')                      #<!Open the style file
  188.   #ENDIF
  189.   #IF(%MouseSupport)
  190.   SETMOUSE(1,1)                                #<!Turn on mouse
  191.   #ENDIF
  192.   SETCOLOR(WhiteOnBlack)                       #<!Set white on black
  193.   BLANK                                        #<!Clear the screen
  194.   SETCOLOR                                     #<!Turn off override color
  195.  
  196.   %FirstProcedure                              #<!Call the first procedure
  197.  
  198.   #EMBED('Before return to DOS')
  199.   RETURN                                       #<!Return to DOS
  200.  
  201. OMIT('╝')
  202. ╔════════════════════════════════════════════════════════════════════════════╗
  203. ║  Check ERROR() function after opening a file                               ║
  204. ╚════════════════════════════════════════════════════════════════════════════╝
  205. #IF(%CloseFiles)                                #!Generate function for close
  206. CheckOpen         FUNCTION(File)
  207.  
  208.   CODE
  209.   OPEN(File,%AccessMode)                       #<!Attempt to open the file
  210.   CASE ERRORCODE()                             #<! and check for errors
  211.   OF NoError                                   #<!Return opened flag
  212.     RETURN(1)                                    ! signal successful open
  213.   OF IsOpenErr                                 #<! or if already open.
  214.     RETURN(0)
  215.   #IF(%FileNotFound <> 'Halt')
  216.   OF NoFileErr                                 #<!If file was not found
  217.     CREATE(File)                               #<!Create the file
  218.     OPEN(File,%AccessMode)                     #<! then open it
  219.     IF ~ERRORCODE() THEN RETURN(1).            #<!  And return if it opened
  220.   #ENDIF
  221.   OF InvalidFileErr                            #<!Invalid Record Declaration
  222.     #INSERT(%InvalidFileMsg)
  223.     HALT(InvalidFileErr)
  224.   OF BadKeyErr                                 #<!Key Files must be rebuilt
  225.     #INSERT(%BadKeyMsg)
  226.     OPEN(File,12H)                               !Open for exclusive access
  227.     BUILD(File)                                  !Rebuild the key files
  228.     IF ERRORCODE()
  229.       #INSERT(%KeyBuildErrorMsg)
  230.       HALT(BadKeyErr)
  231.     ELSE
  232.       CLOSE(File)                                !Close
  233.       OPEN(File,%AccessMode)                   #<! then re-open it
  234.       RETURN(1)                                  ! signal successful open
  235.     END
  236.   END                                          #<!End of Case Structure
  237.   IF DiskError(NAME(File) & ' File could not be opened') THEN HALT(0). #<!Cannot resume
  238. #ELSE                                           #!Generate procedure
  239. CheckOpen         PROCEDURE(File)
  240.  
  241.   CODE
  242.   OPEN(File,%AccessMode)                       #<!Attempt to open the file
  243.   CASE ERRORCODE()                             #<! and check for errors
  244.   OF NoError                                   #<!Return if no error
  245.   OROF IsOpenErr                               #<! or if already open.
  246.     RETURN
  247.   #IF(%FileNotFound <> 'Halt')
  248.   OF NoFileErr                                 #<!If file was not found
  249.     CREATE(File)                               #<!Create the file
  250.     OPEN(File,%AccessMode)                     #<! then open it
  251.     IF ~ERRORCODE() THEN RETURN.               #<!  And return if it opened
  252.   #ENDIF
  253.   OF InvalidFileErr                            #<!Invalid Record Declaration
  254.     #INSERT(%InvalidFileMsg)
  255.     HALT(InvalidFileErr)
  256.   OF BadKeyErr                                 #<!Key Files must be rebuilt
  257.     #INSERT(%BadKeyMsg)
  258.     OPEN(File,12H)                             #<!Open for exclusive access
  259.     BUILD(File)                                #<!Rebuild the key files
  260.     IF ERRORCODE()
  261.       #INSERT(%KeyBuildErrorMsg)
  262.       HALT(BadKeyErr)
  263.     ELSE
  264.       CLOSE(File)                              #<!Close
  265.       OPEN(File,%AccessMode)                   #<! then open it
  266.     END
  267.   END                                          #<!End of Case Structure
  268.   IF DiskError(NAME(File) & ' File could not be opened') THEN HALT(0). #<!Cannot resume
  269. #ENDIF
  270.  
  271. OMIT('╝')
  272. ╔════════════════════════════════════════════════════════════════════════════╗
  273. ║  Check ERROR() function after a disk access                                ║
  274. ╚════════════════════════════════════════════════════════════════════════════╝
  275. DiskError        FUNCTION(Cause)
  276. StopMsg::        STRING(180)
  277.  
  278.   CODE
  279.   IF ~ERRORCODE() THEN RETURN(0).              #<!Return with no error
  280.   IF ~OMITTED(1)                               #<!If a cause was given
  281.     StopMsg:: = 'Cause: ' & Cause & LF:CR      #<!  Display it
  282.   END                                          #<!End IF
  283.   IF ERRORFILE()                               #<!If error involves a file
  284.     StopMsg:: = CLIP(StopMsg::) & 'File : '  | #<!  display the file
  285.               & ERRORFILE() & LF:CR
  286.   END                                          #<!End IF
  287.   StopMsg:: = CLIP(StopMsg::) & 'Error: '    | #<!Display the error code
  288.             & ERRORCODE() & ' - '            | #<!  and the error message
  289.             & ERROR() & LF:CR
  290.  
  291.   STOP(StopMsg::)                              #<!Stop with message
  292.   RETURN(1)                                    #<!Return with error
  293.  
  294. OMIT('╝')
  295. ╔════════════════════════════════════════════════════════════════════════════╗
  296. ║  Display a warning message using 3 Global message variables.               ║
  297. ╚════════════════════════════════════════════════════════════════════════════╝
  298. ShowWarning      PROCEDURE
  299.  
  300. SaveStyle        STRING(256)
  301.  
  302. Screen           SCREEN(9,53),PRE(SCR),CENTER,SHADOW,CUA,COLOR(112)
  303.                    ROW(1,1)    STRING('█▀{51}█'),COLOR(116)
  304.                    ROW(9,1)    STRING('█▄{51}█'),COLOR(116)
  305.                                REPEAT(7)
  306.                    ROW(2,1)      STRING('█'),COLOR(116)
  307.                    ROW(2,53)     STRING('█'),COLOR(116)
  308.                                .
  309.                    ROW(3,5)    ENTRY(@S45),USE(GLO:Message1),INS,SKIP,COLOR(112,112,112)
  310.                    ROW(4,5)    ENTRY(@S45),USE(GLO:Message2),INS,SKIP,COLOR(112,112,112)
  311.                    ROW(5,5)    ENTRY(@s45),USE(GLO:Message3),INS,SKIP,COLOR(112,112,112)
  312.                    ROW(7,24)   BUTTON('  &Ok  |'),SHADOW,USE(?Ok),COLOR(23,71,24,31,79)
  313.                  .
  314.  
  315.   CODE
  316.   SaveStyle = STYLES()                         #<!Save current style
  317.   GETSTYLES('')                                #<!Turn off Styles
  318.   GLO:Message1 = CENTER(GLO:Message1,SIZE(GLO:Message1))
  319.   GLO:Message2 = CENTER(GLO:Message2,SIZE(GLO:Message2))
  320.   GLO:Message3 = CENTER(GLO:Message3,SIZE(GLO:Message3))
  321.   OPEN(Screen)
  322.   DISPLAY
  323.   ACCEPT                                       #<!Enable keyboard and mouse
  324.   CLEAR(GLO:MessageGroup)                      #<!Blank out message fields
  325.   SETSTYLES(SaveStyle)                         #<!Restore user styles
  326.   RETURN
  327.  
  328. #!
  329. #MODULE
  330. #!
  331. #!┌────────────────────────────────────────────────────────┬─────────────────┐
  332. #!│                                 #MODULE                │Version: 3007.000│
  333. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  334. #!│The Module template generates the MEMBER statement, and module level data │
  335. #!│declarations for a source module of a Clarion program.  There is only one │
  336. #!│#MODULE segment in a template file chain.                                 │
  337. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  338. #!│Version   Comments                                                        │
  339. #!│────────  ────────────────────────────────────────────────────────────────│
  340. #!│3007.000  Release of CDD3 version 3007 templates                          │
  341. #!└──────────────────────────────────────────────────────────────────────────┘
  342. #!
  343.                 MEMBER('%Program')
  344. OMIT('╝')
  345. ╔════════════════════════════════════════════════════════════════════════════╗
  346. ║   %Module - %ModuleDescription               #<!                           ║
  347. ╚════════════════════════════════════════════════════════════════════════════╝
  348. %ModuleData
  349. #EMBED('Data Section')
  350. #!
  351. #CHAIN('PullDown.tpx')
  352.