COBOL Initialize
Working-Storage for Example 1 and 2
000340 01 CAT-AND-DOG. 000350 05 CAT PIC 9. 000360 05 DOG PIC X.
Initialize Example Number 1 - Initialize a PIC 9 and a PIC X field
004310 004320 INITIALIZE CAT. 004430 INITIALIZE DOG. 004440
Initialize Example Number 2 - Initialize a PIC 9 and a PIC X field
004310 004320 INITIALIZE CAT-AND-DOG. 004440
Working-Storage for Example 3
000340 01 CATS-AND-DOGS-GROUP. 000350 05 CATS-AND-DOGS OCCURS 10. 000350 10 CATS PIC 9. 000360 10 DOGS PIC X.
Initialize Example Number 3 - Initialize a table
004310 004320 INITIALIZE CATS-AND-DOGS. 004440
| Sign In |
| to add your own comment |
| Comment by TheMadProfessor Rate this Comment |
Actually, INITIALIZE has an optional REPLACING clause (albeit one I've seldom seen used):
|
| Comment by archive Rate this Comment |
Just wanted to write ;)
|
| Comment by archive Rate this Comment |
Thanks for the site. It is very helpful & straightforward.
|
| Comment by dsiebel Rate this Comment |
The Example 3 code is invalid: the OCCURS clause cannot be on the 01 level. |
| Comment by Larry Rate this Comment |
You can use initialize on group or non group items. Try it out, it's always possible that whatever compiler you are using doesn't accept it for some reason. I've only used initialize on IBM mainframe and compliant systems.
|
| Comment by archive Rate this Comment |
The INITIALIZE statement may only be used on group items is this TRUE or FALSE? why? |
| Comment by archive Rate this Comment |
You might want to mention that use of the INITIALIZE statement on a variable that uses a VALUES clause will cast the type and not the content.
|
| Comment by archive Rate this Comment |
I was told to stop using this instruction because it was placing binary zeroes in some fields.
|