[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global Variable


Just to rabble rouse....

env["xx"] -> global array .. lol

Global arrays/collections are possible, they are variables I guess, could be any type of array

class globalValueArray
' Gambas class file
Static varfile As New Collection(gb.ignorecase)
Static Public Sub _init()
    varfile.default = ""
End
Static Public Sub _get(name As String) As Variant
    Return varfile[name]
End
Static Public Sub _put(value As Variant, name As String)
    varfile[name] = value
End
end class

Public Sub Main()
    Print "Hello world"
    Print Env["SHELL"]  ' global array

    ' Global Array/Collections
    globalValueArray["hexit"] = "hello world"
    Print globalValueArray["hexit"]
End


On 2/19/26 02:22, Gianluigi wrote:
Il 19/02/26 11:06, Benoît Minisini ha scritto:
Le 19/02/2026 à 10:40, Gianluigi a écrit :
Sorry, Benoit,

you need to please resolve a forum discussion.
I maintain that in Gambas, unlike other languages, there is no such thing as a global variable (i.e., a variable you can access anywhere in the project by name alone). Global Variables exist only at the module (or class) level. A Global Variable in Gambas can be Static, Private (visible everywhere but only in the module where it was declared), or Public (visible everywhere in the project). If the Global Variable is Public (being at the module level), if called in another class or module, it must be preceded by the name of the module in which it was declared.

Am I mistaken or missing something?

Thanks for your attention.

Regards
Gianluigi



It seems right to me. What could be the matter of arguing about that?


Thank you so much.
You find meaning in aging: the older you get, the more you feel like a child again :-)

Best regards
Gianluigi



--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


Follow-Ups:
Re: Global VariableGianluigi <gradobag@xxxxxxxxxxx>
References:
Global VariableGianluigi <gradobag@xxxxxxxxxxx>
Re: Global VariableBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Global VariableGianluigi <gradobag@xxxxxxxxxxx>