MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Index and Subscript

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
abracadabra
Beginner


Joined: 02 Sep 2003
Posts: 101
Topics: 55
Location: India

PostPosted: Tue Dec 23, 2003 7:16 am    Post subject: Index and Subscript Reply with quote

What is the difference b/w index and subscript?
_________________
Cheers!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Dec 23, 2003 7:28 am    Post subject: Reply with quote

In simple terms Index represents the displacement value of the table entry from the beginning of the table, whereas subscript reprensts the occurrence # of the table entry.

check this link which explains about good tips on writing efficient COBOL programs
the performance. In that you have a section of Efficient COBOL Coding Techniques and in it there is a section which discusses about Indexes vs Subscripts

http://www-1.ibm.com/support/docview.wss?org=SW&doc=7001476&aid=1

Hope this helps...

cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abracadabra
Beginner


Joined: 02 Sep 2003
Posts: 101
Topics: 55
Location: India

PostPosted: Tue Dec 23, 2003 7:37 am    Post subject: Reply with quote

Thanks Kolusu. The manual is really good. However, I still have one ot two questions.
1) I believe the index value is written in the register while the subscript is not. Can you tell me more about this?
2) The other thing is that which one can I pass...a subscript or an index?
_________________
Cheers!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Dec 23, 2003 7:59 am    Post subject: Reply with quote

abracadabra,

Indexes are stored as a 4-byte binary number and pointed to in the variable portion of the TGT(Task Global Table) whereas subscripts are defined in the working-storage section and are stored according to their PIC and USAGE clauses (PIC S9(4) or S9(8) COMP)

I am sorry I did not quite understand your second question. can you elaborate?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abracadabra
Beginner


Joined: 02 Sep 2003
Posts: 101
Topics: 55
Location: India

PostPosted: Tue Dec 23, 2003 10:34 pm    Post subject: Reply with quote

Kolusu,

Actually I have heard somebody telling me that if there is a program A which calls another program B, index can be accessed from both the programs while with subscript its not possible. I am not sure about this at all.
_________________
Cheers!
Back to top
View user's profile Send private message
hari_uss
Beginner


Joined: 19 Dec 2002
Posts: 78
Topics: 6
Location: Trivandrum, India

PostPosted: Tue Dec 23, 2003 11:58 pm    Post subject: Reply with quote

abracadabra,

It is not possible to pass index via linkage. Index is not a part of calling program's working storage.

Hari.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Dec 24, 2003 9:23 am    Post subject: Reply with quote

hari_uss,

Quote:

It is not possible to pass index via linkage. Index is not a part of calling program's working storage.


I beg to differ as direct references to an index data item can be made only in a SEARCH statement, a SET statement, a relation condition, the USING phrase of the Procedure Division header, or the USING phrase of the CALL statement. An index data item can be referred to directly in the USING phrase of an ENTRY statement. So index can be accessed both in the main program as well as the subroutine.

Hope this helps...

cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abracadabra
Beginner


Joined: 02 Sep 2003
Posts: 101
Topics: 55
Location: India

PostPosted: Fri Jan 02, 2004 5:32 am    Post subject: Reply with quote

Thanks Kolusu for the update. I still have one more doubt. If I can use an index in the USING statement for CALL, I need to receive it in my subroutine/sub program. So will I need to define a ws-variable in the linkage section?
_________________
Cheers!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sun Jan 04, 2004 12:03 pm    Post subject: Reply with quote

abracadabra,

No you don't have to define the index in the working storage section. Just use it in the procedure division statement of the subroutine.

Hope this helps...

cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun Jan 04, 2004 4:54 pm    Post subject: Reply with quote

Hi Kolusu,

Granted, a passed index is not defined in WS. If it is defined in the LS, how is it defined when intended to be used to reference an entry of a passed table?

Thanx, Jack.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group