Professional Documents
Culture Documents
Indexand Subscrpt
Indexand Subscrpt
Message
Post subject: How to define and
HOW TO DEFINE ARRAY IN COBOL. SUPPOSE I HAVE DEFINE NY ARRAY LIKE THIS 01 WS-TABLE ONE 05 WS-TABLE ONE OCCURS 10 TIMES PIC X(10). HOW CAN WE ACCES 5th ELEMENT OF THIS TABLE USING SUBSCRIPT AND INDEX? PLS GIVE ME EXAMPLE
Back to top
<>
DavidatK
Active Member Posted: Wed Oct 04, 2006 10:35 pm and access an array in COBOL Post subject: Re: How to define
Rajeev, I'm not sure if I understand your syntax. Define and use a cobol table like this:
Code: 01 WS-TABLE. 05 WS-TABLE-ENTRY PIC X(10) OCCURS 10 TIMES. 05 WS-TABLE-SUBSCRIPT PIC S9(3) COMP-3. MOVE 5 TO WS-TABLE-SUBSCRIPT. DISPLAY WS-TABLE-ENTRY(WS-TABLE-SUBSCRIPT). (or) DISPLAY WS-TABLE-ENTRY(5).
Dave
Back to top MFRASHEED
Active User Posted: Wed Oct 04, 2006 11:27 pm and access an array in COBOL Post subject: Re: How to define
If you want to process all elements then use PERFORM VARYING INDX-1 FROM +1 BY +1 just like how you would with sub-script variable.
Back to top karnataka
New User
Post subject:
IDENTIFICATION DIVISION. PROGRAM-ID. OCCURPGM. DATA DIVISION. WORKING-STORAGE SECTION. 01 ARRAY2. 02 OCCUR2 PIC 9(2) OCCURS 10 TIMES. 01 I PIC 9(2) VALUE 1. 01 VAR2 PIC 9(4) COMP-3. 01 SUB PIC 9(2) VALUE 1. PROCEDURE DIVISION. MAIN-PARA. PERFORM 100-ACCEPT-PARA. PERFORM 200-DISPLAY-PARA. STOP RUN. 100-ACCEPT-PARA. PERFORM UNTIL I = 10 MOVE I TO OCCUR2 ( SUB) ADD 1 TO I ADD 1 TO SUB END-PERFORM.
Post subject:
hi,
the above code is to access 5th element of array using subscript . just check it out wheather it fullfil your request. plz let me know if its wrong........ thanks..
Post subject: