In the Array it is woriking as expected. In the List it is completely wrong.
What's the reason for?
Code: Select all
EnableExplicit
Define I, N, *ptr.Character
Dim ary.s(7)
NewList lst.s()
ary(0) = "abc"
ary(1) = "def"
ary(2) = "ghi"
ary(3) = "jkl"
ary(4) = "mno"
ary(5) = "pqr"
ary(6) = "stu"
ary(7) = "vwx"
Debug "-- Elements --"
For I = 0 To 7
AddElement(lst())
lst() = ary(I)
Debug lst()
Next
Debug "-------"
Debug ""
Debug "Array"
For I=0 To 7
*ptr = @ary(I)
Debug ary(I) + " : " + Chr(*ptr\c) + " : " + Str(*ptr\c)
Next
Debug ""
Debug "List"
ForEach lst()
*ptr = @lst()
Debug lst() + " : " + Chr(*ptr\c) + " : " + Str(*ptr\c)
Next
-- Elements --
abc
def
ghi
jkl
mno
pqr
stu
vwx
-------
Array
abc : a : 97
def : d : 100
ghi : g : 103
jkl : j : 106
mno : m : 109
pqr : p : 112
stu : s : 115
vwx : v : 118
here the Pointer to not point to the String! Why?
List
abc : ঀ : 2432
def : ঠ : 2464
ghi : ী : 2496
jkl : ৠ : 2528
mno : : 2560
pqr : ਠ : 2592
stu : ੀ : 2624
vwx : : 2656