Undefined variables sometimes compile ok in FF

Started by John Waalkes, June 29, 2010, 03:21:17 PM

Previous topic - Next topic

John Waalkes

I'm cleaning up a bit of code that I've been working on and came across some strange behavior in FF3.

I've temporarily commented out my variable declarations to let the compiler error out on the ones that I need (and then I uncomment that declare).

So I have this in a function:

'Local i&

But then I use i& later on in the same function:

   For i& = 1 To UBound(DiscoveredNodes)
      If LTrim$(DiscoveredNodes$(i&)) = s$ Then
         Exit For
      End If
   Next i&


This obviously shouldn't happen (and it hasn't been declared as a Global anywhere either), is it a FF3 problem, or is it a PB9 problem?

Oddly enough, the compiler (or FF3) caught some of them (i& wasn't the only undeclared variable that slipped through), but not others.


Thanks :)


John

Roger Garstang

Been forever since I've used type specifiers, but in putting a & aren't you declaring it as a Long?  Also, you need DIM ALL to force it too.  The ones with issue may have been syntax errors.

John Waalkes

Quote from: Roger Garstang on July 01, 2010, 12:49:12 PM
Been forever since I've used type specifiers, but in putting a & aren't you declaring it as a Long? 

Yeah, it's the same thing, it's just a matter of preference. I suffer from CRS (Can't Remember Stuff), so having the variable type staring me in the face helps me keep track of what I'm working with.


Quote from: Roger GarstangAlso, you need DIM ALL to force it too.  The ones with issue may have been syntax errors.

That was it. It was commented out.  :-[