Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
where we need to use subscripting and where Indexing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
richa.setia

New User


Joined: 23 Mar 2005
Posts: 10
Location: Noida

PostPosted: Wed May 11, 2005 6:31 pm    Post subject: where we need to use subscripting and where Indexing
Reply with quote

Can anybody give the scenarios where we need to use subscripting and where we nede to use Indexing? Also the difference between the two.
Back to top
View user's profile Send private message

Ashutosh Shrinet

New User


Joined: 22 Aug 2004
Posts: 10
Location: New Delhi

PostPosted: Thu May 12, 2005 5:19 pm    Post subject: re
Reply with quote

Hi, Richa
this is the basic differnce between subscript and index,Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to use SEARCH, SEARCH ALL.
Back to top
View user's profile Send private message
ashutosh719

New User


Joined: 06 Apr 2005
Posts: 12

PostPosted: Sat May 14, 2005 10:47 am    Post subject:
Reply with quote

Also, index is preferred one...due to enhanced execution speed...
refer stern/stern for more...

thanks.
Back to top
View user's profile Send private message
narasimharao_koganti

New User


Joined: 26 Apr 2005
Posts: 11
Location: pune

PostPosted: Tue May 17, 2005 9:48 pm    Post subject:
Reply with quote

hi,
index is used for faster access. when the table size is large it is better to go for the index. because index represents the displacement position starting of the array.
the primary difference between index and subscript is, index represents the displacement position, where as subscript represents the occurance position of the element.
Back to top
View user's profile Send private message
vasanthanc

New User


Joined: 01 Apr 2005
Posts: 58

PostPosted: Thu May 19, 2005 11:17 am    Post subject:
Reply with quote

thats right. As subscript represents the occurance position, when ever an array element is referred, to retrieve the value, displacement position will be calculated internally and this will take some time as it includes multiplication and in case the array size is large, there will be much time difference. So its better to go for index in case of large arrays
Back to top
View user's profile Send private message
swaran_msc

New User


Joined: 19 May 2005
Posts: 5
Location: Bangalore

PostPosted: Thu May 19, 2005 12:05 pm    Post subject:
Reply with quote

Yeah... What they said is correct. Also we have no need to declare the index variables in W-S Section whereas declaration is required for Subscript.

Thanks...

Corrections are Welcome
Back to top
View user's profile Send private message
Mohan.r

New User


Joined: 07 Mar 2005
Posts: 2

PostPosted: Thu May 19, 2005 12:36 pm    Post subject: Why Index, not subcript for use in programming
Reply with quote

hi,
subscript is advisable to use when u have to point few number of records say 50.
If u have large number of records it is wise one should use index.
In Index concept, data will be pointed internally in binary format that is why it will not take time to point it out. where as it n't the same with subscript, internally it has to convert into binary form and then start pointing to the record and results in time-consuming.

I prefer to use index always.
Back to top
View user's profile Send private message
pa1chandak
Currently Banned

New User


Joined: 31 Jan 2006
Posts: 55

PostPosted: Thu Feb 02, 2006 1:31 pm    Post subject:
Reply with quote

INDEXING IS BINARY SEARCH

AND SUBSCRIPT IS SERIAL SEARCH



IF I AM WRONG SOMEWHERE PLEASE CORRECT ME

THANK YOU

DO SEND ME THE REPLY

PAWAN

09822546416

// THE ONE I LOVE , I SHALL NEVER BLAME //
Back to top
View user's profile Send private message
kshalini

New User


Joined: 20 Feb 2007
Posts: 8
Location: Banglore

PostPosted: Mon Mar 12, 2007 5:49 pm    Post subject: :rE
Reply with quote

Please give elaborate example.
What I can undestand that since Index is defined while delaring an array when we refer a particular array occurence index access is faster because the memory is assigned for an array.
But when referred by subscripts the seach time is more because m/f has to search for teh exact location.
e.g:
01 NAMES.
05 NAME-TBL OCCURS 3 INDEXED BY T.
10 MY-NAME PIC X(10).
SET T TO 1
PERFORM VARYING T FROM 1 BY 1 UNTIL T=3
MOVE 'TONY' TO NAME-TBL(T)
END-PERFORM.
MOVE 2 TO WS-SUB.
DISPLAY 'NAME-TBL(WS-SUB)'NAME-TBL(WS-SUB).
SET T TO 1.
DISPLAY 'NAME-TBL(T)'NAME-TBL(T).

I am getting the same value in both of them
NAME-TBL(WS-SUB)TONY
NAME-TBL(T)TONY

So please elaborate whether the main difference lies in the access time as because when array is defined a fixed memory location is defined by index but for subscript it takes longer time to arraive at the exact location
Back to top
View user's profile Send private message
kshalini

New User


Joined: 20 Feb 2007
Posts: 8
Location: Banglore

PostPosted: Mon Mar 12, 2007 5:52 pm    Post subject:
Reply with quote

value will be difnitely same but what i want to know is the exact difference with example
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Mar 12, 2007 9:53 pm    Post subject:
Reply with quote

Hello,

Please search the forum and the Fine Manual.

The topic has been in the forum several times.

From
Quote:
INDEXING IS BINARY SEARCH

AND SUBSCRIPT IS SERIAL SEARCH


Not necessarily. Indexes may be used for a serial search. Subscripts may point directly at an entry with no serialization needed. Before SEARCH and SEARCH ALL were included in the language specification, binary searches were implemented using subscripts.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Mar 13, 2007 12:59 am    Post subject: Re: :rE
Reply with quote

kshalini wrote:
So please elaborate whether the main difference lies in the access time as because when array is defined a fixed memory location is defined by index but for subscript it takes longer time to arraive at the exact location
I don't think so....
In effect, the calculation for each is done a different times
Indexes are computed to the displacement when they are set or incremented.
Subscripts can be incremented up or down with little regard but the moment a subscripted element (with a variable subscript) is referenced, calculation time. Subscripted elements with literal subscripts are calculated at compile time.
The size of the table has no bearing on which is better, the usage is more the concern.

BTW, I don't think you can
PERFORM VARYING T FROM 1 BY 1 UNTIL T=3
if T is an index.....
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 indexing Rohit Umarjikar DB2 5 Thu Jun 21, 2012 2:08 pm
No new posts Indexing in db2 with expressions knn9413 DB2 4 Tue Sep 20, 2011 2:42 am
No new posts Indexing issue kanha DB2 1 Mon Jul 25, 2011 1:04 pm
No new posts FIELD(1:4): compilation is indexing t... Ensign COBOL Programming 7 Mon Jun 22, 2009 5:24 pm
No new posts Status AK while using Secondary index... Jonai IMS DB/DC 4 Mon Mar 09, 2009 1:27 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us