DataType

# Ptr

<div class="rst-class">

forsearch

</div>

DataType

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A reference to a chunk of memory. You can pass a `MemoryBlock</api/language/memoryblock>` object via this data type and it will be treated as a pointer to the memory contained within the `MemoryBlock</api/language/memoryblock>`.

<div class="warning">

<div class="title">

Warning

</div>

Setting <span class="title-ref">Ptr</span> values via the methods of this class is not currently supported for Android.

</div>

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                           | Parameters                                       | Returns                                                     | Shared |
|--------------------------------|--------------------------------------------------|-------------------------------------------------------------|--------|
| `Boolean<ptr.boolean>`         | offset As `Integer</api/data_types/integer>` = 0 | `Boolean</api/data_types/boolean>`                          |        |
| `Byte<ptr.byte>`               | offset As `Integer</api/data_types/integer>` = 0 | `Byte</api/data_types/additional_types/byte>`               |        |
| `CFStringRef<ptr.cfstringref>` | offset As `Integer</api/data_types/integer>` = 0 | `CFStringRef</api/data_types/additional_types/cfstringref>` |        |
| `Color<ptr.color>`             | offset As `Integer</api/data_types/integer>` = 0 | `Color</api/data_types/color>`                              |        |
| `CString<ptr.cstring>`         | offset As `Integer</api/data_types/integer>` = 0 | `CString</api/data_types/additional_types/cstring>`         |        |
| `Currency<ptr.currency>`       | offset As `Integer</api/data_types/integer>` = 0 | `Currency</api/data_types/currency>`                        |        |
| `Double<ptr.double>`           | offset As `Integer</api/data_types/integer>` = 0 | `Double</api/data_types/double>`                            |        |
| `Int16<ptr.int16>`             | offset As `Integer</api/data_types/integer>` = 0 | `Int16</api/data_types/additional_types/int16>`             |        |
| `Int32<ptr.int32>`             | offset As `Integer</api/data_types/integer>` = 0 | `Int32</api/data_types/additional_types/int32>`             |        |
| `Int64<ptr.int64>`             | offset As `Integer</api/data_types/integer>` = 0 | `Int64</api/data_types/additional_types/int64>`             |        |
| `Int8<ptr.int8>`               | offset As `Integer</api/data_types/integer>` = 0 | `Int8</api/data_types/additional_types/int8>`               |        |
| `Integer<ptr.integer>`         | offset As `Integer</api/data_types/integer>` = 0 | `Integer</api/data_types/integer>`                          |        |
| `Single<ptr.single>`           | offset As `Integer</api/data_types/integer>` = 0 | `Single</api/data_types/single>`                            |        |
| `Structure<ptr.structure>`     | offset As `Integer</api/data_types/integer>` = 0 | `Structure</api/language/structure>`                        |        |
| `UInt16<ptr.uint16>`           | offset As `Integer</api/data_types/integer>` = 0 | `UInt16</api/data_types/additional_types/uint16>`           |        |
| `UInt32<ptr.uint32>`           | offset As `Integer</api/data_types/integer>` = 0 | `UInt32</api/data_types/additional_types/uint32>`           |        |
| `UInt64<ptr.uint64>`           | offset As `Integer</api/data_types/integer>` = 0 | `UInt64</api/data_types/additional_types/uint64>`           |        |
| `UInt8<ptr.uint8>`             | offset As `Integer</api/data_types/integer>` = 0 | `UInt8</api/data_types/additional_types/uint8>`             |        |
| `UInteger<ptr.uinteger>`       | offset As `Integer</api/data_types/integer>` = 0 | `UInteger</api/data_types/additional_types/uinteger>`       |        |
| `WString<ptr.wstring>`         | offset As `Integer</api/data_types/integer>` = 0 | `WString</api/data_types/additional_types/wstring>`         |        |

## Method descriptions

<div id="ptr.boolean">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Boolean

**Boolean**(offset As `Integer</api/data_types/integer>` = 0) As `Boolean</api/data_types/boolean>`

> Converts the value referenced to by the pointer to a Boolean.

<div id="ptr.byte">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Byte

**Byte**(offset As `Integer</api/data_types/integer>` = 0) As `Byte</api/data_types/additional_types/byte>`

> Converts the value referenced to by the pointer to a Byte.

<div id="ptr.cfstringref">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.CFStringRef

**CFStringRef**(offset As `Integer</api/data_types/integer>` = 0) As `CFStringRef</api/data_types/additional_types/cfstringref>`

> Converts the value referenced to by the pointer to a CFStringRef.

<div id="ptr.color">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Color

**Color**(offset As `Integer</api/data_types/integer>` = 0) As `Color</api/data_types/color>`

> Converts the value referenced to by the pointer to a Color.

<div id="ptr.cstring">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.CString

**CString**(offset As `Integer</api/data_types/integer>` = 0) As `CString</api/data_types/additional_types/cstring>`

> Converts the value referenced to by the pointer to a CString.

<div id="ptr.currency">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Currency

**Currency**(offset As `Integer</api/data_types/integer>` = 0) As `Currency</api/data_types/currency>`

> Converts the value referenced to by the pointer to a Currency.

<div id="ptr.double">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Double

**Double**(offset As `Integer</api/data_types/integer>` = 0) As `Double</api/data_types/double>`

> Converts the value referenced to by the pointer to a Double.

<div id="ptr.int16">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Int16

**Int16**(offset As `Integer</api/data_types/integer>` = 0) As `Int16</api/data_types/additional_types/int16>`

> Converts the value referenced to by the pointer to an Int16.

<div id="ptr.int32">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Int32

**Int32**(offset As `Integer</api/data_types/integer>` = 0) As `Int32</api/data_types/additional_types/int32>`

> Converts the value referenced to by the pointer to an Int32.

<div id="ptr.int64">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Int64

**Int64**(offset As `Integer</api/data_types/integer>` = 0) As `Int64</api/data_types/additional_types/int64>`

> Converts the value referenced to by the pointer to an Int64.

<div id="ptr.int8">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Int8

**Int8**(offset As `Integer</api/data_types/integer>` = 0) As `Int8</api/data_types/additional_types/int8>`

> Converts the value referenced to by the pointer to an Int8.

<div id="ptr.integer">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Integer

**Integer**(offset As `Integer</api/data_types/integer>` = 0) As `Integer</api/data_types/integer>`

> Converts the value referenced to by the pointer to an Integer.

<div id="ptr.single">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Single

**Single**(offset As `Integer</api/data_types/integer>` = 0) As `Single</api/data_types/single>`

> Converts the value referenced to by the pointer to a Single.

<div id="ptr.structure">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.Structure

**Structure**(offset As `Integer</api/data_types/integer>` = 0) As `Structure</api/language/structure>`

> Converts the value referenced to by the pointer to a specific Structure type.
>
> Given a structure, you can dereference it from a pointer like this:
>
> ``` xojo
> Structure TestStruct
> Value As Int64
> End Structure
> ```
>
> ``` xojo
> Var p As Ptr ' assign an appropriate Ptr value
> Var structVar As TestStruct = p.TestStruct
>
> structVar.Value = 42
> ```

<div id="ptr.uint16">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.UInt16

**UInt16**(offset As `Integer</api/data_types/integer>` = 0) As `UInt16</api/data_types/additional_types/uint16>`

> Converts the value referenced to by the pointer to an UInt16.

<div id="ptr.uint32">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.UInt32

**UInt32**(offset As `Integer</api/data_types/integer>` = 0) As `UInt32</api/data_types/additional_types/uint32>`

> Converts the value referenced to by the pointer to an UInt32.

<div id="ptr.uint64">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.UInt64

**UInt64**(offset As `Integer</api/data_types/integer>` = 0) As `UInt64</api/data_types/additional_types/uint64>`

> Converts the value referenced to by the pointer to an UInt64.

<div id="ptr.uint8">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.UInt8

**UInt8**(offset As `Integer</api/data_types/integer>` = 0) As `UInt8</api/data_types/additional_types/uint8>`

> Converts the value referenced to by the pointer to an UInt8.

<div id="ptr.uinteger">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.UInteger

**UInteger**(offset As `Integer</api/data_types/integer>` = 0) As `UInteger</api/data_types/additional_types/uinteger>`

> Converts the value referenced to by the pointer to an UInteger.

<div id="ptr.wstring">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Ptr.WString

**WString**(offset As `Integer</api/data_types/integer>` = 0) As `WString</api/data_types/additional_types/wstring>`

> Converts the value referenced to by the pointer to a WString.

## Notes

A <span class="title-ref">Ptr</span> is 4 bytes for 32-bit apps and 8 bytes for 64-bit apps.

You can compare one <span class="title-ref">Ptr</span> to another <span class="title-ref">Ptr</span> or to `Nil</api/language/nil>`.

You can convert the value referenced to by the pointer to a specific data type using the available methods.

You can assign a <span class="title-ref">Ptr</span> to a `MemoryBlock</api/language/memoryblock>`.

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, <span class="title-ref">Ptr</span>, Short, Single, UInt16, UInt32, UInt64, UInt8, WString.

<div class="important">

<div class="title">

Important

</div>

On Android, the <span class="title-ref">Ptr</span> type can be used with Declares and Declares that call [Kotlin Library projects](https://blog.xojo.com/2023/08/15/creating-an-android-library-with-kotlin-for-use-with-xojo/). Other usage of <span class="title-ref">Ptr</span> on Android will result in a compile error.

</div>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

You can compare one <span class="title-ref">Ptr</span> to another or to `Nil</api/language/nil>`.

## Sample code

``` xojo
Var p1, p2, p3 As Ptr

p1 = AddressOf someMethod
p2 = someMemoryBlock ' A Ptr to the MemoryBlock itself
p3 = someMemoryBlock.Ptr(n) ' Retrieve Ptr stored within the MemoryBlock at offset n
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`AddressOf</api/language/addressof>` method; `Declare</api/language/declare>` statement; `MemoryBlock</api/language/memoryblock>` class; `MemoryBlock.Ptr<memoryblock.ptr>` function, `OSHandle</api/os/oshandle>` class.

</div>
