02-28-2023, 03:33 PM
There is a small error in the first code on the page. Thats how it works:
One advantage of associative arrays didn't in moment become clear to me. Similar to a two-dimensional random access array. . . That's how I understood it.
Code: (Select All)
'Assosziatives Array: https://jeff.win/qbhash/
'28. Feb. 2023
Type element
tag As String * 10
value As String * 10
End Type
Dim Shared aa(10) As element
Dim Shared aalast ' Last occupied AA() element
setvalue "foo", "bar"
Print getvalue$("foo") ' prints bar
End
Function getvalue$ (tag As String)
tag = LTrim$(RTrim$(tag))
tag = tag + String$(10 - Len(tag), " ")
For i = 0 To aalast
If (tag = aa(i).tag) Then
getvalue$ = aa(i).value
Exit Function
End If
Next
End Function
Sub setvalue (tag As String, value As String)
aa(aalast).tag = tag
aa(aalast).value = value
aalast = aalast + 1
End Sub
One advantage of associative arrays didn't in moment become clear to me. Similar to a two-dimensional random access array. . . That's how I understood it.