COBOL In Line Perform
000340 01 CAT-TYPE PIC X(15) VALUE 'CALICO'. 000360 01 CAT-COUNT PIC 99 VALUE 15.
InLine Perform Example Number 1
004310 004320 PERFORM UNTIL CAT-TYPE(CAT-COUNT:1) NOT = SPACE 004325 OR CAT-COUNT < 1 004330 SUBTRACT 1 FROM CAT-COUNT 004340 END-PERFORM. 004440
InLine Perform Example Number 2 - Using TEST LAST
004310 004320 PERFORM UNTIL CAT-TYPE(CAT-COUNT:1) NOT = SPACE 004323 OR CAT-COUNT < 1 004325 WITH TEST LAST 004330 SUBTRACT 1 FROM CAT-COUNT 004340 END-PERFORM. 004440
|Comments Comments are left by visitors to FluffyCat.com and may or may not be accurate.|
|Comment by Fumigator on 2013-06-10 Rate this Comment|
Just a nit-pick here-- You should always test the iterator of a loop first before anything else in a PERFORM condition, to avoid an array overflow. For example:
|Comment by TheMadProfessor on 2013-05-22 Rate this Comment|
Can't do anything about your incipient baldness problem - looking for the solution to that one myself. The problem with the code I see is that you have two IFs contained within the PERFORM, but only one END-IF terminator. Since you cannot have an overt terminator (period) within the body of the inline PERFORM, all potentially multi-statement clauses (READs with AT END, COMPUTEs with ON OVERFLOW, EVALUATEs, IFs, etc.) must have its corresponding terminator so the compiler can determine to which clause each statement belongs, even if the clause consists of just a single statement. There may be some other problem due to various compiler options or other code surrounding the below snippet, but I suspect adding a second END-IF will eliminate the error.
|Comment by archive on 2007-09-28 Rate this Comment|
|Comment by rahul on 2013-05-22 Rate this Comment|
inline perform is really a very stong method. it is same as the do while loop in c.
|Sign in to comment on COBOL In Line Perform.|