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

Find out the uninitialized variable in COBOL program?


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

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 22, 2007 10:19 am
Reply with quote

Hi all,

Is there any way to find out uninitialized variable in a program? Do those variable will be displayed somewhere in the job after compilation. Please let me know if there is any way to find it out

Regards
Sujatha
Back to top
View user's profile Send private message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Thu Nov 22, 2007 10:47 am
Reply with quote

As per my knowledge, it will not be displayed. It would be a logical error in the code. What do others say?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Nov 22, 2007 11:00 am
Reply with quote

Sujatha,

Quote:
Is there any way to find out uninitialized variable in a program?

Do you mean 'unused' variable in a program?

If you are looking for above, see the warning messages during compilation process.
Back to top
View user's profile Send private message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 22, 2007 11:09 am
Reply with quote

No not the unused variable.
For Example: In a Program "A"......

01 name pic x(5) value 'hello' ------ this is initialized variable

01 age pic 9(2). ----- This is un initialized variable.

I want to know is the variable AGE will be displayed somewhere in the compile listing
Back to top
View user's profile Send private message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Thu Nov 22, 2007 12:25 pm
Reply with quote

It will not be displayed
Back to top
View user's profile Send private message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 22, 2007 12:37 pm
Reply with quote

Can u tell me is there any other way to make it display ?
Back to top
View user's profile Send private message
VinayCM

New User


Joined: 06 Nov 2007
Posts: 36
Location: Bengaluru

PostPosted: Thu Nov 22, 2007 12:45 pm
Reply with quote

Sujatha,
There is no way to display uninitialized variable.. You can find out unused variables.
Back to top
View user's profile Send private message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Thu Nov 22, 2007 1:05 pm
Reply with quote

May be, you can write a tool for that!!! That would be the solution to find out the uninitialized variables.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 1:52 am
Reply with quote

Edit your pgm in ISPF.

On the cmd line enter: x all; f ' pic';x all ' value '

What remains displayed s/b the "uninited" variables.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Nov 28, 2007 2:02 am
Reply with quote

mmwife wrote:
Edit your pgm in ISPF.

On the cmd line enter: x all; f ' pic';x all ' value '

What remains displayed s/b the "uninited" variables.


What about
1. items with pic on one line and value on the next
2. items with that are part of a redefines
3. LINKAGE Section
4. items defined in copy or includes?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 7:44 pm
Reply with quote

Quote:
What about
1. items with pic on one line and value on the next
2. items with that are part of a redefines
3. LINKAGE Section
4. items defined in copy or includes?


1. You're right. Add "a f all ' value '"
2. No value allowed in a redef.
3. LS only carries received items (no "value" allowed). Value in caller.
4. He's screwed unless he wants to copy the expanded compiler listing to ISPF or he could do the same thing to the copybk(s).
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Nov 28, 2007 7:55 pm
Reply with quote

[quote="mmwife"]
Quote:
2. No value allowed in a redef.
3. LS only carries received items (no "value" allowed). Value in caller.


But first he has to determine that it is a redefinition or LINKAGE Section item.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 9:00 pm
Reply with quote

I guess it all depends on the details of what he's attempting to do.

He could always put another "find all" or 2 in the mix.

But then there's the ques of the INIT verb, move spaces, etc.

As I said it's in the details. And these are ques he's got to ans, if he's interested enough.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Nov 28, 2007 10:59 pm
Reply with quote

The problem is theoretically impossible.

If I could write a program to see if a given variable would ever have a value assigned to it, then I could solve the Halting Problem for Turing Machines (see any intro book on authomata theory) in the following way:

I'll write a program SIM to input another program PGM and its data, then simulate PGM. If the simulation halts, then SIM will initialize one of a own variables HALTED; otherwise, it won't.

Now, if I have a program INITTED that can tell if a variable in another program is ever initialized, I'll just run INITTED on SIM. If SIM initialized its variable HALTED, then I know the simulation halted, and therefore PGM halted.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 11:58 pm
Reply with quote

Phil,

You might be right, but I think it's simpler than that: he just wants to know the fields that don't have an associated VALUE clause.

But, then again, maybe not.
Back to top
View user's profile Send private message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 29, 2007 4:05 pm
Reply with quote

Thanks For all the reply

So the final solution is to write a COBOL pgm which has to list all the un initialized variable. I am rite?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Nov 30, 2007 1:13 am
Reply with quote

Hello,

You can surely write COBOL code that will parse other COBOL code.

It may not be so straight forward to get the exact results you want (please refer to the earlier discussion).

While you are working on the code and there are questions/problems, if you post them here, we may be able to offer suggestions.

Keep in mind that reference modification is your friend icon_wink.gif
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top