Marco:

A useful alternative, which noone has ever fixed in over 25 years, is the
message:

 [B10] in program "MyProgram", Line 106: Variable has not been assigned a
value; zero used.

     or

 [B10] in program "MyProgram", Line 106: Nonnumeric where numeric required;
zero used.


Why in the world hasn't it been fixed to display:

 [B10] in program "MyProgram", Line 106: "InvoiceNo" has not been assigned a
value; zero used.

     or

 [B10] in program "MyProgram", Line 106: "InvoiceNo" = "A"; Nonnumeric where
numeric required; zero used.

Stupid questions for the exasperated business developer?

Bill

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Martin Phillips
> Sent: Wednesday, March 03, 2004 12:42 AM
> To: U2 Users Discussion List
> Subject: Re: [UV] Variable never assigned a value warning
>
>
> Marco,
>
> The easy answer is no.  This would require the compiler to establish all
> possible paths through a program and determine whether it was possible to
> arrive at any place that uses a variable without setting it
> first.  Although
> some compilers (many C compilers for example) make a good attempt at this,
> there are always cases that cannot be resolved.
>
> As a very simple example, consider the following:
>
> BEGIN CASE
>    CASE A = 1
>        B = 'Apple'
>    CASE A = 2
>        B = 'Orange'
>    CASE A= 3
>        B = 'Banana'
> END CASE
> DISPLAY B
>
> Clearly, if A is not 1, 2 or 3 B will not be assigned when we get to the
> DISPLAY statement.  But, the compiler cannot treat this as an
> error/warning
> because the author of the program may know that A can only have these
> values. We do not want to have to set variables explicitly for cases that
> cannot happen.
>
> 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  I am told that a UV user somewhere has asked for
> this trap to be optional.  I wouldn't like to try to support their code!
>
> Martin Phillips
> Ladybridge Systems
> 17b Coldstream Lane, Hardingstone, Northampton NN4 6DB
> +44-(0)1604-709200
>
> ----- Original Message -----
> From: "Marco Manyevere" <[EMAIL PROTECTED]>
> Subject: [UV] Variable never assigned a value warning
>
>
> > Hi All,
> >
> > Is it technically or theoretically possible for the BASIC
> compiler (or any
> other compiler for that matter) to catch (during compilation) all the
> situations that might result in the use of unassigned variable at runtime
> within the scope of the subroutine being compiled? Under what
> circumstances
> does the compiler catch or fail to catch such situations?
>
> --
> u2-users mailing list
> [EMAIL PROTECTED]
> http://www.oliver.com/mailman/listinfo/u2-users

-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to