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

Content of variable before moving or initializing


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

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Fri Feb 10, 2012 9:52 am
Reply with quote

I have a varible defined as below.

05 WS-EMP-SALARY PIC S9(13)V9(02) COMP-3.

What value will be there in this variable before initializing or moving any value to this?

If I move Zero to this variable and check for Numeric as below, what will be the outcome? T or F

IF WS-EMP-SALARY NUMERIC

Thanks
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Fri Feb 10, 2012 10:15 am
Reply with quote

Why don't you write a simple program and check it yourself. You can always post your findings to help others with same set of questions.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Feb 10, 2012 12:08 pm
Reply with quote

You could also read the manuals or any primer on programming languages.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Feb 10, 2012 1:09 pm
Reply with quote

The questions are so basic, or so odd, there must be something else behind them. Why don't you tell us what the problem is, not your far-fetched analysis of it.
Back to top
View user's profile Send private message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Fri Feb 10, 2012 3:27 pm
Reply with quote

I have tried this. just declared variable is having zeros only. I just wanted to cofirm if it is always true.

for second question, yes its numeric.. I tested

thanks
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Feb 10, 2012 3:44 pm
Reply with quote

Unless you actually do something with your variable the storage it occupies will remain as it was before your program started - in general but some environments may pre-initialise storage but I do not know which (if any).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Feb 10, 2012 3:52 pm
Reply with quote

Look in the manuals.

If you define storage without an initial value, you'd be a fool to rely on its content before putting something else into it.

For this one, I don't care how often you test it. Read the manual. Believe it.

For your particular set-up you may get predictable results. Since this is in conflict with the manual and you don't know how that comes about, I don't suggest you rely on it even at your site. You may also get what look like predicatble results but turns out to be coincidence.

If you even think of relying on the value of unitialised storage I will have to get a thesaurus out, look up fool, include all those in a piece of text and add what assorted colloquialisms I can come up with as welll
Back to top
View user's profile Send private message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Fri Feb 10, 2012 4:25 pm
Reply with quote

Now I got answer. it may be some junk values also.. need not be zero.. thank you Nic.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Feb 10, 2012 5:45 pm
Reply with quote

The answer to your question can only be provided by someone working at your site. There are options, for example, that can be set to initialize memory to zeroes (LOW-VALUES in COBOL terms) or any other desired value -- but these options are site-dependent and no one on this forum could possibly tell you how your site is configured.
Back to top
View user's profile Send private message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Fri Feb 10, 2012 6:19 pm
Reply with quote

Thanks for reply Robert.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Fri Feb 10, 2012 6:37 pm
Reply with quote

Not only site-dependent, but are subject to change over time. What works today, may not work tomorrow, even at the same site.
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 Reformat and relocate content DFSORT/ICETOOL 4
Search our Forums:

Back to Top