View previous topic :: View next topic
|
Author |
Message |
bamohan
New User
Joined: 29 Jan 2007 Posts: 33 Location: chennai
|
|
|
|
In Cobol array concept,ie., OCCURS CLAUSE
What will happen if we try to execute the below statement..
say ,
MOVE '2' TO EXAMPLE(0)
ie., moving the value to Zero subscript variable. Will that be possible to move to Zero subscript variables ? |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Hi,
The lowest possible subscript value is 1 which points to first item in the table.
for your query y dont you try it out and see what happens ? |
|
Back to top |
|
|
mymains Currently Banned New User
Joined: 24 Apr 2008 Posts: 5 Location: Banglore
|
|
|
|
i think it is possible to move the value to the subscript .
thnkz
mymains |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
i think it is possible to move the value to the subscript
|
since a subscript is just a numeric field, the obvious answer is yes.
The subject had you bothered to read the OP post is what will happen
Quote: |
MOVE '2' TO EXAMPLE(0)
|
The execution of an instruction (without the SSRANGE options on) with a zero subscript is an excpetion - error.
But even if the SSrange Options are off, and your instruction with a 0 value in the subscript executes without error, you will not populate the table being subscripted - you will populate an area before the defined cobol internal table. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I don't think that an instruction with a literal value of 0 as the index value will compile.
with a subscript, you can even use negative values, if the SSRANGE option is off. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
I agree with Dick, the code won't compile if you code (0) in the subcript.
However you can do this
Code: |
move 0 to sub
move '2' to EXAMPLE(sub) |
this should compile and it will populate area before the array.
I have seen typical use of such 'tricky' code to get the RDW of variable length record. If you are trying to do the same, use the RECORD IS VARYING clause of COBOL instead. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Agkshirsagar,
You're very correct with that statement as it applies to COBOL2 and greater.
I remember trying this, by setting the subscript to ZERO, in a COBOL2 environment about 20 years ago and it did NOT work.
FWIW, this trick was outlined in both of Harvey Bookman's COBOL2 and COBOL/370 books (from the J. Ranade series / McGraw Hill), late 80's / early 90's.
Harvey has since retired.
Regards,
Bill |
|
Back to top |
|
|
bamohan
New User
Joined: 29 Jan 2007 Posts: 33 Location: chennai
|
|
|
|
Thanks for all your responses.. I will give a try and let u know.. |
|
Back to top |
|
|
|