home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / CLATPL.ZIP / CLARION.TPL next >
Text File  |  1993-07-26  |  13KB  |  292 lines

  1. #!------------------------------------------------------------------------------
  2. #!
  3. #!                          The Clarion Template File
  4. #!
  5. #!    CLARION.TPL is the first of a chain of template files that contain the
  6. #!    standard Clarion procedure templates.  These templates generate CUA
  7. #!    compliant, text-based applications.  Other files in the template chain
  8. #!    are CLARION1.TPX, CLARION2.TPX, and so forth.
  9. #!
  10. #!    Initial screen, report, and action images are contained in corresponding
  11. #!    application files with an extension of .APP (e.g. CLARION.APP).
  12. #!
  13. #!    Template Directory
  14. #!
  15. #!      CLARION1.TPX    Batch        Sequential record processing of a file.
  16. #!      CLARION3.TPX    Browse       Browse records directly from a file
  17. #!      CLARION6.TPX    Child        Update a batch of Child records
  18. #!      CLARION1.TPX    External     Document external procedure call
  19. #!      CLARION8.TPX    File         Select a file from a directory listing
  20. #!      CLARION4.TPX    Form         Update a record with a form
  21. #!      CLARION3.TPX    List         List a file's records from a memory queue
  22. #!      CLARION3.TPX    Lookup       Setup procedure to lookup a field
  23. #!      CLARION2.TPX    Menu         Execute a procedure from a pop-up menu
  24. #!      CLARION.TPL     Module       Initialize a module
  25. #!      CLARION4.TPX    MultiPage    Update a file with a multiple page entry form
  26. #!      CLARION4.TPX    PageOf       Data entry 'Page' used with the MultiPage Form
  27. #!      CLARION1.TPX    Print        Print a report from memory
  28. #!      CLARION.TPL     Program      Initialize a program
  29. #!      CLARION2.TPX    Pulldown     Execute a procedure from a pulldown menu
  30. #!      CLARION8.TPX    Redirect     Select destination for a report
  31. #!      CLARION7.TPX    Report       Print a report
  32. #!      CLARION1.TPX    Screen       Process any screen
  33. #!      CLARION3.TPX    Select       Load a selected record into memory
  34. #!      CLARION1.TPX    Source       Process any source code
  35. #!      CLARION1.TPX    Todo         Undefined procedure code
  36. #!      CLARION3.TPX    Validate     Edit procedure to lookup a field
  37. #!      CLARION8.TPX    View         View a selected text file in a listbox
  38. #!      CLARION9.TPX    #GROUPs      Groups used by multiple templates
  39. #!
  40. #!------------------------------------------------------------------------------
  41. #PROGRAM
  42. #!------------------------------------------------------------------------------
  43. #!
  44. #!                           The Program Template
  45. #!
  46. #!    The Program template generates the PROGRAM statement, MAP structure,
  47. #!    FILE structures, and global declarations for a Clarion program.  This
  48. #!    template also blanks the screen and calls the first procedure.  There
  49. #!    is only one #PROGRAM segment in a template file chain.
  50. #!
  51. #!------------------------------------------------------------------------------
  52. #PROMPT('Enable &Shared Files',CHECK),%SharedFiles
  53. #PROMPT('Enable Mouse Support',CHECK),%MouseSupport
  54. #PROMPT('Enhanced Background?',CHECK),%EnhancedBackground
  55. #PROMPT('Close Unused &Files?',CHECK),%CloseFiles
  56. #PROMPT('If &File Not Found',OPTION),%FileNotFound
  57. #PROMPT('Create',RADIO)
  58. #PROMPT('Halt',RADIO)
  59. #PROMPT('Program &Author',@S30),%Author
  60. #!
  61. #IF(%SharedFiles)
  62.   #SET(%AccessMode,'42h')
  63. #ELSE
  64.   #SET(%AccessMode,'22h')
  65. #ENDIF
  66.                 TITLE('%Program')
  67. OMIT('╝')
  68. ╔════════════════════════════════════════════════════════════════════════════╗
  69. ║  Program - %Program                          #<!                           ║
  70. ║  Author  - %Author                           #<!                           ║
  71. ╚════════════════════════════════════════════════════════════════════════════╝
  72.                  PROGRAM
  73.  
  74.                  INCLUDE('KEYCODES.EQU')
  75.                  INCLUDE('CLARION.EQU')
  76.                  INCLUDE('ERRORS.EQU')
  77.  
  78.                  MAP
  79. #IF(%CloseFiles)
  80.                    CheckOpen(*FILE),BYTE
  81. #ELSE
  82.                    CheckOpen(*FILE)
  83. #ENDIF
  84.                    DiskError(<STRING>),BYTE
  85.                    ShowWarning
  86.                    %ModuleStructures
  87.                  END
  88.  
  89.                  EJECT('File Layouts')
  90.  
  91. %GlobalData
  92.  
  93. #FOR(%AppFiles)
  94.   #FIX(%File,%AppFiles)
  95. %FileStructure
  96.  
  97. #ENDFOR
  98.  
  99. AddRecord        EQUATE(1)                     #<!  Add a new record
  100. ChangeRecord     EQUATE(2)                     #<!  Change the current record
  101. DeleteRecord     EQUATE(3)                     #<!  Delete the current record
  102.  
  103. #EMBED('Data Section')
  104.  
  105.   CODE
  106.   #EMBED('Setup Program')
  107.   LOADSYMBOLS                                  #<!Display graphic mouse
  108.   #IF(%EnhancedBackground)
  109.   SETNOBLINK                                   #<!Enable enhanced colors
  110.   #ENDIF
  111.   #IF(%HelpFile)
  112.   HELP('%HelpFile')                            #<!Open the help file
  113.   #ENDIF
  114.   #IF(%StyleFile )
  115.   GETSTYLES('%StyleFile')                      #<!Open the style file
  116.   #ENDIF
  117.   #IF(%MouseSupport)
  118.   SETMOUSE(1,1)                                #<!Turn on mouse
  119.   #ENDIF
  120.   SETCOLOR(WhiteOnBlack)                       #<!Set white on black
  121.   BLANK                                        #<!Clear the screen
  122.   SETCOLOR                                     #<!Turn off override color
  123.  
  124.   %FirstProcedure                              #<!Call the first procedure
  125.  
  126.   #EMBED('Before return to DOS')
  127.   RETURN                                       #<!Return to DOS
  128.  
  129. OMIT('╝')
  130. ╔════════════════════════════════════════════════════════════════════════════╗
  131. ║  Check ERROR() function after opening a file                               ║
  132. ╚════════════════════════════════════════════════════════════════════════════╝
  133. #IF(%CloseFiles)                                #!Generate function for close
  134. CheckOpen         FUNCTION(File)
  135.  
  136.   CODE
  137.   OPEN(File,%AccessMode)                       #<!Attempt to open the file
  138.   CASE ERRORCODE()                             #<! and check for errors
  139.   OF NoError                                   #<!Return opened flag
  140.     RETURN(1)                                    ! signal successful open
  141.   OF IsOpenErr                                 #<! or if already open.
  142.     RETURN(0)
  143.   #IF(%FileNotFound <> 'Halt')
  144.   OF NoFileErr                                 #<!If file was not found
  145.     CREATE(File)                               #<!Create the file
  146.     OPEN(File,%AccessMode)                     #<! then open it
  147.     IF ~ERRORCODE() THEN RETURN(1).            #<!  And return if it opened
  148.   #ENDIF
  149.   OF InvalidFileErr                            #<!Invalid Record Declaration
  150.     GLO:Message1 = 'Error accessing: '& NAME(File)
  151.     GLO:Message2 = 'Code: ' & ERRORCODE() & ' ' & ERROR()
  152.     GLO:Message3 = 'Press OK to return to DOS'
  153.     ShowWarning
  154.     HALT(InvalidFileErr)
  155.   OF BadKeyErr                                 #<!Key Files must be rebuilt
  156.     GLO:Message1 = NAME(File) & ' Key file is invalid'
  157.     GLO:Message3 = 'Press OK to rebuild keyfile'
  158.     ShowWarning
  159.     OPEN(File,12H)                               !Open for exclusive access
  160.     BUILD(File)                                  !Rebuild the key files
  161.     IF ERRORCODE()
  162.       GLO:Message1 = NAME(File) & ' The file cannot be repaired'
  163.       GLO:Message2 = 'while other stations are using it'
  164.       GLO:Message3 = 'Press OK to return to DOS'
  165.       ShowWarning
  166.       HALT(BadKeyErr)
  167.     ELSE
  168.       CLOSE(File)                                !Close
  169.       OPEN(File,%AccessMode)                   #<! then re-open it
  170.       RETURN(1)                                  ! signal successful open
  171.     END
  172.   END                                          #<!End of Case Structure
  173.   IF DiskError(NAME(File) & ' File could not be opened') THEN HALT(0). #<!Cannot resume
  174. #ELSE                                           #!Generate procedure
  175. CheckOpen         PROCEDURE(File)
  176.  
  177.   CODE
  178.   OPEN(File,%AccessMode)                       #<!Attempt to open the file
  179.   CASE ERRORCODE()                             #<! and check for errors
  180.   OF NoError                                   #<!Return if no error
  181.   OROF IsOpenErr                               #<! or if already open.
  182.     RETURN
  183.   #IF(%FileNotFound <> 'Halt')
  184.   OF NoFileErr                                 #<!If file was not found
  185.     CREATE(File)                               #<!Create the file
  186.     OPEN(File,%AccessMode)                     #<! then open it
  187.     IF ~ERRORCODE() THEN RETURN.               #<!  And return if it opened
  188.   #ENDIF
  189.   OF InvalidFileErr                            #<!Invalid Record Declaration
  190.     GLO:Message1 = 'Error accessing: '& NAME(File)
  191.     GLO:Message2 = 'Code: ' & ERRORCODE() & ' ' & ERROR()
  192.     GLO:Message3 = 'Press OK to return to DOS'
  193.     ShowWarning
  194.     HALT(InvalidFileErr)
  195.   OF BadKeyErr                                 #<!Key Files must be rebuilt
  196.     GLO:Message1 = NAME(File) & ' Key file is invalid'
  197.     GLO:Message3 = 'Press OK to rebuild keyfile'
  198.     ShowWarning
  199.     OPEN(File,12H)                             #<!Open for exclusive access
  200.     BUILD(File)                                #<!Rebuild the key files
  201.     IF ERRORCODE()
  202.       GLO:Message1 = NAME(File) & ' The file cannot be repaired'
  203.       GLO:Message2 = 'while other stations are using it'
  204.       GLO:Message3 = 'Press OK to return to DOS'
  205.       ShowWarning
  206.       HALT(BadKeyErr)
  207.     ELSE
  208.       CLOSE(File)                              #<!Close
  209.       OPEN(File,%AccessMode)                   #<! then open it
  210.     END
  211.   END                                          #<!End of Case Structure
  212.   IF DiskError(NAME(File) & ' File could not be opened') THEN HALT(0). #<!Cannot resume
  213. #ENDIF
  214.  
  215. OMIT('╝')
  216. ╔════════════════════════════════════════════════════════════════════════════╗
  217. ║  Check ERROR() function after a disk access                                ║
  218. ╚════════════════════════════════════════════════════════════════════════════╝
  219. DiskError        FUNCTION(Cause)
  220. StopMsg::        STRING(180)
  221.  
  222.   CODE
  223.   IF ~ERRORCODE() THEN RETURN(0).              #<!Return with no error
  224.   IF ~OMITTED(1)                               #<!If a cause was given
  225.     StopMsg:: = 'Cause: ' & Cause & LF:CR      #<!  Display it
  226.   END                                          #<!End IF
  227.   IF ERRORFILE()                               #<!If error involves a file
  228.     StopMsg:: = CLIP(StopMsg::) & 'File : '  | #<!  display the file
  229.               & ERRORFILE() & LF:CR
  230.   END                                          #<!End IF
  231.   StopMsg:: = CLIP(StopMsg::) & 'Error: '    | #<!Display the error code
  232.             & ERRORCODE() & ' - '            | #<!  and the error message
  233.             & ERROR() & LF:CR
  234.  
  235.   STOP(StopMsg::)                              #<!Stop with message
  236.   RETURN(1)                                    #<!Return with error
  237.  
  238. OMIT('╝')
  239. ╔════════════════════════════════════════════════════════════════════════════╗
  240. ║  Display a warning message using 3 Global message variables.               ║
  241. ╚════════════════════════════════════════════════════════════════════════════╝
  242. ShowWarning      PROCEDURE
  243.  
  244. SaveStyle        STRING(256)
  245.  
  246. Screen           SCREEN(9,53),PRE(SCR),CENTER,SHADOW,CUA,COLOR(112)
  247.                    ROW(1,1)    STRING('█▀{51}█'),COLOR(116)
  248.                    ROW(9,1)    STRING('█▄{51}█'),COLOR(116)
  249.                                REPEAT(7)
  250.                    ROW(2,1)      STRING('█'),COLOR(116)
  251.                    ROW(2,53)     STRING('█'),COLOR(116)
  252.                                .
  253.                    ROW(3,5)    ENTRY(@S45),USE(GLO:Message1),INS,SKIP,COLOR(112,112,112)
  254.                    ROW(4,5)    ENTRY(@S45),USE(GLO:Message2),INS,SKIP,COLOR(112,112,112)
  255.                    ROW(5,5)    ENTRY(@s45),USE(GLO:Message3),INS,SKIP,COLOR(112,112,112)
  256.                    ROW(7,24)   BUTTON('  &Ok  |'),SHADOW,USE(?Ok),COLOR(23,71,24,31,79)
  257.                  .
  258.  
  259.   CODE
  260.   SaveStyle = STYLES()                         #<!Save current style
  261.   GETSTYLES('')                                #<!Turn off Styles
  262.   GLO:Message1 = CENTER(GLO:Message1,SIZE(GLO:Message1))
  263.   GLO:Message2 = CENTER(GLO:Message2,SIZE(GLO:Message2))
  264.   GLO:Message3 = CENTER(GLO:Message3,SIZE(GLO:Message3))
  265.   OPEN(Screen)
  266.   DISPLAY
  267.   ACCEPT                                       #<!Enable keyboard and mouse
  268.   CLEAR(GLO:MessageGroup)                      #<!Blank out message fields
  269.   SETSTYLES(SaveStyle)                         #<!Restore user styles
  270.   RETURN
  271.  
  272. #!
  273. #MODULE
  274. #!------------------------------------------------------------------------------
  275. #!
  276. #!                            The Module Template
  277. #!
  278. #!    The Module template generates the MEMBER statement, and module
  279. #!    level data declarations for a source module of a Clarion program.
  280. #!    There is only one #MODULE segment in a template file chain.
  281. #!
  282. #!------------------------------------------------------------------------------
  283.                 MEMBER('%Program')
  284. OMIT('╝')
  285. ╔════════════════════════════════════════════════════════════════════════════╗
  286. ║   %Module - %ModuleDescription               #<!                           ║
  287. ╚════════════════════════════════════════════════════════════════════════════╝
  288. %ModuleData
  289. #EMBED('Data Section')
  290. #!
  291. #CHAIN('CLARION1.TPX')
  292.