Error when setting array elements by a pointer

Just starting out? Need help? Post your questions and find answers here.
erion
Posts: 9
Joined: Fri Mar 03, 2017 8:16 pm

Error when setting array elements by a pointer

Post 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
Fred
Site Admin
Posts: 1821
Joined: Mon Feb 24, 2014 10:51 am

Re: Error when setting array elements by a pointer

Post by Fred »

You can't do that in SB. Peek/Poke can be only used with AllocateMemory block, not other objects like in PB.
Post Reply