View previous topic :: View next topic
|
Author |
Message |
SUJATHAA
New User
Joined: 26 Sep 2007 Posts: 7 Location: CHENNAI
|
|
|
|
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 |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
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 |
|
|
SUJATHAA
New User
Joined: 26 Sep 2007 Posts: 7 Location: CHENNAI
|
|
|
|
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 |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
It will not be displayed |
|
Back to top |
|
|
SUJATHAA
New User
Joined: 26 Sep 2007 Posts: 7 Location: CHENNAI
|
|
|
|
Can u tell me is there any other way to make it display ? |
|
Back to top |
|
|
VinayCM
New User
Joined: 06 Nov 2007 Posts: 36 Location: Bengaluru
|
|
|
|
Sujatha,
There is no way to display uninitialized variable.. You can find out unused variables. |
|
Back to top |
|
|
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
May be, you can write a tool for that!!! That would be the solution to find out the uninitialized variables. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
[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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
SUJATHAA
New User
Joined: 26 Sep 2007 Posts: 7 Location: CHENNAI
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
Back to top |
|
|
|