I am fairly new to GP, but have found the combination of customizable widgets and scripting to be perfect for setting up a live guitar rig with my FCB1010 pedal board. However, I have come across some odd behavior with arrays, including what appears to be a bug.
First, the bug: calling a user function that returns an array crashes GP. To confirm this, I created a new rackspace, with no plugins or widgets, and created a very simple script:
var array1 : double Function GetArray() returns double array result = array1 End Initialization var ar : double array ar = GetArray() End
When I compile this script, GP crashes.
The other odd thing I have noticed is that assigning an array to a new variable seems to copy the array, instead of creating a new reference to the array. For example:
Initialization var ar1 : double ar2 : double array ar2 = ar1 //at this point, I expect ar2 to be pointing to ar1, e.g. they are the same array in memory ar2 = 1.0 Print("ar1 = " + ar1) Print("ar2 = " + ar2) End
ar1 = 0.0
ar2 = 1.0
This is unlike any programming language I have ever used. This seriously messed me up for hours trying to debug a script that uses two arrays, one of which gets assigned to a local variable depending on a specific condition. I was setting a member of the local array to a new value, but that value was not getting reflected in the global array that I thought that variable was pointing to. I didn’t see any mention of this behavior in the docs, but maybe I just missed it.
Is there some way to assign an array to a new array variable, such that the variable points to the array instead of getting a copy of it?