Passing array from context to Xojo Script

Hi,

I have an array named ‘discount_applications_array’ that contains: (1,2,3) within my context that I would like to access from a XojoScript.

I am attempting to input it into the script with the following:

dim dsc() as string
dsc.append discount_applications_array
print dsc(0)

and this:

dim dsc() as string
dsc = discount_applications_array
print dsc(0)

If we use a single item instead of an array it works otherwise when using an array we get: “[2:6-2:33] This item does not exist.” when using the XojoScript Example Application.

Any advice? Thanks

Arrays are objects and cannot be passed across the boundary. You’ll need to make a data format as a string to move the data across… like JSON.

You could pass a tab delimited string (combinedNames), created by

Dim combinedNames As String = Join(names, chr(9))

And once you get it in the script, split it with chr9).

anArray = s.Split(chr(9))

You can create a method in the context object which expects the index as parameter and returns the item for the index. Another method which appends an entry and one which sets an entry.

1 Like