What is the difference between index and subscript?
Answers were Sorted based on User's Feedback
Answer / jkb
Index represents the displacement value of the table entry
from the beginning of the table whereas subscript is the
occurrence number of the table entry.
To calculate the displacement of the table entry from its
beginning when subscript is used takes 16 additional
instructions from the system because of that the usage of
the index is more efficient.
An index can only be modified using PERFORM, SEARCH & SET.
Need to have index for a table in order to use SEARCH,
SEARCH ALL.
Is This Answer Correct ? | 25 Yes | 3 No |
Answer / harish
subscript normal variable dec in w-s section.
index cant
subscript can be accepted or displayed
for index set index up by value down by value..
subscript- arithmetic operation is possible..
subscript refers to array occurance,
index refers to the displacement of start of the array
pls correct me if anything wrong
HARISH POOMGAME SHIVAPPA(hassan,karnataka)
NIIT TECHNOLOGY
KOLKATA
Is This Answer Correct ? | 17 Yes | 5 No |
Answer / vamsi krishna g
subscript is occurence type like arrays so if u want to
dispaly a value of it means it will search for it from
begining
indexed:
if u want to dispaly a value of an vairable it will
directly diplaces to that value and display the value
so from this we can say
subscript is an occurance type and indexed is displacement
type
if any wrong means please update me
Is This Answer Correct ? | 12 Yes | 2 No |
Answer / manjunath
ubscript - Subscript is used to access elements in array.
Index also used for the same purpose.
Ex. 01 WS-GROUP.
05 WS-MONTH PIC X(3) OCCURS 12 TIMES.
To access 2nd month we sepcify WS-MONTH(2).
Value enclosed in brackets is called subscript ( in this case 2 ).
You can use INDEX for the same.
Ex. 01 WS-GROUP.
05 WS-MONTH PIC X(3) OCCURS 12 TIMES INDEXED BY WS-INDX.
In above example WS-INDX is a INDEX data item.
we can use this variable to access the elements in the array.
If you want to access 2nd element in the array. need to write the code as follows
SET WS-INDX TO 2.
DISPLAY " 2nd element in array " , WS-INDX.
An index is similar to a subscript, but internal value in the variables are different..
Normaly subscript refer the occurance number of the item in array. in our example that is 2. means to refer second occurance we use number 2.
In case of index, to refer second element of your array, it shoud contains value of displacement from the starting of the arrary. i.e, in our example we used SET command to set value in index field WS-INDX. after execution of this command
WS-INDX contain the value 3. To refer third element it should contains the value of
6, for fourth element it should contain the value of 9 ( in our example array element size is 3 ).
Is This Answer Correct ? | 1 Yes | 0 No |
How to know whether the module is dynamical or statistical?
How to read records in reverse order in flat file? I know we can do it by reading all records into an array.... Then read records in reverse order by using subscript or index but can any body give me the exact code.
how to display date in reverse order if the pic clause of the is numeric suppose date is 09032010 ==> need to print in 20100309 (pic clause is numeric)
If we use GO BACK instead of STOP RUN in cobol?
how do u list the abended jobs?
How are the next sentence and continue different from each other?
consider the fallowing 77 stat pic 9. 88 male value 1,2,3. 88 female value 4 through7. what will be the value of stat a) set male to true. b) set female to true.
The maximum number of dimensions that an array can have in COBOL-85 is ?
What is the size of s9(19)comp3? explain
How do you get the data to code the BMS macro?
what is the difference between Normal vaiable and comp variable.
Re: 01 NAME1 PIC X(13) VALUE "COBOL PROGRAMMING". 01 NAME2 PIC X(13). now I want to display the value of NAME1 in reverse order i.e value should be displayed as "GNIMMARGORP LOBOC" HOW can I do that ??? please let me know if any one knows it.