xxx xxx xxx ...xxx


1960

JDoodle - Online COBOL Compiler IDE ...
(Ctrl+C, open link in new panel, Ctrl+V, Submit)

identification division.
program-id. TYPEWRITER.   *> from STDIN to screen directly
    *> with GO statements - NON Interactive mode ***

data division.
working-storage section.
1   TW-MEMORY.
 2   INP-LINE pic x(80) occurs 5.
77  I pic 9 value 1.

procedure division.
MAIN-PROC.
    move space to TW-MEMORY
    perform INP-PROC thru WORK-PROC.
END-PROC.
    display "   the work is finished ***"  
    stop run. 
   
INP-PROC.
    if I > 5
        display "   limit 5 exceeded"   
        go END-PROC.
WORK-PROC.
    accept INP-LINE(I)
    if INP-LINE(I) = "e" 
        go END-PROC
    else 
        display I ". " INP-LINE(I)
        add 1 to I
        go INP-PROC.

I = STDIN:

aaaaaaa
bbbbbbb
ccccccc
e

O = screen:

1. aaaaaaa                                                                         
2. bbbbbb                                                                          
3. ccccccc                                                                         
   work is terminated ***

 


ANS X3.23-1968

JDoodle - Online COBOL Compiler IDE ...
(Ctrl+C, open link in new panel, Ctrl+V, Submit)

identification division.
program-id. TYPEWRITER.   *> keyboard - memory - screen
    *> structured code without scope-delimiters
    *> *** execute in Interactive mode ***
    
data division.
working-storage section.
1   TW-MEMORY.
 2   INP-LINE pic x(80) occurs 5.
77  I pic 9.

procedure division.
    move space to TW-MEMORY
    display "write text max 5 times, at end write e:"  display " " 

    perform INP-PROC varying I from 1 by 1 until I > 5
    display "   entry is complete"  display " "

    perform OUT-PROC varying I from 1 by 1 until INP-LINE(I) = "e" or I > 5
    display "   the work is finished ***"
    stop run.
    
INP-PROC.
    accept INP-LINE(I)
    if INP-LINE(I) = "e" 
        move 6 to I.
OUT-PROC.
    display I ". " INP-LINE(I).

I = keyboard, W = memory, O = screen:

write text max 5 times, at end write e:
 
aaaaaaa
bbbbbbb
ccccccc
e
   entry is complete
 
1. aaaaaaa                                                                         
2. bbbbbbb                                                                         
3. ccccccc                                                                         
   the work is finished ***

 


ANSI '85

JDoodle - Online COBOL Compiler IDE ...
(Ctrl+C, open link in new panel, Ctrl+V, Submit)

identification division.
program-id. TYPEWRITER.    *> keyboard - memory - screen
    *> structured code with scope-delimiters
    *> *** execute in Interactive mode ***

data division.
working-storage section.
1   TW-MEMORY.
 2   INP-LINE pic x(80) occurs 5.
77  I pic 9.
77  MEM pic 9.
 88  MEM-BEG value 0.
 88  MEM-END value 1.

procedure division.
    initialize TW-MEMORY
    set MEM-BEG to true
    display "write text max 5 times, at end write e:"  display " " 
    
    perform varying I from 1 by 1 until I > 5 or MEM-END
        accept INP-LINE(I)
        if INP-LINE(I) = "e" 
            set MEM-END to true
        end-if  end-perform
    display "   entry is complete"  display " "
    
    perform varying I from 1 by 1 until INP-LINE(I) = "e" or I > 5
        display I ". " INP-LINE(I)
        end-perform
    display "   the work is finished ***"
    stop run. 

I = keyboard, W = memory, O = screen:

write text max 5 times, at end write e:
 
aaaaaaaa
bbbbbbbb
cccccccc
e
   entry is complete
 
1. aaaaaaaa                                                                        
2. bbbbbbbb                                                                        
3. cccccccc 
the work is finished

 

Čevela - 8.5.2020