[futurebasic] Re: [FB] Boolean variable = 48 instead of 0

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2003 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Thu, 13 Mar 2003 16:06:43 -0500
On Thursday, March 13, 2003, at 01:03  PM, Rich Love wrote:

> Thanks for all of your suggestions.
> None of them worked but it got me to dig deeper into the problem and 
> solve it.
> It was caused by a string variable that was incorrectly dimensioned 
> just prior to the boolean variable.
> The string variable was dimensioned for one character but in fact 
> needed to be dimensioned for two characters.
>
> As soon as the string variable was assigned a value two characters 
> long, it corrupted the boolean variable and changed it from zero to > 48.
>
> Like this:
> DIM 1 gStringVar$
> DIM gTestVar AS BOOLEAN
>
> gStringVar$ = "12"   ' this corrupts gTestVar because gStringVar$ can 
> only hold one character not two
> PRINT gTestVar   ' this now = 48
>

Good that you found it, and also it makes for your observation of an 
ASCII value as being correct, no?

As Dr. Spencer says, Array overrun pref might be the ticket. Just run 
your program through the paces with it on before final release, and 
then turn it off for the final build.

It catches a world of hurt...sometimes an array overruns and the 
initial symptom is -nothing-...but causes hard to track bugs down the 
road (horrid).  Other times,  an overrun instantly kills a program. In 
the latter, it is an easy bit of detective work with the setting 
on...in the former, you finally get a fix for what can manifest as 
mysterious program instability.

I say all this from experience, as the byte is worse than the bark of 
an error dialog. :) That's no bool. :)


Robert Bob