Store index in some other variable?

All sort of Mainframes Interview Questions.
Post Reply
divyaanand
New Member
Posts: 2
Joined: Fri Dec 19, 2014 6:41 pm

Store index in some other variable?

Post by divyaanand »

Hi,

Can index be stored in some other variable? The question was like, assume we have a table like this:

Code: Select all

01 SOME-VARIABLE-1 PIC X(36). 
05 SOME-VARIABLE--2 REDEFINES STRING-1 PIC X(1) OCCURS 36 TIMES 
INDEXED BY INDX1. 


SEARCH STRING-2 WHEN SOME-VARIABLE-2 (INDX1) = TEMP(i:1) 
SET INDX1 UP BY 1. 
Now can we get INDX1 into some other variable?

I'm not sure if we can do that?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Store index in some other variable?

Post by William Collins »

You use SET.

Exactly how you do it depends on what you want. Do you to save the value of the index, or do you want the "occurrence number" of the index? It may not make a big difference for a one-byte OCCURS.

What do you feel that code is doing anyway?

Please use scope-terminators (like END-SEARCH) instead of full-stops/periods.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Store index in some other variable?

Post by Robert Sample »

Look at USAGE INDEX in the Enterprise COBOL Language Reference manual.
Last edited by William Collins on Tue Oct 13, 2015 11:02 pm, edited 1 time in total.
Reason: Typo
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”