Page 1 of 1

Error when setting array elements by a pointer

Posted: Tue Mar 14, 2017 4:29 pm
by erion
Hello,

The following SB code does not define the PB internal pointer properly:

Code: Select all

Global i
Dim S.l(2)
Global *Sp = @S()

PokeL(*Sp, 0, 42)
                        PokeL(*Sp, 1, 1984)
                        PokeL(*Sp, 2, 2012)
            For i = 0 To 2
              debug s(i)
              Next
Produces the error: TypeError: a.view is undefined

The slightly modified code in PB works fine:

Code: Select all

Global i
Dim S.l(2)
Global *Sp = @S()

PokeL(*Sp, 42)
            *sp+SizeOf(long)
            PokeL(*Sp, 1984)
            *sp+SizeOf(long)
            PokeL(*Sp, 2012)
            For i = 0 To 2
              Debug s(i)
              Next
Erion

Re: Error when setting array elements by a pointer

Posted: Wed Mar 15, 2017 6:32 am
by Fred
You can't do that in SB. Peek/Poke can be only used with AllocateMemory block, not other objects like in PB.