# What am I missing about Ptr.String?

**URL:** <https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061>\
**Category:** General\
**Created:** [February 3, 2014, 5:12pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061 "2014-02-03T17:12:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [February 3, 2014, 5:12pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/1 "2014-02-03T17:12:40Z")

</div>

Consider this code:

```auto
  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?

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [February 3, 2014, 5:20pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/2 "2014-02-03T17:20:38Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [February 3, 2014, 5:25pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/3 "2014-02-03T17:25:52Z")

</div>

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.

> [@](#):
>
> You can convert the value referenced to by the pointer to a specific datatype using the Pointer Properties: Boolean, Byte, CFStringRef, Class, Color, CString, Currency, Double, Int16, Int32, Int64, Int8, Integer, Object, Ptr, Short, Single, String, UInt16, UInt32, UInt64, UInt8, Variant, WindowPtr, WString [emphasis mine]

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [February 3, 2014, 5:26pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/4 "2014-02-03T17:26:32Z")

</div>

I think the docs need updating.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [February 3, 2014, 5:28pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/5 "2014-02-03T17:28:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [February 3, 2014, 5:31pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/6 "2014-02-03T17:31:33Z")

</div>

> [@62872:@Kem Tekinay](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [February 3, 2014, 5:36pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/7 "2014-02-03T17:36:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [February 3, 2014, 5:50pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/8 "2014-02-03T17:50:17Z")

</div>

See:

\<[https://xojo.com/issue/32055](https://xojo.com/issue/32055)\>

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:03pm UTC](https://forum.xojo.com/t/what-am-i-missing-about-ptr-string/14061/9 "2020-10-29T17:03:51Z")

</div>


