Can anybody give me example of subscript and index

Answer Posted / billyboyo

In IBM Cobol there are two methods of accessing elements in
a table (array). By subscript, which you explicitly define
in the Data Division or by index, which is implicitly
defined by the compiler.

01 subscript-for-table COMP PIC S9(4).

If you want the 20th item, set the above to 20 and use
field-looked-for (subscript-for-table).

An index is the displacement of an item from the start of a
table. For a subscript, the displacement, which is needed
to find the item, is calculated at run time (from the
subscript and the length of the data item(s)). So an index
is faster, but is generally considered more complex to use.
Some features, like SEARCH ALL, require the use of an INDEX.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name the sections present in data division.

793


what is the use of outrecord?

1858


2 input fles: 2 flat files, with different number of records. both are having unique key for each record and already sorted in ascending order . match these files using unique key and in output only matching key value has to be written. please procide cobol logic

2257


What is the difference between PIC 9.99 and PIC9v99?

904


What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?

797






What is inspect in cobol ?

881


Can we redefine the field of x(200) to less than 200?

955


What is length is cobol?

750


how to refer the data field?

1902


Write a program to enter and display the names of students in a class using the occurs clause.

774


what is search and searchall?what is the diffrence between them?give an best example?

5874


how to convert the recors form vsam file to db2 table tru file aid

2853


i want a program using by if, evaluate , string, unstring, perform, occurs?

4190


How you can characterize tables in cobol?

817


1.give the details about WHEN OTHER. 2. how many form are available in evaluate.

1716