:sign0085:When I attempt to change a tag in one object it changes ALL the tags in the card array -
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim c0,c1,c2,c3 As ImageView
Dim CardViews() As ImageView
Dim Comments As Label
Type TagData(Who As Int,Where As String)
Dim MyTag As TagData
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim i,j As Int
Dim q As String
'Dim MyTag As TagData
activity.LoadLayout("test4")
CardViews=Array As ImageView(c0,c1,c2,c3)
For i=0 To 3 'Sets all lower arrays in addition to current one!!!
q="KK"
MyTag.Who=i
MyTag.Where=q
CardViews(i).Tag=MyTag
j=i
Next
Comments.Text=Comments.Text & "1="
Printit
MyTag=CardViews(2).Tag 'makes all tags the same!!!
MyTag.Who=5
CardViews(2).Tag=MyTag
Comments.Text=Comments.Text & " 2="
Printit
' For i=0 To 3
' j=5+i
' MyTag=CardViews(i).Tag
' MyTag.Who=j
' MyTag.Where="NN"
' CardViews(i).Tag=MyTag 'Stops here when assembling
' Next i
' Comments.Text=Comments.Text & " 2="
' Printit
' For i=3 To 0 Step -1
' j=5+1
' MyTag.Who=i
' MyTag.Where=q
' CardViews(i).Tag=MyTag
' Next i
' Comments.Text=Comments.Text & " 2="
' Printit
End Sub
Sub Printit
Dim i As Int
' Dim MyTag As TagData
For i=0 To 3
MyTag =CardViews(i).tag
Comments.Text=Comments.Text & " Who=" &MyTag.Who
Next
End Sub
The first change prints "3 3 3 3" instead of "0 1 2 3" and the second change prints "5 5 5 5".
Also, the commented-out block won't assemble. It stops on line 42. What's going on?
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim c0,c1,c2,c3 As ImageView
Dim CardViews() As ImageView
Dim Comments As Label
Type TagData(Who As Int,Where As String)
Dim MyTag As TagData
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim i,j As Int
Dim q As String
'Dim MyTag As TagData
activity.LoadLayout("test4")
CardViews=Array As ImageView(c0,c1,c2,c3)
For i=0 To 3 'Sets all lower arrays in addition to current one!!!
q="KK"
MyTag.Who=i
MyTag.Where=q
CardViews(i).Tag=MyTag
j=i
Next
Comments.Text=Comments.Text & "1="
Printit
MyTag=CardViews(2).Tag 'makes all tags the same!!!
MyTag.Who=5
CardViews(2).Tag=MyTag
Comments.Text=Comments.Text & " 2="
Printit
' For i=0 To 3
' j=5+i
' MyTag=CardViews(i).Tag
' MyTag.Who=j
' MyTag.Where="NN"
' CardViews(i).Tag=MyTag 'Stops here when assembling
' Next i
' Comments.Text=Comments.Text & " 2="
' Printit
' For i=3 To 0 Step -1
' j=5+1
' MyTag.Who=i
' MyTag.Where=q
' CardViews(i).Tag=MyTag
' Next i
' Comments.Text=Comments.Text & " 2="
' Printit
End Sub
Sub Printit
Dim i As Int
' Dim MyTag As TagData
For i=0 To 3
MyTag =CardViews(i).tag
Comments.Text=Comments.Text & " Who=" &MyTag.Who
Next
End Sub
The first change prints "3 3 3 3" instead of "0 1 2 3" and the second change prints "5 5 5 5".
Also, the commented-out block won't assemble. It stops on line 42. What's going on?