[Gambas-user] Another basics
Fabien Bodard
gambas.fr at ...626...
Fri Jan 6 16:07:04 CET 2012
well :)
i'm not a true professionnal of computing so words i use are not good.
(and my english is really bad)
In a class you have 3 time
_Init
Called only one time at the first use of the class
_New
Called at each NEW instantiation
_Free
Called when a classe is freed (when the ref to this class instance
not stored anywhere)
You can access a public var from anywhere but this var is linked to an instance
If you use static public the var is accessible from the class name
like with a module and not depend of an instance. (it allow for
example to share a value between each instance of a class
Private var is accessible ony from the sub of the current class
static private can be used only from a static sub.
I use public var for property that just store a value and can be
accessed in read write mode
i use property for value that need controle or that generate an event
for example
dim $iX as private
property X as integer
Private X_Read() as Integer
return $iX
end
Private X_Write(Value as integer)
$iX = min(Value,100) 'max 100
RefreshDraw() 'redraw the object when the x is changed
end
You can use Property Read for a read only value
this is some basis.....
--
Fabien Bodard
More information about the User
mailing list