May 04, 2024, 04:44:34 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


GLOBAL variables not recognized

Started by novi, February 24, 2011, 05:41:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

novi

I am trying to create project which is in multiple source files.  Compiling and using subs from other source files works in the main file but I can not get the compiler to recognize my GLOBAL variables from the main file in my other added source files.  For example I need the GLOBAL WINDOW win_main variable to be defined also in the other source files so commands to the window will work in those other files.

Thanx for any help,
cheers.

LarryMc

February 24, 2011, 06:05:47 PM #1 Last Edit: February 24, 2011, 06:08:07 PM by LarryMc
The PROJECTGLOBAL preprocessor switch allows using the same file to both define project-wide globals and define them as external when the file is $included into other project files.  for variables you want global

create a file called Globals.iwb (or eba) and put the following in it
'global variables accessable to all modules
PROJECTGLOBAL "on"
 window mywindow
 int blah
 string blahblah
PROJECTGLOBAL "OFF"

add the file to your project
Add the following line to the top of every other source file in your project
$include "globals.iwb"  ' or eba

-----------------------------------
for subs

create sub
global sub test(int param),int
'...blah blah
return x
endsub

In every other source file where you want to use the sub enter this line at the top of the source file
declare extern test(int param),int

Pretty simple and it is going to be even simpiler for global subs in ver 2.0

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library