Welcome to %s forums

BrainModular Users Forum

Login Register

multidimensional arrays in scripts?

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

multidimensional arrays in scripts?

Unread post by woodslanding » 14 Apr 2025, 18:48

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
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

SylvainT
Site Admin
Posts: 494
Contact:

Unread post by SylvainT » 17 Apr 2025, 08:06

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

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 17 Apr 2025, 15:43

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;

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 21 Apr 2025, 21:38

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....
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 23 Apr 2025, 13:53

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 880 times
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 24 Apr 2025, 11:43

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests