Using the new possibilities extensively I've experienced that there are often somewhere stored Indexes of array-elements are not accessable from within the type-function - so it's not possible to just retrieve some index of the current into some pattern/condition fitting element from a type-function and to compare this Index later within another function of that type.
Anyway a variable could have some property which tells who in the world current Me exactly is. Now if there's no additional waste of memory for such identifier wanted or needed for each element - there is a simple way if the type we talk about is used for one array-variable only:
Type t_Type
Static current As DWord ' Static is same memory to all elements of that type
someFunctionCheck As Function
otherFunctionDo As Function
End Type
Function t_Type.someFunctionCheck( something As Any )
If something And Me Then
Me.current = VarPtr(Me)
EndIf
End Function
Function t_Type.otherFunctionDo()
If Me.current = VarPtr(Me) Then
' Me gets a pretty pink hairbow...
Else
' Me gets same old grey hat as all the others
EndIf
End Function
Dim foo(123) As t_Type
'...maybe:
Long i
foo(1).Current = 0 ' delete old information
While i < UBound(foo)
i += 1
foo(i).someFunctionCheck(whatever)
If foo(1).Current Then Exit While ' found out the current matching one, so exit
Wend
'...to find out current foo,
'...different ways thinkable
For i = 1 to Ubound(foo)
If Varptr(foo(i)) = foo(1).Current Then ' could call a type-function instead
' we got a match...
Else
' no match
EndIf
Next
'...
of course one can store the "current elements pointer" to some globals as well if the type is used for more than one array.
So omit the static type member then and
Dim current_foo as DWord
Dim current_moo ...
If use this way on dynamic used arrays make sure to do the checking after redim and before calling the function that uses the information about "current element" since varptrs could have changed.
Anyway can make some local overlay to access current element instantly like
Sub SomeSub()
Local x as t_myType at current_foo
With X
'...
End With
End Sub
Bookmarks