move index to some other variable



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

move index to some other variable

Postby mohd dalib » Sat Jul 26, 2008 4:20 pm

can index be displayed .
can index be taken into some other variable?
01 ORIG-STRING.
05 STRING-1 PIC X(36).
05 STRING-2 REDEFINES STRING-1 PIC X(1) OCCURS 36 TIMES
INDEXED BY INDX1.


SEARCH STRING-2 when string-2 (indx1) = temp(i:1)
SET INDX1 UP BY 1.

now can i get this indx1 into some other variable. or can i display indx1?
mohd dalib
 
Posts: 6
Joined: Thu Jul 03, 2008 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: move index to some other variable

 

Re: move index to some other variable

Postby dick scherrer » Sat Jul 26, 2008 10:58 pm

Hello,

question 1. You can use any numeric variable to store the occurance value of an index.

05 ws-hold-sub               pic s9(4) comp.
05 ws-hold-index            usage is index.

set ws-hold-index to indx1.
set ws-hold-sub    to indx1.


Ws-hold-index will contain the value of indx1, and ws-hold-sub will contain a number for the occurance of inx1. Which you use would depend on what you want to do with in. You can display ws-hold-sub.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post