[futurebasic] Re: [FB] Global Trick, Was: GWorlds, Edit Fields...

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

From: Jamin <benjamen@...>
Date: Thu, 5 Aug 1999 09:48:57 +1000
Paul Bruneau said something like:

> Also, still no clue as to what to do about my giant 20K global records
> which keep my includes from compiling when they get to the "globals"
> area. Help?
>

How about defining a structure like so:

DIM RECORD MyGlobals
  DIM myVar$
  DIM myOtherVar%
etc..
DIM END RECORD.MyGlobals

And a pointer that will lead to it:

DIM gGlobalsPtr&

But don't create an instance of the struct in your globals file.  Then, in the init stage of your app, create a new pointer for your structure:

gGlobalsPtr& = FN NewPtr _Clear(_MyGlobals+4)

Now you can setup all the values in the struct, and any include can get at then using the offset notation:

theVarIWant% = gGlobalsPtr&.myOtherVar%

This way the globals don't have to sit in the first 32k as per normal, and the definitions don't take up any room.

Jamin