Global Variables
Posted
#1
(In Topic #534)
Enthusiast

I was wondering if someone could direct me to the correct outcome of this issue I am having
I want to have a module that holds all my global settings for example
Code
Public Key_SignOn As Integer = 65 'Athe idea is so I can use the same declare though out my application like this
Code
Select Case Key.Code
Case Key_SignOn ' lower case A
frmSignedOff.Enabled = False
FMain.Workspace1.Add(FrmSignOn, False)
End Selectand not like this
Code
elect Case Key.Code
Case 65 ' Lower case A
frmSignedOff.Enabled = False
FMain.Workspace1.Add(FrmSignOn, False)
End Selectbut when I try to run the program I get the following error "Unknown identifier: Key_SignOn in frmSignedoff.class:13"
what do I need to do to get this to work.
I do come from a Visual Basic 6 background and I am willing to learn new skills here
Posted
Enthusiast

BUT
maybe you like to have a look at the gb.settings class …
http://gambaswiki.org/…p/gb.settings?ht=settings
or
https://gambas-buch.de/doku.php?id=k19:k19.1:start (german, not translated yet)
Posted
Expert

I went full 1980's and named my two main modules:
AV { application variables } - just global variables
AG { application global } - Global functions and routines
…as long as you don't go overboard with shortened names, it will save you a LOT of time as you code.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Enthusiast

Posted
Regular

Quincunxian said
Do yourself a favour and don't name your modules too long…
Quin, I agree with PJ and rely on auto-complete to do most of my typing. But I try to avoid similar long names:-
mySpecialFunkyChicken
mySpecialFunkyChildren
…but even in such cases, I just use the up/down arrow when auto-complete gives me a list of options.
I'd probably call the modules: gVars & gFunctions
I don't want to go back to the 1980s for x = y - z + 2j
…I'd only go back for ABBA
Posted
Expert

If you assign a local variable to a global variable in a form or a class then the auto-complete does not work.
As a whole, I agree to a point.
Normally I only use three distinct modules and avoid using more as they do come with a memory overhead.
So having short names for these especially with the naming convention used ( AE, AG, AV ) does save time ( AE is dedicated to error management routines )
I make extensive use of tool-box classes that I've developed over the years and the contained routines do need to be named distinctively for obvious reasons.
My advice to new coders is: be consistent.
If you work in a professional developer team, they will normally have a style guide on what naming convention to use.
Even if you are just an enthusiast, then being consistent makes life easier in the long run.
I've opened code I wrote 10 years ago and with a horrified look on my face, I had that moment of "What the hell was i thinking…"
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Enthusiast

I've opened code I wrote 10 years ago and with a horrified look on my face, I had that moment of "What the hell was i thinking…"
I have had that happen with what I wrote last week
Posted
Enthusiast

1 guest and 0 members have just viewed this.


