You are here: Home > Knowledge Refreshers

KR editions 97 to 98


KR-97 (perform until?) :

Did you know that when we say: 
PERFORM UNTIL condition 
in cobol it is actually 
PERFORM WITH TEST BEFORE UNTIL condition?

So this code snippet won't execute (assume WS-TEST to be PIC 9(1)):
MOVE 2 TO WS-TEST
PERFORM UNTIL WS-TEST<3 
DISPLAY "IN THE LOOP!"
COMPUTE WS-TEST = WS-TEST + 1
END-PERFORM 

Before entering the loop for the first time the condition WS-TEST<3 will be tested and in this case it is TRUE (because 2<3). Since it is already true the code won't enter into the loop body even once.

But this snippet will execute:

MOVE 2 TO WS-TEST
PERFORM WITH TEST AFTER UNTIL WS-TEST<3 
DISPLAY "IN THE LOOP!"
COMPUTE WS-TEST = WS-TEST + 1
END-PERFORM 

The first time the code encounters the loop condition it won't check for the condition. So it'll enter the loop body. 
Food for thought: Can you guess how many times this loop will execute?

Did you know that in NDM, the term PNODE denotes primary node and SNODE denotes secondary node?


KR-98 Cutting Tip) :

Tip contributed by Yasmeen Basith

There are situations where we have a lengthy primary command to issue but the primary command area does not allow us to type in a long command. For example: 
C ALL ‘STRING TO BE CHANGED XXXXXX’ ‘STRING TO REPLACE THE CHANGED STRING’ will not fit on a single line.
You can split this command into two:
1) F ALL ‘STRING TO BE CHANGED XXXXXX’ 
2) C ALL * ‘STRING TO REPLACE THE CHANGED STRING’
The asterix represents the results of the previous line command.

Answer to yesterdays food for thought: The loop will execute 8 times (WS-TEST starts at 2; keeps on incrementing till 9 and then on another increment it'll become 0 - because WS-TEST was a PIC 9(1). When this variable becomes 0 the condition WS-TEST < 3 becomes true and thus looping stops).

Did you know that SCL stands for Source Control Language?

Ever wondered what's the use of blocked records (or why we specify the block size while allocating datasets)?

 


 

Go back to the main contents page