PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: James Padgett on November 19, 2010, 02:25:15 PM

Title: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: James Padgett on November 19, 2010, 02:25:15 PM
Where should I put DIM gmstuff AS GLOBAL ?

Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: Rolf Brandt on November 19, 2010, 03:02:02 PM
Depending on the size of your project you probably will have a code module in your project. You can put Globals at the beginning of that module. Since I have often more than one code module in my projects I usually add a module with the name 'modGlobal' to project where I keep them.
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: James Padgett on November 19, 2010, 03:25:07 PM
Nevermind...

I didn't know I would have to DIM a global in every function...  I thought once done that it was done.
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: Elias Montoya on November 19, 2010, 03:47:07 PM
 You dont have to. You just define like this at the top of your code:

GLOBAL MYARRAY() AS LONG         (OR WHATEVER TYPE)

Then at the entrance of your program do this

DIM MYARRAY(1 TO 100) AS GLOBAL LONG.

Then it will be global for any module, except threaded.
The trick is do do this before any module or submodule uses the array,
otherwise the program will crash.

Since you used DIM i assumed you were talking about arrays...
For simple variables its easier... just add this:

GLOBAL MyVar AS LONG
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: James Padgett on November 19, 2010, 04:17:30 PM
I put it in the FF_AppStart section...

Sometimes you just can't see the forest for the trees....
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: Eddy Van Esch on November 22, 2010, 07:32:58 AM
Quote from: James Padgett on November 19, 2010, 04:17:30 PM
I put it in the FF_AppStart section...
Where can I find FF_AppStart..?

Kind regards
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: Rolf Brandt on November 22, 2010, 07:34:54 AM
In the FireFly Workspace - Special Functions section.
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: Eddy Van Esch on November 22, 2010, 08:02:25 AM
Got it, Rolf. Thanks!

Kind regards
Title: Re: Stupid Question Time- Where do I put GLOBAL DIM's
Post by: Paul Squires on November 24, 2010, 05:59:42 PM
Yeah, I usually put all of my globals in the FF_AppStart, or #Include a file containing the globals into FF_AppStart. It is easier than having them scattered throughout the project. You could also do as Rolf does (and I have also done in the past) and create a module specially to hold the globals (ie  modGlobals.inc)