[futurebasic] Re: [FB] Overflowed string of len 5 but it's not mine

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2000 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Sat, 12 Aug 2000 08:27:32 +0200

Michael S Kluskens wrote:

> I got a real problem that I can't figure out:
>
> I get a runtime message about overflowing a string with a defined
> length of 5, but I checked every case of "dim 5" by searching for " 5
> " which is the only way I can think how a string could have been
> defined a length of 5 and it's not my string that is getting
> overflowed, in fact I changed all my strings of length 5 to length 8
> and still got the error (the overflow is with a string of length 9).
>
> I also searched for ",5" and ", 5" but no hits.
>
> It's very possible I'm passing a string of length 9 into a FB3
> function that requires a string of length 5 but I can't figure this
> one out.
>
> Can anyone please help.

Hello Mickael,

Don't know if it will help, but the last time I encountered such an error it
was due to the fact that I failed to initialize strings in a LOCAL FN. It got
me some time to figure this out because the prog was running OK on my Mac
until I tried to run it on another one. The weird thing was that running with
the Debugger on the prog was suddenly running OK.
A string contains garbage when a function is entered and probably sometimes,
but not always, right at the address of the string, the memory may hold a byte
that overflows the limit you have defined.
I fixed the bug adding a CLEAR LOCAL statement above the culprit FN, but of
course you can also initialize your string before attempting to use it in any
statement, i.e. noGarbageStr$ = "" or faster noGarbageString$[0] = 0

Cheers

Alain