View previous topic :: View next topic
|
Author |
Message |
sanaathana
New User
Joined: 23 Nov 2006 Posts: 3 Location: India
|
|
|
|
Is it possible to predict the value of an uninitialized alphanumeric variable's value?
IF TABLE-SW = 'N'
THEN
NEXT SENTENCE
ELSE
PERFORM 100-INITIALIZE THRU 100-EXIT.
Here TABLE-SW is not initialized anywhere.
How is the value predicted?
Thanks a lot!! |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi sanaathana,
We cant predict the value of a variable if it is not initialized & does not have any value clause. |
|
Back to top |
|
|
sanaathana
New User
Joined: 23 Nov 2006 Posts: 3 Location: India
|
|
|
|
Isn't there any fill value clause or something equivalent during compilation time?
Does this mean that the programmer of the above piece of code expected the random/junk value present in the uninitialised variable to not be 'N'? |
|
Back to top |
|
|
surya_pathaus
Active User
Joined: 28 Aug 2006 Posts: 110
|
|
|
|
Hi,
I think when alphanumeric field is not intialized then it will take "LOW VALUES". |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Surya,
I dont thk so? |
|
Back to top |
|
|
sanaathana
New User
Joined: 23 Nov 2006 Posts: 3 Location: India
|
|
|
|
Ekta, I think uninitialized alphanumeric variables will have low-values. Noticed this -uninitialised AN vars having low-values- in 2 cases . There might be some catch to this though.
I'll try to confirm this.
Thanks Ekta and Surya! |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
The following was stated from IBM's E COBOL reference manual in the link below:
Quote: |
In the working-storage section, the VALUE clause can be used in condition-name entries, or in specifying the initial value of any data item. The data item assumes the specified value at the beginning of program execution. If the initial value is not explicitly specified, it is unpredictable. |
From personal experience, in MOST cases it is LOW-VALS, but I wouldn't bet the farm on it.
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGY3LR10/5.3.17?SHELF=&DT=20020920180651&CASE= |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
In the (really) old days, all programmers pre-initialized working storage.....
Later there were releases of COBOL that insured clear low value working storage and most newer programmers knew that they could trust that fact....
Then along came LE and it did not automatically provide cleared storage and that really messed up, among other things, CICS maps......
There is a LE parm that forces LE to provide cleared storage and nowadays most shops have it so..... |
|
Back to top |
|
|
|