View previous topic :: View next topic
|
Author |
Message |
preethi sajjan
New User
Joined: 27 Oct 2011 Posts: 4 Location: india
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Three answers, three different interpretations :-)
We need some clarification on what you mean, while you're waiting... |
|
Back to top |
|
|
preethi sajjan
New User
Joined: 27 Oct 2011 Posts: 4 Location: india
|
|
|
|
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
output should be
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? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
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 |
|
|
|