# Plugin instructions to pass an array of single

**URL:** <https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703>\
**Category:** Plugins\
**Created:** [August 13, 2022, 7:04am UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703 "2022-08-13T07:04:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Dakin](https://forum.xojo.com/user_avatar/forum.xojo.com/eugene_dakin/32/178_2.png) [@Eugene\_Dakin](https://forum.xojo.com/u/Eugene_Dakin)\
**Post date:** [August 13, 2022, 7:04am UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703/1 "2022-08-13T07:04:43Z")

</div>

I am attempting to pass an array of single values from Xojo and place them into a plugin method. Is there instructions on how to do this? Here is my Xojo single array:

> [@](#):
>
> Var Vertices(8) as Single  
> Vertices(0) = -0.5  
> Vertices(1) = -0.5 \* Sqrt(3) / 3  
> Vertices(2) = 0.0  
> Vertices(3) = 0.5  
> Vertices(4) = -0.5 \* Sqrt(3) / 3  
> Vertices(5) = 0.0  
> Vertices(6) = 0.0  
> Vertices(7) = 0.5 \* Sqrt(3) / 3  
> Vertices(8) = 0.0

The third parameter of glBufferData is the array of Single, and the array is passed to the method in Xojo with the following function:

> [@](#):
>
> GLADSS.glBufferData(GLADSS.GL\_ARRAY\_BUFFER, (Vertices.Count\*4), Vertices, GLADSS.GL\_STATIC\_DRAW)

In the plugin, the Xojo array is UData() as Single

> [@](#):
>
> { (REALproc)glBufferDataSS, REALnoImplementation, “glBufferData(uTarget as UInteger, uSize as UInteger, uData() as Single, uUsage as Uinteger)”, REALconsoleSafe },

Here is the function to receive the parameters:

> [@](#):
>
> void glBufferDataSS(GLenum target, GLsizeiptr size, GLenum data, GLenum usage)  
> {  
> }

When data is received at the function, the data is mangled:

> [@](#):
>
> 0: 0  
> 1: 0  
> 2: 2095232784  
> 3: 32763  
> 4: 0  
> 5: 0  
> 6: 2  
> 7: 0  
> 8: 4294967295

When I write the code in pure C++ (no Xojo code), the data is correct:

> [@](#):
>
> vertices[0]: -0.5  
> vertices[1]: -0.288675  
> vertices[2]: 0  
> vertices[3]: 0.5  
> vertices[4]: -0.288675  
> vertices[5]: 0  
> vertices[6]: 0  
> vertices[7]: 0.57735  
> vertices[8]: 0

How do I pass a Single array from Xojo into a plugin without data mangling?

I am guessing that I am supposed to use REALInsertArrayValueSingle and the constant kTypeFloat32 = 1, but how do I use it? What did I program incorrectly?

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 13, 2022, 7:52am UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703/2 "2022-08-13T07:52:41Z")

</div>

Your single array is passed to the function as a REALarray type.  
And then you use REALGetArrayValue() to pick up a value.

---

<div class="post-metadata">

**Author:** ![Eugene\_Dakin](https://forum.xojo.com/user_avatar/forum.xojo.com/eugene_dakin/32/178_2.png) [@Eugene\_Dakin](https://forum.xojo.com/u/Eugene_Dakin)\
**Post date:** [August 13, 2022, 3:15pm UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703/3 "2022-08-13T15:15:35Z")

</div>

Thanks for the helpful information Christian. Unfortunately, there is no data at the memory address, and it appears that REALGetArrayValue is deprecated and is now REALGetArrayValueSingle.

Are there any other helpful hints to set/get a Single array in a plugin with Xojo?

I can pass a single array in the REALmethodDefinition:

> [@](#):
>
> { (REALproc)glBufferDataSS, REALnoImplementation, “glBufferData(uTarget as UInteger, uSize as UInteger, uData() as Single, uUsage as Uinteger)”, REALconsoleSafe },

And I can get to my method with REALarray:

> [@](#):
>
> void glBufferDataSS(GLenum target, GLsizeiptr size, REALarray data, GLenum usage)

Data from REALGetArrayValueSingle a loop are memoryaddresses:

> [@](#):
>
> for (int i = 0; i \< 9; ++i)  
> {  
> REALGetArrayValueSingle(data, i, MyFloatValue);  
> ss \<\< i \<\< ": " \<\< &MyFloatValue \<\< std::endl;  
> }

> [@](#):
>
> 0: 000000000014DBB0  
> 1: 000000000014DBB0  
> 2: 000000000014DBB0  
> 3: 000000000014DBB0  
> 4: 000000000014DBB0  
> 5: 000000000014DBB0  
> 6: 000000000014DBB0  
> 7: 000000000014DBB0  
> 8: 000000000014DBB0

Unfortunately, there is no data at that place in memory with the program running:

![MemAddress](https://forum.xojo.com/uploads/default/original/2X/3/3ba85d41903219af436d842c53989413ebd5da4c.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 13, 2022, 4:38pm UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703/4 "2022-08-13T16:38:55Z")

</div>

You Output the address of the variable instead of the value!

---

<div class="post-metadata">

**Author:** ![Eugene\_Dakin](https://forum.xojo.com/user_avatar/forum.xojo.com/eugene_dakin/32/178_2.png) [@Eugene\_Dakin](https://forum.xojo.com/u/Eugene_Dakin)\
**Post date:** [August 13, 2022, 6:47pm UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703/5 "2022-08-13T18:47:56Z")

</div>

> [@Christian\_Schmitz](#):
>
> You Output the address of the variable instead of the value!

You are correct, my error.

Thanks for your help Christian.

Edit: changed the quote

---

<div class="post-metadata">

**Author:** ![Eugene\_Dakin](https://forum.xojo.com/user_avatar/forum.xojo.com/eugene_dakin/32/178_2.png) [@Eugene\_Dakin](https://forum.xojo.com/u/Eugene_Dakin)\
**Post date:** [August 13, 2022, 6:50pm UTC](https://forum.xojo.com/t/plugin-instructions-to-pass-an-array-of-single/71703/6 "2022-08-13T18:50:47Z")

</div>

For completeness of this answer, here is the final for-loop:

> [@](#):
>
> float MyFloatValue;  
> for (int i = 0; i \< 9; ++i)  
> {  
> REALGetArrayValueSingle(data, i, &MyFloatValue);  
> ss \<\< i \<\< ": " \<\< MyFloatValue \<\< std::endl;  
> }
