cobol - Is there a way to automatically fill in array after getting user input? -
i have array of 5 elements , each of elements holds character. want accept user input in 1 line. example: abcde. , intend element 1 of array have , element 2 of array have b , on. this? have attached relevant portions of code below:
environment division. input-output section. file-control. select standard-input assign keyboard. select standard-output assign display. data division. file section. fd standard-input. 01 stdin-record pic x(80). fd standard-output. 01 stdout-record pic x(80). working-storage section. 01 input-area. 02 inputcharacters pic x(1) occurs 5 times. 01 print-line. 02 inputcharacters pic x(1) occurs 5 times. procedure division. open input standard-input, output standard-output. read standard-input input-area @ end close standard-input, standard-output end-read. write stdout-record print-line after advancing 5 line end-write stop run.
move input-area print-line
for code have, this:
write stdout-record input-area after advancing 5 line end-write
if don't need 2 copies of table (cobol doesn't have "arrays" in way you're used to) don't have 2 copies.
if have 2 tables, i'd suggest making item names different. if don't, you're making things tougher having use "qualification" make references unique.
move inputcharacters ( 1 ) of input-area inputcharacters ( 1 ) of print-line
instead of
move inputcharacters ( 1 ) outputcharacters ( 1 )
if don't mind qualification yourself, may find colleagues or future maintainers hate it.
i'm not quite sure want happen this:
read standard-input input-area @ end close standard-input, standard-output end-read.
you 1 read
, you'll at end
when there no data (whatever means keyboard
). in case, don't have data with.
you should @ how use file status each file. check file-status field after each io, , i'd recommend using file-status field end-of-file checking, rather cumbersome @ end.
however, said, don't know means keyboard... perhaps won't work :-)
Comments
Post a Comment