What does the initialize statement do ?

Questions by sprabodhini

Showing Answers 1 - 9 of 9 Answers

Hi

Initailize verb initiallizes(empty) the data items.  Alphabetic, Alphanumeric fields & alphanumeric edited items  are set to SPACES.  Numeric, Numeric edited items set to ZERO.  FILLER , OCCURS DEPENDING ON items left untouched. 

  Was this answer useful?  Yes

sujithdan

  • Mar 7th, 2011
 

INITIALIZE is basically used to initialize or set the initial value of variables that we use in a COBOL program. For numeric variables (PIC (9) ), the value of the variable will be initialized to zero while for non-numeric(alphabetic/alphanumeric ie.PIC X (9)) the value will be initialized to SPACES. The main advantage of using INITIALIZE is that you can ensure that even from the starting point of your program no garbage values (unwanted values that may be in memory that is used by your COBOL variable)are present in the variable. Thus if no value is added/moved to the variable we will just get a zero(for numeric) and SPACES(for alphanumeric variables). This makes it easy for debugging too rather than checking garbage values, which is just any value,that can arise confusion.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions