IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Is it Initializing an Array?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Aug 04, 2008 4:20 pm
Reply with quote

Hi,

Could anyone explain me what is the following..

Initialize the Large array in Cobol.

05 WS-TEMP.
07 A OCCURS 10 TIMES

INITIALIZE A (1)

MOVE WS-TEMP TO WS-TEMP (LENGTH OF A (1) + 1 : )


Thanks,
~Vamsi
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Mon Aug 04, 2008 4:48 pm
Reply with quote

shreevamsi wrote:
Hi,

Could anyone explain me what is the following..

Initialize the Large array in Cobol.

05 WS-TEMP.
07 A OCCURS 10 TIMES

INITIALIZE A (1)

MOVE WS-TEMP TO WS-TEMP (LENGTH OF A (1) + 1 : )


Thanks,
~Vamsi



I have executed a sample code.
Code:


01 WS-OCCURS.
   10 WS-A1  OCCURS 3 TIMES
                     INDEXED BY I.
      20 WS-A1-1 PIC 9(9).
      20 WS-A1-2 PIC X(9).
01 WS-TEMP PIC 9(01) VALUE 1.

PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3
MOVE WS-TEMP TO  WS-A1-1(I)
MOVE WS-TEMP TO  WS-A1-2(I)
ADD 1 TO WS-TEMP
END-PERFORM.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3
DISPLAY  WS-A1-1(I)
DISPLAY  WS-A1-2(I)
END-PERFORM.
INITIALIZE WS-A1-1(1)
MOVE WS-OCCURS  TO
                WS-OCCURS (LENGTH OF WS-A1-1(1) + 1 : )
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3
DISPLAY  WS-A1-1(I)
DISPLAY  WS-A1-2(I)
END-PERFORM.

And the results are

000000001
1
000000002
2
000000003
3
000000000
000000000
000000000
000000000
000000000
000000000


Finally what i have observed is : It moved zeros to all array variables.

Seniors and Moderators correct me if i am wrong.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts How to move values from single dimens... COBOL Programming 1
No new posts array indexing PL/I & Assembler 4
No new posts COBOL batch program using large size ... COBOL Programming 3
Search our Forums:

Back to Top