[Gambas-user] accessing a variable from another class

Mayost Sharon sharon at 455.co.il
Thu Apr 20 16:12:11 CEST 2023


Hello

In previous discussions on this topic
I was told that what I was trying to do did not make sense

After thought and examination

In Gambas it is possible to access and change variables that are in another class
By
STATIC PUBLIC

It also exists in other languages, for example:
https://www.w3docs.com/snippets/java/accessing-a-variable-from-another-class.html

So it makes sense to do such a thing

The question is if I create several classes for example
class1 class2 class3
Is there a possibility that only class2 or class3 can read from class1
That is, when I am in class2 it will be possible to read:
class1.var1

But when I compile all 3 classes
It will not be possible from the outside to read the variable:

dim cl1 as class1
cl1.
After the DOT it will not show me the variable var1

Thank you very much everyone


More information about the User mailing list