Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

can index be stored in some other variable?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
dalib
Currently Banned

New User


Joined: 26 Jul 2008
Posts: 2
Location: hyderabad

PostPosted: Sat Jul 26, 2008 4:22 pm    Post subject: can index be stored in some other variable?
Reply with quote

can index be displayed .
can index be taken into some other variable?
in my code
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?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8120
Location: East Dubuque, Illinois, USA

PostPosted: Sat Jul 26, 2008 5:04 pm    Post subject:
Reply with quote

Have you looked at the COBOL Language Reference manual at all?

For question 1, if you have a variable defined as USAGE IS POINTER you can use the SET statement to copy INDX1 into it.

For question 2, the manual specifically states USAGE IS INDEX variables cannot be put into a DISPLAY statement.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Jul 26, 2008 7:13 pm    Post subject:
Reply with quote

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

Code:

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.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2284
Location: @my desk

PostPosted: Sun Jul 27, 2008 9:21 am    Post subject:
Reply with quote

Hello dalib,

Quote:
now can i get this indx1 into some other variable. or can i display indx1?


If you simply want to see the occurrence at which match occurred, use SET command to move the occurrence to a numeric variable as suggested above and DISPLAY it.

Thanks,
Arun
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us