COBOL: PERFORM Varying UNTIL Sample Logic

COBOL supports loop control statements. Out of those PERFORM VARYING is one kind of option. To search an Array PERFORM Varying is a typical loop statement. As arrays usually popular to store file data till program execution completes.


PERFORM Varying Without Until Example

PERFORM paragraph-name
VARYING a-variable-value 
FROM start-value BY increment-value
UNTIL some-condition-is-met

PERFORM Varying with UNTIL Example

PERFORM PARA-A
VARYING  TEST-1 
FROM 1 BY 1
UNTIL    TEST-1 > 1000
OR       FILE-SWITCH = 'EOF'

Bonus Post

COBOL: How to use PERFORM-TEST-AFTER Logic

You can use this COBOL logic written using PERFORM TEST AFTER. This is one best way of handling loops in COBOL programs. After reading input files you need to validate each record. So this logic helps you as a guide.

Related Posts

LATEST POSTS

Python Logic to use tell() and seek()

In Python, both tell and seek functions help you get the data from a file. How to use these explained on how to use in your current project.

11 Kafka Admin Interview Questions

You can learn interview questions for the Kafka administrator role here. The questions covered prime points of the Kafka server.

Loading…

Something went wrong. Please refresh the page and/or try again.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.