所以我想在OpenCobolIDE中製作一個程序,它使用COBOL中的SCREEN SECTION
功能創建一個菜單,用戶可以選擇是否要輸入數據或顯示數據。 此數據正在順序.txt文件中記錄。寫入過程正常,所以我不在這裏添加這部分代碼。問題在於閱讀過程。我希望程序在PERFORM
循環中多次顯示DISPLAY-SCREEN
,以顯示我的文件中的所有記錄,但這不起作用。我認爲通過從我的DISPLAY-SCREEN
中刪除BLANK SCREEN
它會以我想要的方式工作,但所發生的只是該程序一次顯示DISPLAY-SCREEN
並且它甚至不顯示任何記錄。可能是什麼問題呢?下面是代碼:是否可以在cobol循環中顯示多個屏幕?
IDENTIFICATION DIVISION.
PROGRAM-ID.PGM001.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MYFILE ASSIGN TO "DATA.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD MYFILE.
01 FS-TB.
02 FS-ID PIC X(03).
02 FS-NAME PIC A(15).
02 FS-PHONE PIC X(09).
WORKING-STORAGE SECTION.
01 WS-TB.
02 WS-ID PIC X(03).
02 WS-NAME PIC A(15).
02 WS-PHONE PIC X(09).
01 WS-EOF PIC A(01) VALUE "N".
01 WS-COUNT PIC 9(01) VALUE ZERO.
01 WS-OP PIC 9(01).
SCREEN SECTION.
01 MENU-SCREEN.
02 BLANK SCREEN.
02 LINE 1 COL 1 VALUE "------------------------------------".
02 LINE 2 COL 1 VALUE "- MENU -".
02 LINE 3 COL 1 VALUE "------------------------------------".
02 LINE 4 COL 1 VALUE "- (1).REGISTER -".
02 LINE 5 COL 1 VALUE "- (2).DISPLAY -".
02 LINE 6 COL 1 VALUE "- (3).EXIT -".
02 LINE 7 COL 1 VALUE "- -".
02 LINE 8 COL 1 VALUE " OPTION:() -".
02 LINE 9 COL 1 VALUE "------------------------------------".
02 LINE 8 COL 20 PIC 9(01) TO WS-OP.
01 DISPLAY-SCREEN.
02 LINE 1 COL 1 VALUE "------------------------------------".
02 LINE 2 COL 1 VALUE "- DISPLAY -".
02 LINE 3 COL 1 VALUE "------------------------------------".
02 LINE 4 COL 1 VALUE "-(1).ID : -".
02 LINE 4 COL 18 PIC X(03) FROM WS-ID.
02 LINE 5 COL 1 VALUE "-(2).NAME : -".
02 LINE 5 COL 18 PIC A(15) FROM WS-NAME.
02 LINE 6 COL 1 VALUE "-(3).PHONE : -".
02 LINE 6 COL 18 PIC X(09) FROM WS-PHONE.
02 LINE 7 COL 1 VALUE "------------------------------------".
PROCEDURE DIVISION.
A-100.
DISPLAY MENU-SCREEN.
ACCEPT MENU-SCREEN.
EVALUATE WS-OP
WHEN 1
GO TO A-200
WHEN 2
GO TO A-300
WHEN 3
STOP RUN
WHEN OTHER
GO TO A-100
END-EVALUATE.
A-200.
A-300.
OPEN INPUT MYFILE
PERFORM UNTIL WS-EOF = "Y"
READ MYFILE INTO WS-TB
AT END MOVE "Y" TO WS-EOF
NOT AT END DISPLAY DISPLAY-SCREEN
END-READ
END-PERFORM
CLOSE MYFILE.
STOP RUN.
END PROGRAM PGM001.
將你的顯示器後接受。屏幕太快,你看不到,然後回到你的「命令行」 –