What am I missing about Ptr.String?

Consider this code:

  dim mb as MemoryBlock = "12345678"
  dim p as Ptr = mb
  dim t as string = p.String( 0 ) // Won't compile

This won’t compile with a “This item does not exist” error at p.String( 0 ). What am I missing?

Line 1: you create a MemoryBlock
Line 2: You declare a pointer to a MemoryBlock
Line 3: Doesn’t work because you first have to dereference the pointer, like that:

dim mb2 as MemoryBlock = p dim t as string = mb2.StringValue(0, 8)

Thanks, but that’s not what the docs or even auto-complete say. And I don’t have to do anything like that when using, for example, p.UInt64.

I think the docs need updating.

So you think String shouldn’t be there, or in auto-complete? I guess that would make sense since it’s very, very limited anyway.

String shouldn’t be there. It’s not a valid data type for use with pointers.

It looks like Variant shouldn’t be there either. Working up a FR now.

See:

<https://xojo.com/issue/32055>