[Gambas-user] Documentation

Benoît Minisini gambas at ...1...
Tue Sep 10 20:26:10 CEST 2002


Le Lundi 9 Septembre 2002 14:50, Laszlo Parkanyi a écrit :
> Hi,
> Though the "Gambas Language Encyclopedia" is a useful resource, it would
> be nice to have some further documentation. In fact I'm having trouble with
> some of the basics, like scope of variables, for example. I Simply could
> not figure out how  one can declare a variable that is global for the whole
> application. I declared it in a Modules block, but apparently did not work.
> Modules pose another problem: what functions can be put in a module and how
> can they access variables?
>
> And things like that. I know it is a lot of work, and Gambas is not yet
> complete.
>
> Cheers,
> Laszlo Parkanyi
>

Hi Laszlo,

Variable scope in Gambas is in fact like the Java one, or any good 
object-oriented language. Not Visual-Basic !

So, there is no project global variables in Gambas like in VB. A global 
variable is global to a class or a module. And if you want to access a 
variable outside of its class or module, you must decalre it public.

To do the same thing as VB, declare your global variable in a module, and 
access it via the name of the module. For example,

Module MGlobal.module:
' Gambas module
PUBLIC BirthYear AS Integer
...

Module MMain.module (startup module):
' Gambas module
...
PUBLIC SUB Main()

  PRINT "BirthYear is"; MGlobal.BirthYear

END

Got it ? :-)

-- 
Benoît Minisini
mailto:gambas at ...1...




More information about the User mailing list