I'm trying to get a portion of bytes from stdin using ACUCOBOL-GT. Because the data could be of any length, specifying a variable PIC X(n) and then using ACCEPT variable won't work, since the whole line is read, and the input line is truncated to the length of variable.
For example, if the stdin contains this:
Some line exceeding 10 caracters↵
and then another line↵
and at last a third line.
and I have this code:
working-storage division.
77 someLine pic X(10).
procedure division.
perform 3 times
accept someLine;
display someLine;
end-perform;
then the result is only
Some line ↵
and then a↵
and at las
Apparently, each ACCEPT reads until a newline is found, and then moves the line into the specified variable, possibly truncating a part of the line.
Now I want to read only a portion of stdin, so no bytes get discarded. I tried to assign a file descriptor to the stdin using SYSIN, as recommended in this post:
select sysin
assign to keyboard
organization binary sequential.
data division.
file section.
fd sysin.
01 inputByte pic X.
procedure division.
open input sysin
perform 3 times
accept inputByte from sysin
display inputByte
end-perform
close sysin.
But it somehow gives an File error 35 (file not found). Seems like ACUCOBOL-GT
does not support the direct assignment to the user's screen or keyboard.
Can I somehow force ACCEPT to read a specified number of bytes instead of scanning for a newline? Or can I somehow use READ SYSIN NEXT?