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

What is the value of an uninitialized alphanumeric variable?


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

New User


Joined: 23 Nov 2006
Posts: 3
Location: India

PostPosted: Thu Nov 23, 2006 12:55 pm
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Nov 23, 2006 1:03 pm
Reply with quote

Hi sanaathana,

We cant predict the value of a variable if it is not initialized & does not have any value clause.
Back to top
View user's profile Send private message
sanaathana

New User


Joined: 23 Nov 2006
Posts: 3
Location: India

PostPosted: Thu Nov 23, 2006 1:47 pm
Reply with quote

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
View user's profile Send private message
surya_pathaus

Active User


Joined: 28 Aug 2006
Posts: 110

PostPosted: Thu Nov 23, 2006 2:26 pm
Reply with quote

Hi,

I think when alphanumeric field is not intialized then it will take "LOW VALUES".
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu Nov 23, 2006 2:51 pm
Reply with quote

Hi Surya,

I dont thk so?
Back to top
View user's profile Send private message
sanaathana

New User


Joined: 23 Nov 2006
Posts: 3
Location: India

PostPosted: Thu Nov 23, 2006 3:26 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Nov 23, 2006 10:22 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Nov 23, 2006 11:03 pm
Reply with quote

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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top