Stupid Question Time- Where do I put GLOBAL DIM's

Started by James Padgett, November 19, 2010, 02:25:15 PM

Previous topic - Next topic

James Padgett


Rolf Brandt

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.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

James Padgett

Nevermind...

I didn't know I would have to DIM a global in every function...  I thought once done that it was done.

Elias Montoya

#3
 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
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

James Padgett

I put it in the FF_AppStart section...

Sometimes you just can't see the forest for the trees....

Eddy Van Esch

Eddy

Rolf Brandt

In the FireFly Workspace - Special Functions section.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Eddy Van Esch

Eddy

Paul Squires

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)
Paul Squires
PlanetSquires Software