home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR9 / VARFIL.ZIP / VARFIL01.CLA < prev    next >
Text File  |  1993-06-24  |  22KB  |  428 lines

  1.                 MEMBER('VARFILES')
  2. OMIT('╝')
  3. ╔════════════════════════════════════════════════════════════════════════════╗
  4. ║   VARFIL01.CLA - Internal Source Module        !                           ║
  5. ╚════════════════════════════════════════════════════════════════════════════╝
  6.  
  7. OMIT('╝')
  8. ╔════════════════════════════════════════════════════════════════════════════╗
  9. ║ Mainmenu -                                     !Generated Procedure        ║
  10. ╚════════════════════════════════════════════════════════════════════════════╝
  11.  
  12. Mainmenu      PROCEDURE
  13.  
  14.  
  15. SCREEN           SCREEN(17,38),PRE(SCR),CENTER,SHADOW,ZOOM,CUA,COLOR(112)
  16.                    !dimensions=25,80,25,80
  17.                    ROW(1,1)    STRING('█▀{36}█'),COLOR(113)
  18.                    ROW(17,1)   STRING('█▄{36}█'),COLOR(113)
  19.                                REPEAT(15)
  20.                    ROW(2,1)      STRING('█'),COLOR(113)
  21.                    ROW(2,38)     STRING('█'),COLOR(113)
  22.                                .
  23.                    ROW(6,12)   BUTTON(' &View Rolodex '),SHADOW,USE(?View_Rolodex),COLOR(23,71,24,31,79)
  24.                    ROW(9,10)   BUTTON(' &Select User File '),SHADOW,USE(?Select_User_File),COLOR(23,71,24,31,79)
  25.                    ROW(15,16)  BUTTON('  E&xit  |'),SHADOW,USE(?Exit),COLOR(23,71,24,31,79)
  26.                  .
  27.  
  28.  EMBED('~~Mainmenu~1~Data Section~1~~')
  29. opening          SCREEN(25,80),PRE(ope),CENTER,FADE,CUA,COLOR(113)
  30.                    !dimensions=25,80,25,80
  31.                  .
  32.  
  33.  ENDEMBED
  34.  
  35.  
  36.   CODE
  37.   EMBED('~~Mainmenu~1~Setup Procedure~3~~')
  38.   Open(Opening)
  39.    
  40.   loop
  41.      If Glo:RoloFile <> '' then Break.
  42.      GetUser
  43.   .
  44.   ENDEMBED
  45.  
  46.   OPEN(Screen)                                   !Open the screen
  47.   LOOP                                           !Loop through screen fields
  48.     DISPLAY
  49.     CASE SELECTED()                              !Jump to field setup routine
  50.     END                                          !End CASE
  51.     ACCEPT                                       !Enable mouse and keyboard
  52.  
  53.     CASE KEYCODE()
  54.     END
  55.  
  56.     CASE FIELD()                                 !Jump to field edit routine
  57.       OF ?View_Rolodex                           !Edit  field
  58.         BrowseRolo
  59.       OF ?Select_User_File                       !Edit  field
  60.         GetUser
  61.       OF ?Exit                                   !Edit  field
  62.         RETURN
  63.     END                                          !End CASE
  64.   END                                            !End LOOP
  65. OMIT('╝')
  66. ╔════════════════════════════════════════════════════════════════════════════╗
  67. ║ GetUser -                                      !Generated Procedure        ║
  68. ╚════════════════════════════════════════════════════════════════════════════╝
  69.  
  70. GetUser       PROCEDURE
  71.  
  72. Queue            QUEUE
  73.                    STRING(40)
  74.                  END
  75.  
  76. ButtonIsDisabled BYTE                            !Flag to allow button enable
  77.  
  78.  
  79. SCREEN           SCREEN(25,46),PRE(SCR),CUA,COLOR(112)
  80.                    !dimensions=25,80,25,80
  81.                    ROW(1,1)    STRING('█▀{44}█'),COLOR(113)
  82.                    ROW(3,7)    STRING('Select A User from the List Below'),COLOR(113)
  83.                    ROW(25,1)   STRING('█▄{44}█'),COLOR(113)
  84.                                REPEAT(23)
  85.                    ROW(2,1)      STRING('█'),COLOR(113)
  86.                    ROW(2,46)     STRING('█'),COLOR(113)
  87.                                .
  88.                    ROW(6,16)   LIST(10,16),FROM(Queue),USE(?List),IMM,COLOR(48,15,120)
  89.                    ROW(20,8)   BUTTON(' &Insert |'),SHADOW,KEY(InsKey),USE(?Insert),COLOR(23,71,24,31,79)
  90.                      COL(19)   BUTTON(' &Change |'),SHADOW,USE(?Change),COLOR(23,71,24,31,79)
  91.                      COL(30)   BUTTON(' &Delete |'),SHADOW,KEY(DelKey),USE(?Delete),COLOR(23,71,24,31,79)
  92.                    ROW(23,13)  BUTTON(' &Select |'),SHADOW,KEY(EnterKey),USE(?Select),COLOR(23,71,24,31,79)
  93.                      COL(26)   BUTTON(' &Cancel |'),SHADOW,KEY(EscKey),USE(?Cancel),COLOR(23,71,24,31,79)
  94.                  .
  95.  
  96.  
  97.   CODE
  98.   CheckOpen(Users)                               !Ensure Users file is open
  99.   OPEN(Screen)                                   !Open the screen
  100.   BeginBrowse(?List)                             !Begin a browse session
  101.   LOOP                                           !Process browse requests
  102.     CASE BrowseAction(Users,Use:UserKey,Queue)   !Browse the file
  103.  
  104.     OF FormatQueue                               !Format a QUEUE element
  105.       Queue = '  ' & FORMAT(Use:Username,@s12)             !Format the QUEUE line
  106.  
  107.     OF ProcessField                              !Process a field
  108.       CASE FIELD()                               !Jump to edit routine
  109.       OF ?List                                   !Process the list field
  110.         CASE KEYCODE()                           !Jump to keycode routine
  111.         OF InsKey                                !For the insert key
  112.           GET(Users,0)                           !Dereference current record
  113.           Do UpdateProcedure                     ! Call the update procedure
  114.         OF CtrlEnter                             !Or the Ctrl-Enter key
  115.           Do UpdateProcedure                     ! Call the update procedure
  116.         OF MouseLeft2                            !On mouse double click
  117.         OROF EnterKey                            !or the enter key
  118.           SELECT(?Select)                        ! Select the Select button
  119.           PRESS(EnterKey)                        ! And complete it.
  120.         END                                      !End CASE
  121.       OF ?Insert                                 !Process the Insert Button
  122.         GET(Users,0)
  123.         SETKEYCODE(InsKey)                       !Set action to Insert
  124.         Do UpdateProcedure                       ! Call the update procedure
  125.         SELECT(?List)                            !Reselect the List field
  126.  
  127.       OF ?Change                                 !Process the Change Button
  128.         SETKEYCODE(EnterKey)                     !Set action to Change
  129.         Do UpdateProcedure                       ! Call the update procedure
  130.         SELECT(?List)                            !Reselect the List field
  131.  
  132.       OF ?Select                                 !Process the Select button
  133.         EMBED('~~GetUser~4~5~9~~')
  134.         Glo:RoloFile = Use:FileName
  135.         ENDEMBED                                 !Select button Edit Routine
  136.         BREAK
  137.  
  138.       OF ?Cancel                                 !Process the Select button
  139.         BREAK
  140.       END                                        !End CASE FIELD()
  141.  
  142.     OF NoRecords                                 !No records to browse
  143.       DISPLAY
  144.       DISABLE(?Change)                           ! Disable the change button
  145.       DISABLE(?Delete)                           ! Disable the delete button
  146.       ButtonIsDisabled = TRUE
  147.       IF RECORDS(Users)                          !If file is not empty
  148.         IF ?List <> 1                            !  And list is not first
  149.           SELECT(1)                              !    Select the first field
  150.         ELSE                                     !  From the first field
  151.           SELECT(?Insert)                        !   Select the Insert Button
  152.         END                                      !  End IF
  153.       ELSE                                       !If file is empty
  154.         GET(Users,0)                             !  Dereference current record
  155.         SETKEYCODE(InsKey)                       !  Ask for a new record
  156.         Do UpdateProcedure                       ! Call the update procedure
  157.         IF RECORDS(Users) = 0                    !  If a record was not added
  158.           BREAK
  159.         END                                      !  End IF
  160.       END                                        !End IF
  161.  
  162.     END                                          !End CASE
  163.   END                                            !End LOOP
  164.   EndBrowse                                      !End the browse session
  165.   FREE(Queue)                                    !Free the Queue memory
  166.  
  167. UpdateProcedure  ROUTINE
  168.   UpdateUser
  169. OMIT('╝')
  170. ╔════════════════════════════════════════════════════════════════════════════╗
  171. ║ UpdateUser -                                   !Generated Procedure        ║
  172. ╚════════════════════════════════════════════════════════════════════════════╝
  173. UpdateUser      PROCEDURE
  174.  
  175. LOC:Message      STRING(30)
  176. Action           BYTE
  177. NoMoreFields     BYTE(0)                         !No more fields flag
  178. SCREEN           SCREEN(13,58),PRE(SCR),SHADOW,FALL,CUA,COLOR(112)
  179.                    !dimensions=25,80,25,80
  180.                    ROW(1,1)    STRING('█▀{56}█'),COLOR(116)
  181.                    ROW(13,1)   STRING('█▄{56}█'),COLOR(116)
  182.                                REPEAT(11)
  183.                    ROW(2,1)      STRING('█'),COLOR(116)
  184.                    ROW(2,58)     STRING('█'),COLOR(116)
  185.                                .
  186.                    ROW(2,17)   ENTRY(@s30),USE(LOC:Message),SKIP,COLOR(126,7,120)
  187.                    ROW(5,7)    PROMPT('User Name:'),COLOR(113,116,120,127,127)
  188.                      COL(18)   ENTRY(@s12),USE(Use:Username),REQ,OVR,COLOR(126,7,120)
  189.                    ROW(7,7)    PROMPT('File Name:'),COLOR(113,116,120,127,127)
  190.                      COL(18)   ENTRY(@s35),USE(Use:FileName),REQ,OVR,COLOR(126,7,120)
  191.                    ROW(10,15)  BUTTON('  &Ok  |'),SHADOW,KEY(EnterKey),USE(?Ok),REQ,COLOR(23,71,24,31,79)
  192.                      COL(35)   BUTTON('  &Cancel  '),SHADOW,KEY(EscKey),USE(?Cancel),COLOR(23,71,24,31,79)
  193.                  .
  194.  
  195. SavePointer   STRING(10)                         !Position of current record
  196. AutoAddPtr    STRING(10)                         !Position of Autoinc record
  197. AutoIncAdd    BYTE(0)                            !On for Autoincrement add
  198.  
  199.   CODE
  200.  
  201.   CheckOpen(Users)                               !Ensure Primary file is OPEN
  202.   CASE KEYCODE()                                 !What Key was pressed?
  203.     OF InsKey                                    !Insert a new record
  204.  
  205.       Action = AddRecord                         !Set action code 1 (ADD)
  206.       LOC:Message = CENTER(GLO:InsertMsg,SIZE(LOC:Message)) !Assign ADD message
  207.       CLEAR(Use:Record)                          !CLEAR Record buffer
  208.  
  209.     OF EnterKey                                  !Process a CHANGE request
  210.     OROF MouseLeft2                              !on EnterKey or double mouse
  211.  
  212.       Action = ChangeRecord                      !Set action code 2 (CHANGE)
  213.       LOC:Message = CENTER(GLO:ChangeMsg,SIZE(LOC:Message)) !Assign CHANGE message
  214.  
  215.     OF DelKey                                    !Process a DELETE request
  216.  
  217.       Action = DeleteRecord                      !Set action code 3 (DELETE)
  218.       LOC:Message = CENTER(GLO:DeleteMsg,SIZE(LOC:Message)) !Assign DELETE message
  219.       SavePointer = POSITION(Users)              !Position in PRIMARY file
  220.  
  221.   END                                            !End CASE Keycode
  222.  
  223.   OPEN(Screen)                                   !Open the FORM screen
  224.   IF Action = DeleteRecord                       !IF request for DELETE
  225.     DISABLE(1,FIELDS())                          !Disable all screen fields
  226.     ENABLE(?OK)                                  !Enable the OK and the
  227.     ENABLE(?Cancel)                              !Cancel buttons
  228.   END                                            !End IF request for delete
  229.   DISPLAY                                        !Display screen fields
  230.  
  231.   LOOP                                           !Begin Main process loop
  232.  
  233.     CASE SELECTED()                              !Process selected Field
  234.       OF NoMoreFields                            !User pressed Enter or OK
  235.         CASE Action                              !Process requested Action
  236.           OF AddRecord                           !Action = 1 (ADD)
  237.  
  238.             ADD(Users)                           !Add Record to Primary file
  239.  
  240.           OF ChangeRecord                        !Action = 2 (Change)
  241.  
  242.             PUT(Users)                           !Write the Record
  243.  
  244.           OF DeleteRecord                        !Action = 3 (Delete)
  245.  
  246.             DELETE(Users)                     !Delete this record
  247.         END                                      !End CASE Action
  248.  
  249.       IF ERRORCODE()                             !Error check on File I/O
  250.         IF ERRORCODE() = DupKeyErr               ! Duplicate key detected
  251.           IF DUPLICATE(Use:UserKey)              !check unique keys
  252.             GLO:Message3 = '[ '
  253.             GLO:Message3 = Clip(GLO:Message3) & (' Use:Username ')
  254.             GLO:Message3 = Clip(GLO:Message3)&' ]'
  255.           END
  256.           GLO:Message1 = 'This record creates a duplicate key entry'
  257.           GLO:Message2 = 'The unique key field(s) are listed below: '
  258.           ShowWarning                            !inform the user
  259.           SELECT(1)                              !select first field
  260.           DISPLAY                                !re-display the screen
  261.           CYCLE                                  !back to main loop
  262.         END                                      !End IF Duplicate errorcode
  263.         CASE Action                              !Error message based on Action
  264.           OF AddRecord
  265.             GLO:Message1 = 'Error attempting to ADD Record'
  266.           OF ChangeRecord
  267.             GLO:Message1 = 'Error attempting to CHANGE Record'
  268.           OF DeleteRecord
  269.             GLO:Message1 = 'Error attempting to DELETE Record'
  270.         END                                      !End CASE Action
  271.         GLO:Message2 = 'The file: Users could not be updated'
  272.         GLO:Message3 = 'Code:'&Errorcode()&': '&Error()
  273.         ShowWarning                              !Notify the user
  274.         DISABLE(1,FIELDS())                      !Disable all the fields
  275.         ENABLE(?Cancel)                          !Enable Cancel button
  276.         SELECT(?Cancel)                          !and place cursor on Cancel
  277.         DISPLAY                                  !Re-display the screen
  278.         CYCLE                                    !Re-start main LOOP
  279.       ELSE                                       !Else no errorcode()
  280.         BREAK                                    !Break from main Loop
  281.       END                                        !End IF Errorcode()
  282.  
  283.     END                                          !End CASE Selected()
  284.  
  285.     ACCEPT                                       !Enable screen entry
  286.  
  287.     CASE FIELD()                                 !Process fields
  288.       OF ?Ok                                     !On the OK button
  289.  
  290.         SELECT(1)                                !Start with the first field
  291.         SELECT                                   !and cycle non-stop
  292.         CYCLE                                    !restart main process loop
  293.  
  294.       OF ?Cancel                                 !On Cancel button
  295.  
  296.         BREAK                                    !Break from main LOOP
  297.     END                                          !End CASE FIELD
  298.  
  299.   END                                            !END MAIN PROCESS LOOP
  300.  
  301.  
  302.  
  303. OMIT('╝')
  304. ╔════════════════════════════════════════════════════════════════════════════╗
  305. ║ BrowseRolo -                                   !Generated Procedure        ║
  306. ╚════════════════════════════════════════════════════════════════════════════╝
  307. BrowseRolo       PROCEDURE
  308.  
  309.  
  310. Queue            QUEUE
  311.                    STRING(74)
  312.                  .
  313.  
  314. ButtonIsDisabled BYTE                            !Flag to allow button enable
  315.  
  316.  
  317. SCREEN           SCREEN(19,74),PRE(SCR),CENTER,EXPAND(10),ZOOM,CUA,COLOR(112)
  318.                    !dimensions=25,80,25,80
  319.                    ROW(1,1)    STRING('█▀{72}█'),COLOR(113)
  320.                    ROW(2,22)   STRING('Rolodex List For :')
  321.                    ROW(19,1)   STRING('█▄{72}█'),COLOR(113)
  322.                                REPEAT(17)
  323.                    ROW(2,1)      STRING('█'),COLOR(113)
  324.                    ROW(2,74)     STRING('█'),COLOR(113)
  325.                                .
  326.                    ROW(5,9)    LIST(10,58),FROM(Queue),USE(?List),IMM,COLOR(48,15,120)
  327.                    ROW(2,41)   ENTRY(@s12),USE(Use:Username),REQ,OVR,SKIP,COLOR(126,7,120)
  328.                    ROW(17,8)   BUTTON('  &Insert  |'),SHADOW,USE(?Insert),COLOR(23,71,24,31,79)
  329.                      COL(22)   BUTTON('  &Change  |'),SHADOW,USE(?Change),COLOR(23,71,24,31,79)
  330.                      COL(36)   BUTTON('  &Delete  |'),SHADOW,USE(?Delete),COLOR(23,71,24,31,79)
  331.                      COL(60)   BUTTON('  E&xit  |'),SHADOW,KEY(EscKey),USE(?Exit),COLOR(23,71,24,31,79)
  332.                  .
  333.  
  334.  
  335.   CODE
  336.   CheckOpen(Rolodex)                             !Ensure Rolodex file is open
  337.   FREE(Queue)                                    !Make sure Queue is empty
  338.   OPEN(Screen)                                   !Open the screen
  339.   EMBED('~~BrowseRolo~1~Setup Screen~3~~')
  340.   Display(?use:username)
  341.   ENDEMBED
  342.  
  343.   BeginBrowse(?List)                             !Begin a browse session
  344.   LOOP                                           !Process browse requests
  345.     CASE BrowseAction(Rolodex,Rol:NameKey,Queue) !Browse the file
  346.  
  347.     OF FormatQueue                               !Format a queue element
  348.       Queue = '  ' & FORMAT(Rol:FirstName,@s15) & |
  349.               '   ' & FORMAT(Rol:Lastname,@s20) & |
  350.               '   ' & FORMAT(Rol:PhoneNumber,@P### ###-####P) !Format the listbox queue
  351.  
  352.     OF ProcessField                              !Process a field
  353.       IF SELECTED() <> FIELD()                   ! If a new field is selected
  354.         CASE SELECTED()                          ! Jump to setup routine
  355.         END                                      ! End CASE SELECTED()
  356.       END                                        ! End IF
  357.       CASE FIELD()                               !Jump to edit routine
  358.  
  359.       OF ?List                                   !Process the list field
  360.         CASE KEYCODE()                           ! Jump to keycode routine
  361.         OF InsKey                                ! For the insert key
  362.           GET(Rolodex,0)                         !  Dereference current record
  363.           DO UpdateProcedure                     !  Call the update procedure
  364.         OF DelKey                                ! For the delete key
  365.           DO UpdateProcedure                     !  Call the update procedure
  366.         OF EnterKey                              ! Or the enter key
  367.         OROF MouseLeft2                          ! Or a double mouse click
  368.           DO UpdateProcedure                     !  Call the update procedure
  369.         END                                      ! End CASE
  370.  
  371.        OF ?Insert                                !Process the Insert Button
  372.         GET(Rolodex,0)                           ! Dereference current record
  373.         SETKEYCODE(InsKey)                       ! Set action to Insert
  374.         Do UpdateProcedure                       ! Call the update procedure
  375.         SELECT(?List)                            ! Reselect the List field
  376.  
  377.       OF ?Change                                 !Process the Change Button
  378.         SETKEYCODE(EnterKey)                     ! Set action to Change
  379.         Do UpdateProcedure                       ! Call the update procedure
  380.         SELECT(?List)                            ! Reselect the List field
  381.  
  382.       OF ?Delete                                 !Process the Delete Button
  383.         SETKEYCODE(DelKey)                       ! Set action to Delete
  384.         DO UpdateProcedure                       ! Call the update procedure
  385.         SELECT(?List)                            ! Reselect the List field
  386.  
  387.       OF ?Exit                                   !Process the Exit button
  388.         BREAK                                    ! Return to caller
  389.  
  390.       END                                        !End CASE FIELD()
  391.  
  392.     OF NoRecords                                 !No records to browse
  393.       DISPLAY
  394.       DISABLE(?Change)                           ! Disable the change button
  395.       DISABLE(?Delete)                           ! Disable the delete button
  396.       ButtonIsDisabled = TRUE
  397.       IF RECORDS(Rolodex)                        ! If file is not empty
  398.         IF ?List <> 1                            !  And list is not first
  399.           SELECT(1)                              !   Select the first field
  400.         ELSE                                     !  Else
  401.           SELECT(?Insert)                        !   Select the Insert Button
  402.         END                                      !  End IF
  403.       ELSE                                       ! Else if file is empty
  404.         GET(Rolodex,0)                           !  Dereference current record
  405.         SETKEYCODE(InsKey)                       !  Ask for a new record
  406.         DO UpdateProcedure                       !  Call the update procedure
  407.           IF POSITION(Rol:NameKey) = ''          !   If record not added
  408.             BREAK                                !    Return to caller
  409.           ELSE                                   !   Else record was added
  410.             ENABLE(?Change)                      !   Disable the change button
  411.             ENABLE(?Delete)                      !   Disable the delete button
  412.             ButtonIsDisabled = FALSE
  413.           END                                    !   End IF
  414.       END                                        ! End IF
  415.  
  416.     END                                          ! End CASE
  417.   END                                            !End LOOP
  418.   EndBrowse                                      !End the browse session
  419.   FREE(Queue)                                    !Free the Queue memory
  420.  EMBED('~~BrowseRolo~1~End of Procedure~1~~')
  421.       Close(Rolodex)
  422.  ENDEMBED
  423.  
  424.  
  425. UpdateProcedure ROUTINE
  426.   UpdateRolo
  427.  
  428.