Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Performing a paragraph in 2 ways using 1 perform statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Performing a paragraph in 2 ways using 1 perform statement
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Nov 16, 2011 7:18 pm    Post subject: Reply to: Performing a paragraph in 2 ways using 1 perform s
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    Post subject:
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

Site Director


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

PostPosted: Wed Nov 16, 2011 8:07 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Nov 16, 2011 10:10 pm    Post subject: Reply to: Performing a paragraph in 2 ways using 1 perform s
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    Post subject: Reply to: Performing a paragraph in 2 ways using 1 perform s
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

Site Director


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

PostPosted: Thu Nov 17, 2011 11:36 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Nov 17, 2011 1:19 pm    Post subject: Re: Reply to: Performing a paragraph in 2 ways using 1 perfo
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Nov 17, 2011 2:37 pm    Post subject: Re: Reply to: Performing a paragraph in 2 ways using 1 perfo
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am
No new posts Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us