View previous topic :: View next topic
|
Author |
Message |
Rahul_kumar Warnings : 2 New User
Joined: 24 Jun 2006 Posts: 50
|
|
|
|
Hi,
Can I execute a section by using a perform statement in decreasing order
e.g.
01 I1 pic s99.
some value is calculated in the program for I1........
Perfrom XYZ varying I1 from I1 by -1 until I1 < 1
Kindly let me know if the above syntax will work...
Rahul |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
There is a link to manuals at the top of this page. If you click on it, find the COBOL Language Reference manual, and read sections 6.2.27.5 and 6.2.27.10 on PERFORM VARYING, all your questions will be answered -- as long as you pay sufficient attention to what is said. |
|
Back to top |
|
|
Rahul_kumar Warnings : 2 New User
Joined: 24 Jun 2006 Posts: 50
|
|
|
|
Checked the manual ;it says :
identifier Must be a numeric elementary item,so I guess -1 will work but I am a bit confused.
Perfrom XYZ varying I1 from I1 by -1 until I1 < 1 |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Why not you just execute a test? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Did you notice in section 6.2.27.5 that using variables requires different variables for the VARYING and FROM phrases? identifier-2 and identifier-3 don't refer to the same variable.
Furthermore, 6.2.27.10 specifically states that non-zero numeric variables or literals are required for the BY variable, so -1 will obviously work.
As I said, pay attention to the details. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Why not just test it already and actually learn how to learn? Experiment. |
|
Back to top |
|
|
Rahul_kumar Warnings : 2 New User
Joined: 24 Jun 2006 Posts: 50
|
|
|
|
The table is still not in place that's why ca'nt check |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
what a lame excuse
no need of any table to write a small program to check the syntax of ithe PERFORM statement
You could simply print the <index> inside the loop! |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Well, just a suggestion - write the code, compile it , at least you'd know if there is any syntax-error with the code ...you're thinking can or can not work. |
|
Back to top |
|
|
|