View previous topic :: View next topic |
Author |
Message |
abracadabra Beginner
Joined: 02 Sep 2003 Posts: 101 Topics: 55 Location: India
|
Posted: Tue Dec 23, 2003 7:16 am Post subject: Index and Subscript |
|
|
What is the difference b/w index and subscript? _________________ Cheers! |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Dec 23, 2003 7:28 am Post subject: |
|
|
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 |
|
|
abracadabra Beginner
Joined: 02 Sep 2003 Posts: 101 Topics: 55 Location: India
|
Posted: Tue Dec 23, 2003 7:37 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Dec 23, 2003 7:59 am Post subject: |
|
|
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 |
|
|
abracadabra Beginner
Joined: 02 Sep 2003 Posts: 101 Topics: 55 Location: India
|
Posted: Tue Dec 23, 2003 10:34 pm Post subject: |
|
|
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 |
|
|
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Tue Dec 23, 2003 11:58 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Dec 24, 2003 9:23 am Post subject: |
|
|
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 |
|
|
abracadabra Beginner
Joined: 02 Sep 2003 Posts: 101 Topics: 55 Location: India
|
Posted: Fri Jan 02, 2004 5:32 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sun Jan 04, 2004 12:03 pm Post subject: |
|
|
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 |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Sun Jan 04, 2004 4:54 pm Post subject: |
|
|
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 |
|
|
|
|