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

Perform para to execute the condition first


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
praveenbl22
Currently Banned

New User


Joined: 26 Sep 2007
Posts: 24
Location: Bangalore

PostPosted: Thu Nov 29, 2007 12:16 pm
Reply with quote

Hi,
How do I perform the para to execute the condition first and increment the variable later?
Code:


2010-para
Perfrom varying count from 1 by 1 until Flag_true
  IF Name = DBtable
      Set Flag_True to true
  end-IF
end-perform
2010-exit


2000-para

perfrom 2010-para
 
move count to Hold-count

........
2000-exit

Here the count is already increament by one when it exits the loop.
Do Perform after verb will work here or we need to explicitly subtract the count by 1?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Nov 29, 2007 1:57 pm
Reply with quote

Praveen,

Why dont you modify the 'perform' loop like -

Code:
Perfrom until Flag_true
  IF Name = DBtable
      Set Flag_True to true
   else
      compute count = count + 1
  end-IF
end-perform
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 128
Location: Guntur

PostPosted: Fri Nov 30, 2007 11:40 am
Reply with quote

Hi praveen,

solution given by murali should work for you as per your specification.

if not please give us clear picture of your requirement.
Back to top
View user's profile Send private message
praveenbl22
Currently Banned

New User


Joined: 26 Sep 2007
Posts: 24
Location: Bangalore

PostPosted: Fri Nov 30, 2007 11:59 am
Reply with quote

Actually i needed the subscript after preforming the PERFROM Verb, But I found that it was incremented by 1 when it exits the Loop. later in the 2000 when i use the subscript to select the element from the table it was actulay selecting the next element. How can i exit the PERFROM loop when the FLAG is set. I tried with subtracting the the subscript by 1. Is there any other method to do .
Code:


2010-para
Perfrom varying count from 1 by 1 until Flag_true
  IF Name = DBtable
      Set Flag_True to true
  end-IF
end-perform
2010-exit

2010-para

2000-para

perfrom 2010-para
 
move SUB to Hold-SUB

........
2000-exit
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 128
Location: Guntur

PostPosted: Fri Nov 30, 2007 2:28 pm
Reply with quote

Hi praveen,

Code:

Perfrom varying count from 1 by 1 until Flag_true
  IF Name = DBtable
      Set Flag_True to true
      move count to temp
  end-IF
end-perform
2010-exit


you can use a temporary variable to store that count and use it after the loop.
Back to top
View user's profile Send private message
jagdishborde

New User


Joined: 14 Sep 2007
Posts: 1
Location: pune

PostPosted: Fri Nov 30, 2007 4:19 pm
Reply with quote

hi friends whenever we use varying option that time it first increment & then it execute the condition so muli written is mostly correct,but condition is complicated it may be gone in infinite loop for above example no problem
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Nov 30, 2007 4:48 pm
Reply with quote

are not the options WITH TEST BEFORE and WITH TEST AFTER nolonger accepted syntax for the PERFORM verb?
Back to top
View user's profile Send private message
praveenbl22
Currently Banned

New User


Joined: 26 Sep 2007
Posts: 24
Location: Bangalore

PostPosted: Fri Nov 30, 2007 5:59 pm
Reply with quote

Quote:

you can use a temporary variable to store that count and use it after the loop.

The table is uesd in many place. we do not want to change the code in all the place in order to add the new variable to hold the subscript.

Quote:

are not the options WITH TEST BEFORE and WITH TEST AFTER nolonger accepted syntax for the PERFORM verb

will the WITH TEST AFTER with the perfrom verb works for the below code.
Code:

 code.

2010-para
Perfrom varying SUB from 1 by 1 until Flag_true
  IF DATA(SUB) = DBtable
      Set Flag_True to true
      move 10   to Field1
  end-IF
end-perform
2010-exit

2010-para

2000-para

perfrom 2010-para
 
move SUB to Hold-SUB

........
2000-exit
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 Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Use of Perform Thru Exit COBOL Programming 6
This topic is locked: you cannot edit posts or make replies. Programa para Realiza Operaciones sob... JCL & VSAM 3
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
Search our Forums:

Back to Top