2009/12/29 Dr. Diesel <dr.die...@gmail.com>: > just there seems no way to make it > global and accessable across different modules/classes.
HA! I had that same logical problem. There is no concept of global in Gabas that matches any variation of VB's idea of global. This is the fault of Microsoft. In the old days there was a concept of "global", but then OO came along and Microsoft haven't been able to escape the problem it created ever since. You must either pass the object around, as I already mentioned, or you reference a module's public properties in this way: mModuleName.PropertyName = "something" where PropertyName is declared as a public string, for example. Let me try and explain by example. Microsoft tell you not to use inline string literals because they slow both the compiler and the interpreter down, which is a huge problem for Microsoft because the interpreter in .NET 2007 is already slower than a wet week. So, too many years ago to remember, I got into the habit of declaring global constants for common literals. I have a program here of thousands of lines of code that does not use a single literal, and it's still slow. Anyway, to the point: 1) In VB.NET I would declare constants in a single module and in this manner: ' Postscript names and values: Public Const QUOTESINGLE As String = "'" Public Const ASTERISK As String = "*" Public Const NUMBERSIGN As String = "#" Public Const PERCENT As String = "%" Public Const PLUS As String = "+" Public Const EQUAL As String = "=" [...] In VB, Public is a euphemism for Global, so I could access any simply constant by using it's name, for example: If SomeString = EMPTY then... 2) In Gambas I would declare constants in a single module and in this manner: ' Postscript names and values: Public Const QUOTESINGLE As String = "'" Public Const ASTERISK As String = "*" Public Const NUMBERSIGN As String = "#" Public Const PERCENT As String = "%" Public Const PLUS As String = "+" Public Const EQUAL As String = "=" [...] Note the distinct lack of difference? In Gambas, Public is a euphemism for "exposed to view", so I could access any constant by using the form "module.name", for example: If SomeString = mConst.EMPTY then... All of that may seem really weird to you, but the good thing is, unlike VB, Gambas forces you to plan your application structure rather than VB's "just type code as you go" approach. Personally, this is a really good thing. If you find any of that that difficult to follow, spare a thought for me. The uppercase constant names are a fortran 77 convention. ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user