Troubleshooting

Using StingConcatenation to set a specific array item

Started by electrofux on .

Sign in or create an account to join the conversation.

2 posts

Topic starter
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.
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.
Phew, got it. Only some ' were too much:
decl pat='Pattern'+(firstof(electropolis.Pattern.x)+1);
decl pattern=getexpression(electropolis,pat);
pattern[nr]=x;
setexpression(electropolis,pat,pattern);
This worked.