Page 1 of 2

how to display the value of the index variable in cobol

PostPosted: Mon Oct 29, 2007 5:48 pm
by dhiviya
hi,

can any body say the answer fot this question?

how to display the value of the index variable?

Re: how to display the value of the index variable in cobol

PostPosted: Mon Oct 29, 2007 6:43 pm
by CICS Guy
dhiviya wrote:how to display the value of the index variable?
Have you tried to just display it? My manual doesn't forbid it.....
You could always set a numeric integer to the index and display that.....

Re: how to display the value of the index variable in cobol

PostPosted: Tue Oct 30, 2007 7:03 pm
by abkumarch
ok i guess, u ve to define the index variable in the ws-section using INDEXED BY clause, now u can display it.. i ve not trird

u plz tr this and tell me.

Re: how to display the value of the index variable in cobol

PostPosted: Sun Dec 09, 2007 4:29 pm
by kiran_ragam
WE CAN'T DISLAY INDEX VARIABLE VALUE

Re: how to display the value of the index variable in cobol

PostPosted: Mon Dec 10, 2007 12:21 am
by dick scherrer
Hello,

Turn off your CAPS. . .

Yes, we can. Simply set some ws variable to the index and display that.

Re: how to display the value of the index variable in cobol

PostPosted: Fri Jan 04, 2008 2:16 pm
by sureshbabu
index variable can be displayed by using
set clsause
try this

Re: how to display the value of the index variable in cobol

PostPosted: Mon Mar 23, 2009 7:11 pm
by qykong1986
I think you can't dipaly index variable. Index variable is S9(8) comp, takes up one word, it means the physical address in the main storage.Use set index-variable to integer, set index-variable up (down) by integer to assign value to index-variable.
I think what you can display is script, script is an integer, can be displayed.

Re: how to display the value of the index variable in cobol

PostPosted: Tue Mar 24, 2009 12:55 am
by dick scherrer
Hello,

I think you can't dipaly index variable.
Why do you believe this? To repeat:
Yes, we can. Simply set some ws variable to the index and display that.

Index variable is S9(8) comp, takes up one word, it means the physical address in the main storage.
How does this relate to the question?
I think what you can display is script, script is an integer, can be displayed.
This surely needs clarification. . . :?

Re: how to display the value of the index variable in cobol

PostPosted: Tue Mar 24, 2009 10:21 am
by qykong1986
Simply set some ws variable to the index and display that.

I follow the scentence and code such program.

05-ws-num1 pic s9(4) comp-3.
05 ws-num2 pic s9(4) comp.
05 ws-num3 pic s9(4).
05 ws-num4 pic 9(4).
SET index to 1.
SET index up by 2.
MOVE index TO WS-NUM1 WS-NUM2 WS-NUM3 WS-NUM4.
DISPLAY' INDEX-VARIABLE' WS-NUM1 WS-NUM2 WS-NUM3 WS-NUM4.
The SYSOUT is 'INDEX-VARIABLE 00030003000B0003'

But still i believe this is not the internal value of the INDEX-VARIABLE, this value is just like subscript.
Index variable is S9(8) comp, takes up one word, it means the physical address in the main storage.
How does this relate to the question?

I think the internal value of INDEX variable is physical address, so how can we display the physical address :cry:
though, to a COBOL PROGRAMMER, the knowledge of internal representation of of an index is of no importance.

Re: how to display the value of the index variable in cobol

PostPosted: Wed Mar 25, 2009 12:19 am
by dick scherrer
Hello,

       01  ZZ-STUFF.                                             
           05  ZZ PIC XXX OCCURS 100 TIMES INDEXED BY ZZ-INX.     
       01  ZZ-N PIC 9(8) COMP VALUE ZEROS.                       

           SET ZZ-INX TO 1.               
           MOVE '111' TO ZZ(ZZ-INX).     
           DISPLAY ZZ(ZZ-INX).           
           SET ZZ-N TO ZZ-INX.           
           DISPLAY ZZ-N.                 
           SET ZZ-INX UP BY 50.           
           MOVE 'U51' TO ZZ(ZZ-INX).     
           DISPLAY ZZ(ZZ-INX).           
           SET ZZ-N TO ZZ-INX.           
           DISPLAY ZZ-N.                 


gives:
111       
00000001   
U51       
00000051   

This
                MOVE ZZ-INX TO ZZ-N.

generates this error
IGYPS2074-S   "ZZ-INX" WAS DEFINED AS A TYPE THAT WAS INVALID IN THIS CONTEXT.
so i don't know how your posted example successfully compiled. . .