本文介绍了在COBOL中读取STDIN(SYSIN)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从COBOL中的STDIN(又名SYSIN)中读取行.现在,我只想打印出来,这样我就知道它们了.从我正在阅读的所有内容看来,这应该可以工作:
I want to read the lines out of STDIN (aka SYSIN) in COBOL. For now I just want to print them out so that I know I've got them. From everything I'm reading it looks like this should work:
IDENTIFICATION DIVISION.
PROGRAM-ID. APP.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SYSIN ASSIGN TO DA-S-SYSIN ORGANIZATION LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD SYSIN.
01 ln PIC X(255).
88 EOF VALUE HIGH-VALUES.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
OPEN INPUT SYSIN
READ SYSIN
AT END SET EOF TO TRUE
END-READ
PERFORM UNTIL EOF
DISPLAY ln
READ SYSIN
AT END SET EOF TO TRUE
END-READ
END-PERFORM
CLOSE SYSIN
STOP RUN.
可以编译(使用open-cobol和cobc -x),但是运行它,我得到:
That compiles (using open-cobol and cobc -x), but running it I get:
libcob: File does not exist (STATUS = 35) File : ''
我在做什么错了?
推荐答案
在 OpenCOBOL论坛.
SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.
使它起作用的是关键字KEYBOARD.
It's the keyword KEYBOARD that makes it work.
显然,DISPLAY是STDOUT的类似词,但我尚未对此进行测试.
Apparently DISPLAY is a similar word for STDOUT, but I have not tested that.
这篇关于在COBOL中读取STDIN(SYSIN)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!