FOR - Iteration construct
Enhanced Definition
An iteration construct, often conceptually referred to as a "FOR loop," is a control flow statement used in programming languages to repeatedly execute a block of code a specified number of times or until a certain condition is met. In mainframe programming, while the exact `FOR` keyword might not be universally present (e.g., COBOL uses `PERFORM VARYING`), the underlying concept of controlled iteration is fundamental for processing data and automating tasks.
Key Characteristics
-
- Controlled Repetition: The primary function is to execute a set of instructions multiple times, either for a fixed count or based on a dynamic condition.
- Loop Control Variables: Typically involves one or more variables that are initialized, tested against a condition, and incremented or decremented with each iteration to control the loop's execution.
- Language-Specific Syntax: The implementation varies significantly across mainframe languages; for example, COBOL uses
PERFORM VARYING, REXX usesDO i = start TO end BY step, and PL/I usesDO i = start TO end BY steporDO WHILE. - Pre-test or Post-test: Loops can be designed to test the termination condition *before* each iteration (e.g.,
PERFORM VARYING,DO WHILE) or *after* each iteration (e.g.,PERFORM UNTILwithWITH TEST AFTER). - Loop Control Statements: Most languages provide mechanisms to alter the normal flow of a loop, such as
EXIT(COBOL), `
Related Products
Related Vendors
Candle Corporation
16 products
Trax Softworks
3 products
Related Categories
Performance
171 products
Monitor
262 products
CICS
214 products
Browse and Edit
64 products
Content, Books and Documents
47 products