Using StingConcatenation to set a specific array item

Discuss problems and solutions.
Post Reply
electrofux
Regular
Posts: 294
Joined: 24 Jan 2012 18:22

Using StingConcatenation to set a specific array item

Post by electrofux »

Can i make the below code work somehow:

Pattern1-8 are expressions in the Container electropolis. The script resides on any of 8 Faders and when i use one of the faders i want to write its x value at the corresponding position in the currently selected Patterns array.

Code: Select all

decl pat='Pattern'+(firstof(electropolis.Pattern.x)+1);
decl pattern=getexpression(electropolis,pat);
pattern[1]=x;
setexpression(electropolis,'pat',pattern);

Thought i first define the name of the expression, then get the expression and write it in pattern, then alter pattern at the right position and then set the expression to the altered array. But it doesnt work.
electrofux
Regular
Posts: 294
Joined: 24 Jan 2012 18:22

Re: Using StingConcatenation to set a specific array item

Post by electrofux »

Phew, got it. Only some ' were too much:

Code: Select all

decl pat='Pattern'+(firstof(electropolis.Pattern.x)+1);
decl pattern=getexpression(electropolis,pat);
pattern[nr]=x;
setexpression(electropolis,pat,pattern);
This worked.
Post Reply