Page 1 of 1

multidimensional arrays in scripts?

Posted: 14 Apr 2025, 18:48
by woodslanding
this syntax is from pascal forums:

var x: array [1..5, 1..9] of integer;

but usine complains about the comma.

Can we use multi-dimensional arrays? If so how?

And more broadly, what variant of pascal does usine actually employ??

THANKS!
-eric

Re: multidimensional arrays in scripts?

Posted: 17 Apr 2025, 08:06
by SylvainT
Hi Eric,

We don't have multidimensional arrays in Usine. We talked many times about that, but never went through.
Actually, there's a solution if you really need it. A comma-text can be think as a multidimensional array, but you have to manipulation either string and data. There's an example in the French section of the forum, viewtopic.php?f=25&t=7318

Best
Sylvain

Re: multidimensional arrays in scripts?

Posted: 17 Apr 2025, 15:43
by senso
another soluce is to use "old style" pascal:

Code: Select all

var x: array [1..5] of array [1..9] of integer

// and inside the code 

  x[i][j] := i*j;

Re: multidimensional arrays in scripts?

Posted: 21 Apr 2025, 21:38
by woodslanding
Thanks!

I am still curious what particular brand of pascal Usine uses....

I found a workaround that keeps my code more readable:

for i = 0 to max
for j = 0 to max
idx = //compute from i and j
do stuff with array[idx]

However, I am now wishing for dynamic arrays in my second dimension, where each array in the array of arrays was of variable length.

var x: array [1..8] of array[] of integer;

I'll see if Usine lets me do that....

Re: multidimensional arrays in scripts?

Posted: 23 Apr 2025, 13:53
by oli_lab
Hi !
If you want variable size array, the best should be to use vectors en C++, and make a user module.

or a simpler way, use polyphony and an array within a sub-array ?

if the process is too heavy on the CPU, you can also use the "procedure" method.

cheers
arrays within arrays matrix.wkp
(676.35 KiB) Downloaded 893 times

Re: multidimensional arrays in scripts?

Posted: 24 Apr 2025, 11:43
by senso
woodslanding wrote:
21 Apr 2025, 21:38
However, I am now wishing for dynamic arrays in my second dimension, where each array in the array of arrays was of variable length.

var x: array [1..8] of array[] of integer;

I'll see if Usine lets me do that....
Sure it will work.