Sub B4JSTestList()
Log("------- Start B4JSTestList")
Dim List1 As List
List1.Initialize
List1.Add("test1")
List1.Add("test2")
Dim strDV As String = List1.Get(0)
Log("test1 <=> " & strDV)
strDV = List1.Get(1)
Log("test1 <=> " & strDV)
Dim List2Arr As List
'List2Arr.Initialize2(Array("test1", "test2", "test3", "test4", "test5", "test6")) ' UnsupportedOperationException in B4JSList.Initialize2 (see further)
' this works
List2Arr.Initialize
List2Arr.Add("test1")
List2Arr.Add("test2")
List2Arr.Add("test3")
List2Arr.Add("test4")
List2Arr.Add("test5")
List2Arr.Add("test6")
Dim List3List As List
List3List.Initialize2(List2Arr)
Dim List4 As List
' List4.Initialize2(Array As String("test-2", "test-1", "test0")) ' UnsupportedOperationException in AddAllAt(2, List3List) (see further). I suspect because List3List is using initialize2 + An Array
' this works
List4.Initialize
List4.Add("test-2")
List4.Add("test-1")
List4.Add("test0")
List4.AddAllAt(2, List3List) ' <- exception if using List2Arr.Initialize2()
Log("test-1 <=> " & List4.Get(1))
Log("test1 <=> " & List4.Get(2))
Log("test2 <=> " & List4.Get(3))
Log("test0 <=> " & List4.Get(8))
' B4JSList is declared as a global variable
B4JSList.Initialize2(List2Arr)
Dim bool1 As Boolean = B4JSList.IsInitialized
Log("true, but in B4JS will always be true <=> " & bool1)
B4JSList.RemoveAt(1) ' UnsupportedOperationException if using List2Arr.Initialize2()
Log("test3 <=> " & B4JSList.Get(1))
Dim int1 As Int = B4JSList.IndexOf("test3")
B4JSList.Set(int1, "newtest1") ' I suspect the same error, but it never reaches this far
Log("newtest1 <=> " & B4JSList.Get(1))
B4JSList.InsertAt(3, "newtest2") ' I suspect the same error, but it never reaches this far
Log("newtest2 <=> " & B4JSList.Get(3))
B4JSList.Sort(True) ' I suspect the same error, but it never reaches this far
Log("newtest1 <=> " & B4JSList.Get(0))
B4JSList.Sort(False) ' I suspect the same error, but it never reaches this far
Log("test6 <=> " & B4JSList.Get(0))
B4JSList.SortCaseInsensitive(bool1) ' I suspect the same error, but it never reaches this far
Log("newtest1 <=> " & B4JSList.Get(0))
B4JSList.Clear
Log("0 <=> " & B4JSList.Size)
' not supported in B4JS
Dim list5 As List
list5.Initialize
Dim i As Int
For i = 0 To 5
' is declared as global: Type testtype(field1 As Int, field2 As Int)
Dim tmptype As testtype
tmptype.Initialize
tmptype.field1 = i
tmptype.field2 = i+1
list5.Add(tmptype)
Next
list5.SortType("field1", True)
Log("SortType is not supported in B4JS")
list5.SortTypeCaseInsensitive("field1", True)
Log("SortTypeCaseInsensitive is not supported in B4JS")
End Sub