My query is not on how to suppress the warning messages but on why the compiler  
catches only a few of them. Even the case statement example you gave is in my opinion 
a good candidate for such warning messages because a robust program would have to 
provide for a default case block, something like:
 
LOOP
   GOSUB ASSIGN.A
   BEGIN CASE
      CASE A = 1; B = 'Apple'
      CASE A = 2; B = 'Orange'
      CASE A = 3; B = 'Banana'
      CASE 1; B = 'Something is very wrong here!'
   END CASE
   DISPLAY B
REPEAT

Regards, Marco

"Stevenson, Charles" <[EMAIL PROTECTED]> wrote:
HEAR, HEAR!

> Incidentally, I find the worryingly common practice of 
> setting all variables to zero / null at the top of a program 
> very annoying as it hides the very useful unassigned variable 
> trap, leaving you thinking your program works when actually 
> it doesn't.
> 
> Martin Phillips
> Ladybridge Systems


Yes, this practice HIDES real errors.

I too see it a lot, and I think it is absolutely disgusting.
Maybe the practice originated with programmers who were used to working
in languages where they had to declare variables & var types at the top
of their program. They just felt kinda naked without saying,
I=0;A='';[EMAIL PROTECTED], at the top of their basic code. A poor reason.

Don't do it.

Be aware that the *occasional* such message may hint at a *multitude* of
unreported error incidents. Especially when the error is deep inside an
important loops. Let me illustrate by expanding Martin's example:

LOOP
GOSUB ASSIGN.A
BEGIN CASE
CASE A = 1; B = 'Apple'
CASE A = 2; B = 'Orange'
CASE A = 3; B = 'Banana'
END CASE
DISPLAY B
REPEAT

You will get an "unassigned error" message only if A just happens to not
be 1,2,or 3 on the very FIRST pass through the loop. Subsequent passes
where that occurs would use the value assigned to B on the previous
iteration. UV will be happy to do so.

Initializing B at the top of the program, above the loop, would
eliminate those occasional error message but not eliminate the buggy
code or a fundamental logic flaw.

Try to initialize & assign variables exactly where they apply. Then
watch for error messages that point out your flaws, and be grateful for
them.

Chuck Stevenson
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users
                
---------------------------------
  Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download 
Messenger Now
-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to