Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between index and subscript?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What the difference is between continue and next sentence?

1155


please..could u give an example about USAGE IS POINTER ..and explain why and when we use it ?

2457


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

2463


Differentiate between structured cobol programming and object-oriented cobol programming.

1139


A table has two indexes defined. Which one will be used by the SEARCH?

1278


What is the use of intialize verb?

1234


How do you reference the following file formats from cobol programs?

1149


Are you comfortable in cobol or jcl?

1034


what is s000 u4087 error? please give the all error codes in cobol,jcl.

17862


what happens if parmparameter passes zero bytes to the program

2121


State the various causes of s0c1, s0c5 and s0c7.

1072


how do you reference the esds vsam file formats from cobol programs

1202


How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?

2570


What is the utilization of copybook in cobol?

1179


Write the code implementing the perform … varying.

1053