String concatenation and arrays

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

String concatenation and arrays

Post by electrofux »

Hello,

can i access distinct array items through the setexpression function or do i have to write the whole array in one go?
something like:

setexpression(currentobj,'values',check[0]);

Or anything similar since the above doesnt really work.
oldgearguy
Regular
Posts: 315
Joined: 02 Nov 2013 11:19

Re: String concatenation and arrays

Post by oldgearguy »

I've only had success creating a temporary array and then using setexpression() to assign it to the object all at once.

check = {0,0,0,1};
setexpression(myBtns, x, check);

At some point in time, I got real tired of trying to figure out clever/cleaner ways and just did it the way I knew worked so I could be done with it. Trying to figure out workarounds every step of the way wore me down. :cry:
electrofux
Regular
Posts: 294
Joined: 24 Jan 2012 18:22

Re: String concatenation and arrays

Post by electrofux »

i am trying to do it like that. But it is getting really complicated ;-) Would be much easier if i figured out a way to directly change array items with via concatenation and setexpression.

I am building an single interface to control several sequencers in Reason and at the same time implement a bidirectional cc conversion to make the sequencers react to predefined scales. So to not blow the code up i need every clever trick i can come across ;-)
oldgearguy
Regular
Posts: 315
Joined: 02 Nov 2013 11:19

Re: String concatenation and arrays

Post by oldgearguy »

I hear you. So, using constructs like currentobj.values = check[0]; or some other type of de-referencing doesn't work? I'm not at a terminal to check it out directly.
electrofux
Regular
Posts: 294
Joined: 24 Jan 2012 18:22

Re: String concatenation and arrays

Post by electrofux »

If the currentobj is an object referenced by the findobject funtion this indeed doesnt work for me. The code gets red when i put the array brackets behind it.
But i got around it because getexpression(currentobj,'values') works. And then i fiddle around with setexpression and dummy arrays.
oldgearguy
Regular
Posts: 315
Joined: 02 Nov 2013 11:19

Re: String concatenation and arrays

Post by oldgearguy »

electrofux wrote:If the currentobj is an object referenced by the findobject funtion this indeed doesnt work for me. The code gets red when i put the array brackets behind it.
But i got around it because getexpression(currentobj,'values') works. And then i fiddle around with setexpression and dummy arrays.


That's nice -- I wouldn't have thought to try the on the result of getexpression like that. Good to know it works (well, as of 5.0.3 anyway ;) )
electrofux
Regular
Posts: 294
Joined: 24 Jan 2012 18:22

Re: String concatenation and arrays

Post by electrofux »

I would love to use the same for setexpression. There should be a way to set specific array items with just a setexpression. ;)
Post Reply