Not understanding Initialize

ietv

Member
Licensed User
Longtime User
I get an "Object should first be initialized error" - even if it have the Initialize statement in the line just before the error!

I noticed this on my solitaire app also, but I just worked around it. Initialize just doesn't seem to "take" or something.

What would cause this type of error?

I'm going to see if I can reproduce it with a minimal app and post it.
 

ietv

Member
Licensed User
Longtime User
Here's the minimal example - modified version of Erel's Tick Tack Toe, using imageviews instead of buttons.
 

Attachments

  • ivttt.zip
    29 KB · Views: 153
Upvote 0

ietv

Member
Licensed User
Longtime User
When the program halts, it tells me both that winTag is not initialized (yet it is, in the line before!) and that tV is not initialized (yet it is, 2 lines before!).

I suspect that the problem is that I pull an imageview from an array to put into tV. That imageview must be the one that is not initialized.

Yet I thought I had initialized it in the Sub Setboard when I placed it in the array.

That is where I think I am doing something wrong.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim winTag As BoxTag
Dim tV As ImageView
tV.Initialize("Box")
tV = Boxes(x,y)
winTag.Initialize
winTag = tV.Tag

1. It is not the cause of this error, however there is no need to call tv.Initialize as you are assigning an already initialized view to this variable. The same is true for other places in your code.

2. Using the debugger I saw that the error happens when x = 0 and y = 1.
Add this line after line 83:
B4X:
Log(tTag.x & " " & tTag.y)
You will see that your code doesn't add the boxes correctly.
 
Upvote 0
Top