Classes question

Bas Hamstra

Member
Licensed User
Longtime User
I created some Class called Brain:

B4X:
Sub Class_Globals
   Type TMove(MType As Int,FRow As Int, FCol As Int , TRow As Int, TCol As Int)   
   Public WhiteToMove As Int
   Public BMove As TMove
   Public Square(9,9), HFence(9,9), VFence(9,9) As Int
   Public WRow, WCol, BRow,BCol As Int
   Public GameMoves As List   
   Public FenceCount(2)
   Private Processed(9,9) As Int
   Public Ply As Int
   Public Nodes As Int


End Sub

Now from another module I want to access the public data. Is this possible? I get a nullpointer exception if I try for example (from main module):

B4X:
If QBrain.Ply == 0 then...



Do I HAVE to write getter/setter for all (trivial) data? This would be slightly disappointing, just now I was thinking this feature is so great.

(please don't lecture me about OO principles, I am aware)

Thanks for any help!

Bas
 

Bas Hamstra

Member
Licensed User
Longtime User
More specific: when I try to access a public array

... in the class from Main module:

B4X:
if QBrain.FenceCount(0) == 10 then... 'nullpointer exception
 
Last edited:
Upvote 0

Bas Hamstra

Member
Licensed User
Longtime User
Solved - user error

As always user errror.

Called the object function before the object was initialized. Stupid.

Bas
 
Upvote 0
Top