我需要帮助...... 无法弄清楚为什么它无法创建文本文件。
IDENTIFICATION DIVISION.
PROGRAM-ID. MACHINEPROBLEM4.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OPTIONAL REC ASSIGN TO "BUSRECORD.TXT"
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS NAME-FILE-STATUS.
DATA DIVISION.
FILE SECTION.
FD REC.
01 IN-RECORD.
05 RSEAT PIC 9(3).
05 RCUSTOMER PIC X(20).
05 RSOURCESTATION PIC A(14).
05 RDESTINATIONN PIC A(14).
WORKING-STORAGE SECTION.
01 NAME-FILE-STATUS PIC XX VALUE SPACES.
88 OPENSUCCESS VALUE "00".
01 SWITCHES.
05 EOF-SWITCH PIC X VALUE "N".
01 INPUTDATA.
05 CHOICE PIC A.
* 05 SEAT PIC 9(3) OCCURS 20 TIMES.
* 05 CUSTOMER PIC X(20) OCCURS 20 TIMES.
* 05 SOURCESTATION PIC A(14) OCCURS 20 TIMES.
* 05 DESTINATIONN PIC A(14) OCCURS 20 TIMES.
05 RESERVEMORE PIC A.
05 DELSEAT PIC 9(3).
05 DELCUST PIC X(20).
05 DELCONT PIC 9(10).
05 CANCELMORE PIC A.
05 M PIC A.
01 COMPUTEDDATA.
05 NUM1 PIC 99 VALUE ZEROS.
05 MAXNUM PIC 99.
05 LINENUM PIC 99.
05 CAGAYANVALLEY PIC A(14) VALUE "CAGAYAN VALLEY".
05 IFUGAO PIC A(14) VALUE "IFUGAO".
05 LAOAG PIC A(14) VALUE "LAOAG".
05 BAGUIO PIC A(14) VALUE "BAGUIO".
05 KALINGA PIC A(14) VALUE "KALINGA".
05 ISABELA PIC A(14) VALUE "ISABELA".
05 DAGUPAN PIC A(14) VALUE "DAGUPAN".
05 MANILA PIC A(14) VALUE "MANILA".
SCREEN SECTION.
01 MAINSCREEN
Blank Screen, Auto, Required,
Foreground-Color is 5,
Background-Color is 0.
03 DISPLAY "ABC TRANSPORT COMPANY" LINE 2 COL 30.
03 DISPLAY "RESERVATION SYSTEM" LINE 3 COL 32.
03 DISPLAY "--------------------------------" LINE 4 COL 1.
03 DISPLAY "--------------------------------" LINE 4 COL 32.
03 DISPLAY "-------------------------" LINE 4 COL 56.
03 DISPLAY "MAIN MENU: " LINE 5 COL 2.
03 DISPLAY "R] RESERVATION " LINE 6 COL 2.
03 DISPLAY "V] VIEW RESERVATIONS " LINE 7 COL 2.
03 DISPLAY "D] CANCEL RESERVATION " LINE 8 COL 2.
03 DISPLAY "E] EXIT" LINE 9 COL 2.
03 DISPLAY "--------------------------------" LINE 10 COL 1.
03 DISPLAY "-------------------------------" LINE 10 COL 32.
03 DISPLAY "-------------------------" LINE 10 COL 56.
03 DISPLAY "CHOICE: [ ]" LINE 11 COL 2.
01 RESERVATION
Blank Screen, Auto, Required,
Foreground-Color is 7,
Background-Color is 0.
03 DISPLAY "ABC TRANSPORT COMPANY" LINE 2 COL 30.
03 DISPLAY "RESERVATION SYSTEM" LINE 3 COL 32.
03 DISPLAY "--------------------------------" LINE 4 COL 1.
03 DISPLAY "--------------------------------" LINE 4 COL 32.
03 DISPLAY "-------------------------" LINE 4 COL 56.
03 DISPLAY "RESERVATION: " LINE 5 COL 2.
03 DISPLAY "RESERVE SEAT NUMBER: " LINE 6 COL 2.
03 DISPLAY "CUSTOMER NAME: " LINE 7 COL 2.
03 DISPLAY "SOURCE STATION: " LINE 8 COL 2.
01 VIEWRESERVATION
Blank Screen, Auto, Required,
Foreground-Color is 7,
Background-Color is 0.
03 DISPLAY "ABC TRANSPORT COMPANY" LINE 4 COL 30.
03 DISPLAY "RESERVATION SYSTEM" LINE 5 COL 32.
03 DISPLAY "--------------------------------" LINE 6 COL 1.
03 DISPLAY "--------------------------------" LINE 6 COL 32.
03 DISPLAY "-------------------------" LINE 6 COL 56.
03 DISPLAY "RESERVE SEAT NO. " LINE 7 COL 1.
03 DISPLAY "CUSTOMER NAME " LINE 7 COL 18.
03 DISPLAY "SOURCE STATION " LINE 7 COL 45.
03 DISPLAY "DESTINATION" LINE 7 COL 66.
PROCEDURE DIVISION.
ROUTINE.
DISPLAY MAINSCREEN.
ACCEPT CHOICE LINE 11 COL 11
EVALUATE CHOICE
WHEN = "R"
DISPLAY RESERVATION
PERFORM RESERVEE
PERFORM ROUTINE
WHEN = "V"
DISPLAY VIEWRESERVATION
PERFORM VIEWW UNTIL EOF-SWITCH = "Y"
WHEN = "D"
DISPLAY CANCELRESERVATION
PERFORM CANCELL
WHEN = "E"
DISPLAY ERASE
STOP RUN
WHEN OTHER
PERFORM ROUTINE
END-EVALUATE.
在下面的代码上,(这是上面代码的延续)我试图将“OPEN I-O”更改为“OPEN EXTEND”或“OPEN OUTPUT”,但数据仍然无法保存。
RESERVEE.
* PERFORM VARYING NUM1 FROM 1 BY 1 UNTIL RESERVEMORE = "N"
* MOVE NUM1 TO MAXNUM
ACCEPT RSEAT LINE 6 COL 23
ACCEPT RCUSTOMER LINE 7 COL 17
DISPLAY "CHOICES: " LINE 9 COL 2
DISPLAY IFUGAO LINE 10 COL 2
DISPLAY LAOAG LINE 11 COL 2
DISPLAY BAGUIO LINE 12 COL 2
DISPLAY KALINGA LINE 13 COL 2
DISPLAY ISABELA LINE 14 COL 2
DISPLAY DAGUPAN LINE 15 COL 2
DISPLAY MANILA LINE 16 COL 2
DISPLAY "DESTINATION: " LINE 17 COL 2
DISPLAY "--------------------------------" LINE 18 COL 1
DISPLAY "--------------------------------" LINE 18 COL 32
DISPLAY "-------------------------" LINE 18 COL 56
DISPLAY "RESERVE MORE? [Y/N]: [ ]" LINE 19 COL 2
PERFORM DESTINN
ACCEPT RESERVEMORE LINE 19 COL 24
EVALUATE RESERVEMORE
WHEN = "Y"
PERFORM RESERVEE
WHEN = "N"
PERFORM ROUTINE
END-EVALUATE
OPEN I-O REC.
WRITE IN-RECORD
INVALID KEY
DISPLAY "RECORD ALREADY RESERVED" LINE 21 COL 2
NOT INVALID KEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
CLOSE REC.
* END-PERFORM.
VIEWW.
OPEN INPUT REC.
IF OPENSUCCESS
DISPLAY "00" LINE 2 COL 50
ELSE
DISPLAY NAME-FILE-STATUS LINE 1 COL 50
END-IF
MOVE "N" TO EOF-SWITCH
READ REC
AT END
MOVE "Y" TO EOF-SWITCH
NOT AT END
ADD 1 TO NUM1
END-READ.
CLOSE REC.
DESTINN.
ACCEPT RSOURCESTATION LINE 8 COL 18
INSPECT RSOURCESTATION
CONVERTING "abcdefghijklmnopqrstuvwxyz"
TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
IF RSOURCESTATION = CAGAYANVALLEY
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = IFUGAO
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = LAOAG
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = BAGUIO
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = KALINGA
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = ISABELA
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = DAGUPAN
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = MANILA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE IF RSOURCESTATION = MANILA
ACCEPT RDESTINATIONN LINE 17 COL 15
IF RDESTINATIONN = CAGAYANVALLEY
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = IFUGAO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = LAOAG
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = BAGUIO
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = KALINGA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = ISABELA
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE IF RDESTINATIONN = DAGUPAN
DISPLAY "RECORD SAVED." LINE 21 COL 2
ELSE
PERFORM DESTINN
ELSE
PERFORM RESERVEE
END-IF
STOP RUN.
尚未创建文本文件。我希望程序能够自己创建它。但是,我已经尝试过,有没有“选择可选”,程序似乎没有保存文本文件的输入。我将如何使其发挥作用?