IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Performing a paragraph in 2 ways using 1 perform statement


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
preethi sajjan

New User


Joined: 27 Oct 2011
Posts: 4
Location: india

PostPosted: Wed Nov 16, 2011 5:20 pm
Reply with quote

Hi all,
Here i have an interesting question. Even i dont know whether it is possible or not so i am posting this topic to know the view of others about this topic.


Q. Is it possible to Perform a paragraph in 2 ways using single perform statement?

ie.. I want to perform a paragraph without checking condition for the 1st time and to check the condition from 2nd time onwards. it can be any condition like until, varying etc.If first time only it satisfies condition then also it should perform without checking condition..

Is it possible?

Waiting for the reply...........................

Sorry guys i mistakenly posted this topic in abends & debugging. I dont know how to move topic to cobol can any 1 tell me how to do it?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 16, 2011 7:18 pm
Reply with quote

Does WITH TEST AFTER do what you want?

If not, post something a little clearer, like what you already have, what you are trying to do. Anything which might help.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 16, 2011 8:02 pm
Reply with quote

the way i interpret the TS's question is
can a perform statement have a variable WITH TEST.

answer is no.

you have two problems:
  • first time indication
  • two different WITH TEST clauses


i would suggest:
Code:

IF FIRSTTIME-SW = 'YES'
THEN
    MOVE 'NO' TO FIRSTIME-SW
    PERFORM paragraph WITH TEST (your choice here)
ELSE
    PERFORM paragraph WITH TEST (opposite of above)
END-IF
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Nov 16, 2011 8:07 pm
Reply with quote

Hello,

Not exactly what you asked, but if you moved the first-time check into the PERFORMed PARA, you would not need to be concerned about "2 ways".
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 16, 2011 10:10 pm
Reply with quote

Three answers, three different interpretations :-)

We need some clarification on what you mean, while you're waiting...
Back to top
View user's profile Send private message
preethi sajjan

New User


Joined: 27 Oct 2011
Posts: 4
Location: india

PostPosted: Thu Nov 17, 2011 11:13 am
Reply with quote

HI,
Actually i dont have any requirement like this but i just wondering this concept can be used in future.

And i may want to use only 1 perform statement not any if statement or 2 perform statements. with if statement we can do but i dont know before performing 'I' have any value or not so if 'I' have any value it should display that array 1st without initializing or incrementing.

ex:

Code:

        MOVE 2 TO I.
        :
        :
********VALUE OF I = 2 AT THIS LEVEL************
        PERFORM DISP-PARA VARYING I FROM 1 BY 1 UNTIL I > 5.
        STOP RUN.

 DISP-PARA.
        DISPLAY ARRAY(I).



if value of array is
Code:
A1
B1
C1
D1
E1

output should be
Code:
B1
A1
B1
C1
D1
E1


Here when it is performing 1st time i should not initialize or increment the value of i and should display the value. when it is performing 2nd time it should start incrementing.


Still i am asking question like is it possible? icon_question.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Nov 17, 2011 11:36 am
Reply with quote

Hello,

In this most recent post of the code snippet, the variable I is initialized to 2 and then immediately destroyed by the PERFORM.

Quote:
And i may want to use only 1 perform statement not any if statement or 2 perform statements.
Unless you have a plan to change the COBOL language specification, you will have to do this in the "normal" ways. What you ask about doesn't exist and very likely will not in the future.

Hopefully, you realize you can do what you want, just not the way you want to. It does not sound like there is an issue.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Nov 17, 2011 1:19 pm
Reply with quote

Quote:

Code:

        MOVE 2 TO I.
        :
        :
********VALUE OF I = 2 AT THIS LEVEL************
        PERFORM DISP-PARA
        PERFORM DISP-PARA
            VARYING I
                FROM 1 BY 1
                    UNTIL I GREATER THAN 5
        STOP RUN
        .

 DISP-PARA.
        DISPLAY ARRAY ( I )
        .




As Dick says, not what you want, but you can't get what you want, and I really can't see why you'd want it.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Nov 17, 2011 2:37 pm
Reply with quote

Code:

        MOVE 2 TO J
                  K
elsewhere
        MOVE 1 TO J
        MOVE 5 TO K
        :
        :
********VALUE OF I = 2 AT THIS LEVEL************
        PERFORM DISP-PARA
            VARYING I
                FROM J BY 1
                    UNTIL I GREATER THAN K
        STOP RUN
        .

 DISP-PARA.
        DISPLAY ARRAY ( I )
        .



Of course you still need an IF of some sort to get to the PERFORM with the right values.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu Nov 17, 2011 9:18 pm
Reply with quote

It sounds like you are trying to overload the function in an OO language.

With that in mind, you are going to have to make the same choices in code that the other language would perform during instantiation.

So something like:
Code:


    PERFORM PARA1

    PERFORM PARA1

    STOP RUN

PARA1

    IF some-condition
        PERFORM PARA1-FIRST-CALL
    ELSE
        PERFORM PARA1-SUBSEQUENT-CALLS
    END-IF
    MOVE not-first to some-condition variable
PARA1-FIRST-CALL
EXIT.

PARA1-SUBSEQUENT-CALLS
EXIT.



That will encapsulate that function for you. It might be handy if you're retooling bunch of newer programmers that are used to the OO mindset.

However, you'll notice that it's a very bad way to use COBOL.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Use of Perform Thru Exit COBOL Programming 6
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts Cobol-DB2 Programming - Better perfor... DB2 1
Search our Forums:

Back to Top