Page 1 of 1
Pass array to inline Javascript
Posted: Sat May 24, 2025 7:13 pm
by Chris
Hi,
I wonder if it is possible to pass an array to inline Javascript?
This does not work (v_array is undefined):
Code: Select all
Dim Array(1)
Array(0)=1
Array(1)=2
Debug Array(0)
Debug Array(1)
EnableJS
v_array[0]=3;
DisableJS
Debug Array(0)
Debug Array(1)
Cheers
Chris
Re: Pass array to inline Javascript
Posted: Sat May 24, 2025 8:27 pm
by Peter
use a_Array....
Code: Select all
Dim Array(1)
Array(0)=1
Array(1)=2
Debug Array(0)
Debug Array(1)
EnableJS
a_Array.array[0]=3;
DisableJS
Debug Array(0)
Debug Array(1)
Re: Pass array to inline Javascript
Posted: Sun May 25, 2025 6:00 am
by Chris
Thanks very much, works fine.
Cheers
Chris
Re: Pass array to inline Javascript
Posted: Tue May 27, 2025 8:38 am
by Fred
That's wierd it's still uppercase, I will take a closer look as all should be lowercase in JS IIRC
Re: Pass array to inline Javascript
Posted: Tue May 27, 2025 10:50 am
by Caronte3D
Additionally, the documentation should list all valid prefixes.
For example, I wasn't familiar with prefixes for static variables or even this one for arrays.
The arrays make me crazy on my current project (solved with a workaround by an old post in this forum), but now, I see it's very easy with that prefix.
Re: Pass array to inline Javascript
Posted: Tue May 27, 2025 12:53 pm
by Fred
when doing inline JS, you should really look at the generated code to see how it's written, it will avoid trial and error. You can do it easily by putting 'CallDebugger' just before the line you want to inspect and then open the browser devtool.