[futurebasic] Global and Local Problems

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 1999 : Group Archive : Group : All Groups

From: TacitR@...
Date: Wed, 21 Apr 1999 20:11:42 EDT
After having spent quite a while tearing my hair out, I can safely say that 
the global variable problem I mentioned here before appears to be a problem 
with the FutureBasic compiler. To recap: After a (large) program I've written 
has been running on a G3 machine for some time, global variables suddenly act 
like constants; eg, a program with a global variable foo in a structure like 
this (note that in my "real" code, the global that's breaking is actually a 
21-element array):

LOCAL FN BAR
foo=foo+1
if foo>20 then foo=1
END FN

LOCAL FN BAZ
print "foo=";foo;
END FN

foo=1
REPEAT
FN BAR
FN BAZ
UNTIL 1=0

will on some G3 machines eventually hit a point where the output looks like 
this
foo=4 foo=5 foo=6 foo=7 foo=7 foo=7 foo=7 foo=7 foo=7.......

This problem appears to affect only G3-equipped machines, and more 
specifically only G3s with 1MB of backside cache, leading me to believe that 
it's a cache-related issue.
 
So: Anybody out there have FB code to flush a G3 cache? (I know how to do it 
on an 040, but that doesn't help me here.)
 
Also, you might be interested to know that one workaround I've found, which 
goes something like this:

LOCAL FN BAR
dim temp
temp=foo+1
if temp>20 then temp=1
poke long (@foo),temp
END FN

solves the problem AND speeds the program up DRAMATICALLY. So is it just me, 
or is there some serious wonkiness going on in the way FB compiles code to 
handle global variables?

Franklin