Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 12.41 KB | None | 0 0
  1. * TWH JLU Record Filing Program v0.0.1a
  2. * Description: This program is for entering and displaying data to/from a file on JLU members.
  3. * Last Updated: 01/20/2011
  4.  
  5.  
  6. *23456789       - column numbers
  7.  
  8.       IDENTIFICATION DIVISION.
  9.       PROGRAM-ID.       JLU-Record-Filing.
  10.       AUTHOR.           Dick Stallman.
  11.      
  12.      
  13.      
  14.       ENVIRONMENT DIVISION.
  15.      
  16.       INPUT-OUTPUT SECTION.  
  17.       FILE-CONTROL.
  18.         SELECT Member-File ASSIGN TO "JLURecord.dat" ORGANIZATION IS SEQUENTIAL.
  19.        
  20.         SELECT Online-File ASSIGN TO "JLUOnline.dat" ORGANIZATION IS SEQUENTIAL.
  21.      
  22.      
  23.      
  24.      
  25.      
  26.       DATA DIVISION.
  27.      
  28.       FILE SECTION.
  29.      
  30.         *> Member file
  31.         FD Member-File.         *> File Descriptor
  32.        
  33.         01 JLU-Member-Database.
  34.             02 Number-Of-Records        PIC 999 USAGE IS BINARY.        *> Number of records to enter
  35.            
  36.             02 Current-User-Number          PIC 999 USAGE IS BINARY VALUE 0.            *> The current user record being entered/displayed
  37.            
  38.             02 JLU-Member-Record.
  39.                
  40.                 03 User-Num         PIC 999 USAGE IS BINARY VALUE 0.        *> Unique number for the current record in the table
  41.                
  42.  
  43.                 03 Second-Life-Data.
  44.                     04 SL-UUID          PIC X(36) VALUE "00000000-0000-0000-0000-000000000000".
  45.                    
  46.                     04 SL-First-Name        PIC X(31).
  47.                     04 SL-Last-Name     PIC X(31).
  48.                    
  49.                     04 SL-Birth-Date        PIC X(10) VALUE "00-00-0000".
  50.                    
  51.                     04 SL-Rank          PIC X(25).          *> Position of power
  52.                    
  53.                     04 SL-Partner.
  54.                         05 SL-Partner-First-Name        PIC X(31).
  55.                         05 SL-Partner-Last-Name     PIC X(31).
  56.            
  57.            
  58.            
  59.                
  60.                 03 Real-Life-Data.
  61.                     04 RL-First-Name        PIC A(20).
  62.                     04 RL-Last-Name     PIC A(20).
  63.                    
  64.                     04 RL-Age           PIC 999.
  65.                    
  66.                     04 RL-Gender        PIC X.
  67.                    
  68.                     04 RL-Birth-Date        PIC X(10) VALUE "00-00-0000".
  69.                    
  70.                     04 RL-Occupation        PIC X(25).
  71.                    
  72.                     04 RL-Location.
  73.                         05 Country      PIC X(20).
  74.                         05 State-Prov       PIC X(20).
  75.                         05 ZIP-Postal       PIC X(6).       *> Zip or Postal code
  76.                         05 Street-Address   PIC X(20).
  77.                
  78.        
  79.        
  80.        
  81.        
  82.        
  83.        
  84.         *> Online File
  85.         FD Online-File.
  86.        
  87.         01 Online-Record.               *> Record used for storing online status data
  88.             02 Number-Of-Entries    PIC 999 USAGE IS BINARY.
  89.            
  90.             02 Current-Entry-Number     PIC 999 USAGE IS BINARY VALUE 0.
  91.            
  92.             02 Online-First-Name    PIC X(20).
  93.             02 Online-Last-Name     PIC X(20).
  94.                
  95.             02 Online-Entry.
  96.                     03 Date-Logged          PIC X(10) VALUE "00-00-0000".
  97.                     03 Hours-Online     PIC 999.
  98.        
  99.        
  100.        
  101.        
  102. * Normal fields
  103.         WORKING-STORAGE SECTION.
  104.        
  105.         01 Cmd              PIC X.          *> The variable to store command input
  106.        
  107.         01 EOF-Flag         PIC 9 VALUE 0.      *> End of file flag (0 = falae, 1 = true)
  108.             88 NOT-EOF      VALUE 0.
  109.             88 EOF          VALUE 1.
  110.        
  111.                
  112.                    
  113.                
  114.        
  115.        
  116.        
  117.                
  118.  
  119.  
  120.  
  121. * -------------------------------------------------------------------
  122. * MAIN SUBROUTINE
  123. * -------------------------------------------------------------------    
  124.  
  125.      
  126.       PROCEDURE DIVISION.
  127.      
  128.      
  129.         *> Two carriage returns before displaying anything
  130.         DISPLAY "".
  131.         DISPLAY "".
  132.      
  133.      
  134.         PERFORM InputCmd.           *> Ask for input
  135.        
  136.        
  137.         *> DISPLAY UUID OF Second-Life-Data OF JLU-Member-Record(1).
  138.        
  139.         STOP RUN.
  140.        
  141.        
  142.        
  143. * END OF PROGRAM
  144.        
  145.        
  146. * ------------------------------------------------------------------
  147. * SUB-ROUTINES
  148. * ------------------------------------------------------------------
  149.        
  150.       *> InputCmd will ask for a one character long input that performs different commands
  151.       InputCmd.
  152.        
  153.             DISPLAY "Input command: " WITH NO ADVANCING.
  154.             ACCEPT Cmd.
  155.        
  156.             IF Cmd = "i" OR "I"     *> Command for entering records
  157.            
  158.            
  159.                 *> Select which table to enter data in
  160.                 DISPLAY "Select file: ('m' for Member file, 'o' for Online Status file): " WITH NO ADVANCING
  161.                 ACCEPT Cmd
  162.                
  163.                 DISPLAY ""
  164.                
  165.                 IF Cmd = "m" OR "M"         *> Member Table
  166.                     PERFORM EnterMemberRecords
  167.                 ELSE
  168.                     IF Cmd = "o" OR "O"     *> Online Status Table
  169.                         PERFORM EnterOnlineRecords
  170.                     END-IF
  171.                    
  172.                 END-IF
  173.                
  174.                
  175.             ELSE
  176.            
  177.                 IF Cmd = "d" OR "D"     *> Command for displaying records
  178.                     PERFORM DisplayRecords
  179.                 END-IF
  180.                
  181.                 IF Cmd = "x" OR "X"     *> Command for exiting the program
  182.                     DISPLAY "Exiting..."
  183.                     STOP RUN
  184.                 END-IF
  185.                
  186.                 IF Cmd = "h" OR "H"     *> Command for help
  187.                     DISPLAY "Type in 'i' for entering data, type 'd' for displaying data."
  188.                 END-IF
  189.                
  190.             END-IF.
  191.        
  192.        EXIT.
  193.            
  194.            
  195.            
  196.            
  197.        
  198.        
  199.        
  200.       *> EnterRecordS will ask all data required for entering a record
  201.       EnterMemberRecords.    
  202.             DISPLAY "Enter number of records: " WITH NO ADVANCING.         
  203.             ACCEPT Number-Of-Records OF JLU-Member-Database.
  204.            
  205.             IF Number-Of-Records OF JLU-Member-Database = 0
  206.                 DISPLAY "No records to enter, exiting..."
  207.                 EXIT
  208.             .
  209.            
  210.             OPEN EXTEND Member-File.
  211.            
  212.             DISPLAY "Entering " Number-Of-Records " records...".
  213.            
  214.             PERFORM Number-Of-Records TIMES
  215.                
  216.                 ADD 1 TO Current-User-Number
  217.                
  218.                 MOVE Current-User-Number TO User-Num
  219.                
  220.                
  221.                 *> SECOND LIFE DATA
  222.                
  223.                
  224.                 *> Avatar UUID
  225.                 DISPLAY "Entry #" Current-User-Number " -- Enter Second Life Avatar UUID: " WITH NO ADVANCING
  226.                 ACCEPT SL-UUID
  227.                
  228.                 *> SL First Name
  229.                 DISPLAY "Entry #" Current-User-Number " -- Enter Second Life First Name: " WITH NO ADVANCING
  230.                 ACCEPT SL-First-Name
  231.                
  232.                 *> SL Last Name
  233.                 DISPLAY "Entry #" Current-User-Number " -- Enter Second Life Last Name: " WITH NO ADVANCING
  234.                 ACCEPT SL-Last-Name
  235.                
  236.                 *> SL Birthdate
  237.                 DISPLAY "Entry #" Current-User-Number " -- Enter Second Life Birthdate (Format: xx-xx-xxxx): " WITH NO ADVANCING
  238.                 ACCEPT SL-Birth-Date
  239.                
  240.                 *> SL Rank
  241.                 DISPLAY "Entry #" Current-User-Number " -- Enter Second Life Rank: " WITH NO ADVANCING
  242.                 ACCEPT SL-Rank
  243.                                
  244.                 *> SL Partner
  245.                 DISPLAY "-- Do they have a Second Life Partner? (y/n): " WITH NO ADVANCING
  246.                 ACCEPT Cmd
  247.                
  248.                
  249.                 IF Cmd = "y" OR "Y"
  250.                     DISPLAY "Entry #" Current-User-Number " -- Second Life Partner First Name: " WITH NO ADVANCING
  251.                     ACCEPT SL-Partner-First-Name
  252.                    
  253.                     DISPLAY "Entry #" Current-User-Number " -- Second Life Partner Last Name: " WITH NO ADVANCING
  254.                     ACCEPT SL-Partner-Last-Name
  255.                    
  256.                 END-IF
  257.                
  258.                
  259.                
  260.                
  261.                
  262.                 *> REAL LIFE DATA
  263.                
  264.                
  265.                 *> RL First Name
  266.                 DISPLAY "Entry #" Current-User-Number " -- Enter Real Life First Name: " WITH NO ADVANCING
  267.                 ACCEPT RL-First-Name
  268.                
  269.                 *> RL Last Name
  270.                 DISPLAY "Entry #" Current-User-Number " -- Enter Real Life Last Name: " WITH NO ADVANCING
  271.                 ACCEPT RL-Last-Name
  272.                
  273.                 *> RL Age
  274.                 DISPLAY "Entry #" Current-User-Number " -- Enter Real Life Age: " WITH NO ADVANCING
  275.                 ACCEPT RL-Age
  276.                
  277.                
  278.                 *> RL Gender
  279.                 DISPLAY "Entry #" Current-User-Number " -- Enter Real Life Gender: " WITH NO ADVANCING
  280.                 ACCEPT RL-Gender
  281.                
  282.                 *> RL Birthdate
  283.                 DISPLAY "Entry #" Current-User-Number " -- Enter Real Life Birthdate (Format: xx-xx-xxxx): " WITH NO ADVANCING
  284.                 ACCEPT RL-Birth-Date
  285.                
  286.                 *> RL Occupation
  287.                 DISPLAY "Entry #" Current-User-Number " -- Enter Real Life Occupation: " WITH NO ADVANCING
  288.                 ACCEPT RL-Occupation
  289.                
  290.                 *> RL Country
  291.                 DISPLAY "Entry #" Current-User-Number " -- Enter Country: " WITH NO ADVANCING
  292.                 ACCEPT Country
  293.                
  294.                 *> RL State/Province
  295.                 DISPLAY "Entry #" Current-User-Number " -- Enter State/Province: " WITH NO ADVANCING
  296.                 ACCEPT State-Prov
  297.                
  298.                 *> RL ZIP/Postal Code
  299.                 DISPLAY "Entry #" Current-User-Number " -- Enter ZIP/Postal Code: " WITH NO ADVANCING
  300.                 ACCEPT ZIP-Postal
  301.                
  302.                 *> RL Street Address
  303.                 DISPLAY "Entry #" Current-User-Number " -- Enter Street Address: " WITH NO ADVANCING
  304.                 ACCEPT Street-Address
  305.                
  306.                    
  307.                    
  308.                    
  309.                
  310.                
  311.                 DISPLAY ""
  312.                 DISPLAY "Record #" Current-User-Number " Complete!"
  313.                
  314.                
  315.                 *> Display two carriage returns before entering the next record
  316.                 DISPLAY ""
  317.                 DISPLAY ""
  318.                
  319.                 PERFORM WriteToMembersFile
  320.                                
  321.             END-PERFORM.            *> End of loop
  322.            
  323.             CLOSE Member-File.
  324.            
  325.            
  326.        EXIT.
  327.            
  328.            
  329.            
  330.            
  331.            
  332.            
  333.            
  334.                
  335.            
  336.            
  337.        *> EnterOnlineRecords will ask for all of the data for the Online Records table
  338.        EnterOnlineRecords.
  339.        
  340.         OPEN EXTEND Online-File.
  341.        
  342.        
  343.         DISPLAY "Number of entries to enter: " WITH NO ADVANCING.
  344.         ACCEPT Number-Of-Entries.
  345.        
  346.         IF Number-Of-Entries = 0
  347.             DISPLAY ""
  348.             DISPLAY "No entries to enter. Exiting..."
  349.            
  350.             STOP RUN   
  351.         .
  352.        
  353.        
  354.         PERFORM Number-Of-Entries TIMES
  355.            
  356.             ADD 1 TO Current-Entry-Number
  357.            
  358.             DISPLAY "Entry #" Current-Entry-Number " -- Enter Second Life First Name: " WITH NO ADVANCING
  359.             ACCEPT Online-First-Name
  360.            
  361.             DISPLAY "Entry #" Current-Entry-Number " -- Enter Second Life Last Name: " WITH NO ADVANCING
  362.             ACCEPT Online-Last-Name
  363.            
  364.             DISPLAY "Entry #" Current-Entry-Number " -- Enter Date Logged (format xx-xx-xxxx): " WITH NO ADVANCING
  365.             ACCEPT Date-Logged
  366.            
  367.             DISPLAY "Entry #" Current-Entry-Number " -- Enter Hours Online: " WITH NO ADVANCING
  368.             ACCEPT Hours-Online
  369.            
  370.             DISPLAY ""
  371.            
  372.             DISPLAY "Entry #" Current-Entry-Number " Complete!"
  373.            
  374.            
  375.             *> Display two carriage returns before entering the next entry
  376.             DISPLAY ""
  377.             DISPLAY ""
  378.            
  379.            
  380.             PERFORM WriteToOnlineFile
  381.            
  382.                
  383.         END-PERFORM.        *> End of loop
  384.        
  385.        
  386.         CLOSE Online-File.
  387.      
  388.        EXIT.
  389.    
  390.            
  391.            
  392.            
  393.            
  394.            
  395.            
  396.            
  397.        
  398.        *> DisplayRecords will display records
  399.        DisplayRecords.
  400.             DISPLAY "Select which file to display ('m' for member file, 'o' for online file): " WITH NO ADVANCING.
  401.             ACCEPT Cmd.
  402.            
  403.             IF Cmd = "m"
  404.                 PERFORM ReadMemberRecord
  405.             ELSE
  406.                 IF Cmd = "o"
  407.                     PERFORM ReadOnlineRecord
  408.                 END-IF
  409.             .
  410.       EXIT.
  411.            
  412.            
  413.        
  414.        
  415.        *> WriteToMembersFile will write the record data to the JLURecords.dat file
  416.        WriteToMembersFile.
  417.             WRITE JLU-Member-Database.
  418.            
  419.        EXIT.
  420.        
  421.        
  422.        
  423.        
  424.        *> WriteToOnlineFile will write the record data to the JLUOnline.dat file
  425.        WriteToOnlineFile.
  426.             WRITE Online-Record.
  427.            
  428.       EXIT.
  429.      
  430.      
  431.      
  432.      
  433.       *> ReadMemberRecord will read a record from the JLUMember.dat file
  434.       ReadMemberRecord.
  435.      
  436.         OPEN INPUT Member-File.
  437.        
  438.                
  439.      
  440.         PERFORM UNTIL EOF
  441.                
  442.             READ Member-File INTO JLU-Member-Database
  443.            
  444.                 AT END
  445.                     MOVE 1 TO EOF-Flag
  446.                    
  447.             END-READ
  448.            
  449.            
  450.             DISPLAY ""
  451.            
  452.             *> Display all of the current record data
  453.             DISPLAY "Member #" Current-User-Number " of " Number-Of-Records
  454.             DISPLAY " - Second Life"
  455.             DISPLAY "  -- UUID:             " SL-UUID
  456.             DISPLAY "  -- First Name:       " SL-First-Name
  457.             DISPLAY "  -- Last Name:        " SL-Last-Name
  458.             DISPLAY "  -- Birthdate:        " SL-Birth-Date
  459.             DISPLAY "  -- Rank:             " SL-Rank
  460.             DISPLAY "  -- Partner:          " SL-Partner
  461.             DISPLAY "------------------------------------------"
  462.             DISPLAY " - Real Life"
  463.             DISPLAY "  -- First Name:       " RL-First-Name
  464.             DISPLAY "  -- Last Name:        " RL-Last-Name
  465.             DISPLAY "  -- Age:              " RL-Age
  466.             DISPLAY "  -- Gender:           " RL-Gender
  467.             DISPLAY "  -- Birthdate:        " RL-Birth-Date
  468.             DISPLAY "  -- Occupation:       " RL-Occupation
  469.             DISPLAY "  -- Location"
  470.             DISPLAY "   --- Country:         " Country
  471.             DISPLAY "   --- State/Province:  " State-Prov
  472.             DISPLAY "   --- ZIP/Postal Code: " ZIP-Postal
  473.             DISPLAY "   --- Steet Address:   " Street-Address
  474.            
  475.            
  476.             DISPLAY ""
  477.             DISPLAY "Press enter to display the next record..."
  478.            
  479.             ACCEPT Cmd
  480.            
  481.         END-PERFORM.            *> End of loop
  482.        
  483.         MOVE 0 TO EOF-Flag.
  484.        
  485.         DISPLAY "End of file reached. Exiting..."
  486.        
  487.         CLOSE Member-File
  488.      
  489.       EXIT.
  490.      
  491.      
  492.      
  493.       *> ReadOnlineRecord will read a record from the JLUOnline.dat file
  494.       ReadOnlineRecord.
  495.      
  496.         OPEN INPUT Online-File.
  497.            
  498.        
  499.         PERFORM UNTIL EOF
  500.            
  501.             READ Online-File INTO Online-Record
  502.            
  503.                 AT END
  504.                     MOVE 1 TO EOF-Flag
  505.                    
  506.             END-READ
  507.            
  508.            
  509.             *> Display the entry data from the file
  510.             DISPLAY ""
  511.            
  512.             DISPLAY "Entry #" Current-Entry-Number " of " Number-Of-Entries
  513.             DISPLAY "- Second Life First Name: " Online-First-Name
  514.             DISPLAY "- Second Life Last Name:  " Online-Last-Name
  515.             DISPLAY "- Date Logged:            " Date-Logged
  516.             DISPLAY "- Hours Online:           " Hours-Online
  517.            
  518.             DISPLAY ""
  519.            
  520.             DISPLAY "Press enter to display the next record..."
  521.             ACCEPT Cmd
  522.                    
  523.         END-PERFORM.            *> End of loop
  524.        
  525.         DISPLAY ""
  526.         DISPLAY "End of file reached. Exiting..."
  527.        
  528.         CLOSE Online-File.
  529.      
  530.       EXIT.
  531.        
  532.        
  533. * EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement