View previous topic :: View next topic
|
Author |
Message |
sudha_shanmughan Currently Banned New User
Joined: 20 Feb 2007 Posts: 9 Location: chennai
|
|
|
|
Hi All,
what is the difference between indexing and subscripting? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi There,
Subscript:Subscript represents occurrence # of the Table Entry. Subscript can be represented explicitly and implicitly. Explicitly means thru occurrence # of the table entry; implicitly means thru a data name. That data name should be defined as an independent item in the W-S Section. The most efficient definition of Subscript is Full-Word binary.
Index:Index is assigned to specific table thru INDEXED BY clause. Internally is represented by Index Register which is Full-Word binary. Specific index name can be used to reference a field from the table to which that index is assigned to index represents displacement value of the table entry from the beginning of the table.
Difference between index & subscript
1)Index represent displacement value of the table entry from the beginning of the table, subscript - occurrence # of the table entry.
2)An index can only be modified using PERFORM, SEARCH & SET
But we can modify subscript by ADD , SUBTRACT COMPUTE
statements also.
3)Need to have index for a table in order to use SEARCH, SEARCH ALL Cobol statements |
|
Back to top |
|
|
kshalini
New User
Joined: 20 Feb 2007 Posts: 8 Location: Banglore
|
|
|
|
Can somebody explain with soem example its not very clear from above reply |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Kshalini,
Hi there,
Subscript:Here it declare WS-TABLE-SUBSCRIPT is used as subscript.
Which we need to declare explicitly in working storage & we can directly do any arithmetic operation on it
Code: |
01 WS-TABLE.
05 WS-TABLE-ENTRY PIC X(10) OCCURS 10 TIMES.
05 WS-TABLE-SUBSCRIPT PIC S9(3) COMP-3. |
Code: |
MOVE 5 TO WS-TABLE-SUBSCRIPT.
DISPLAY WS-TABLE-ENTRY(WS-TABLE-SUBSCRIPT).
(or)
DISPLAY WS-TABLE-ENTRY(5). |
Index:Here TEST-TAB is indexed by INDX-1 index.We need not to declare it in working storage.
Code: |
01 TEST-TABLE.
05 TEST-TAB OCCURS 10 TIMES
INDEXED BY INDX-1.
10 TEST-DAT1 PIC X.
10 TEST-DAT2 PIC X.
To reference a particular element in table use SET clause
Code:
SET INDX-1 TO +5
DISPLAY TEST-DAT1(INDX-1) |
Hope it is clear now |
|
Back to top |
|
|
abel Warnings : 1 New User
Joined: 31 May 2006 Posts: 5
|
|
|
|
Can you explain how does memory allocated for Subscript and Index
because in index we don't give any picture value
and how does sub and indes varies in calling suppose ab(I). |
|
Back to top |
|
|
kshalini
New User
Joined: 20 Feb 2007 Posts: 8 Location: Banglore
|
|
|
|
Thanks |
|
Back to top |
|
|
|