How can I concatenate strings?

Discuss Lemur and share techniques.
Post Reply
ahonoe
Newbie
Posts: 25
Joined: 07 Feb 2012 22:30

How can I concatenate strings?

Post by ahonoe »

Hi All,

Apologies if this has been asked and answered. I'm trying to figure out how to build strings dynamically in Lemur by concatenating a series of smaller strings. Ideally I would store the smaller strings in an array.

I am using the wonderful Missing Link (OSC over WiFi to MIDI box) wifimidi.com. The ML parses incoming OSC strings (addresses) containing MIDI hex data and sending the MIDI to its output.

What I'd like to do is assemble these OSC strings on-the-fly based on user input in Lemur.

Any suggestions would be appreciated.
Regards,

Scott
bxsj
Regular
Posts: 116
Joined: 24 Dec 2011 06:47
Location: Vienna

Re: How can I concatenate strings?

Post by bxsj »

Here you go:

Code: Select all

decl str1={1,2,3};
decl str2={4,5};
decl str3={7,8,9,0x0A};
decl string;

string={str1,str2,str3};
Hope that helps,
B.
Win7 64, Ipad Lemur, Cubase6 and a bunch of Roland Synths and Samplers
ahonoe
Newbie
Posts: 25
Joined: 07 Feb 2012 22:30

Re: How can I concatenate strings?

Post by ahonoe »

Thanks bxsj. I'll give this a try.

Regards,

Scott
Regards,

Scott
bxsj
Regular
Posts: 116
Joined: 24 Dec 2011 06:47
Location: Vienna

Re: How can I concatenate strings?

Post by bxsj »

Unfortunately there is no real string handling available. The "strings" in the example above are actually arrays containing an entry for each character in ASCII. Saying that, displaying a string like yours could like this:

Code: Select all


decl txtsharpy={47,115,104,97,114,112,121,47};
decl i=3;
decl parameter={67,111,108,111,114,87,104,101,101,108,32,53};
decl s = arraytostring({ txtsharpy, i+48, 47, parameter }); 

setattribute(Text,'content',s);
Not sure if this helps,
B.
Win7 64, Ipad Lemur, Cubase6 and a bunch of Roland Synths and Samplers
bxsj
Regular
Posts: 116
Joined: 24 Dec 2011 06:47
Location: Vienna

Re: How can I concatenate strings?

Post by bxsj »

decl s = arraytostring({ '/sharpy/', i+49, '/', 'ColorWheel' });
doesn't work? Is there any way to make that work?
The array with a character per character approach is the only way I am aware of. Perhaps in a future version of Lemur?
If I have to replace all of these strings with ascii arrays it is going to be quite a big pain! (and be potentially quite bug-prone).
You could define the common used strings as variables (expressions), so that they are only defined once to avoid bugs.
E.g.: expression txtsharpy = {47,115,104,97,114,112,121,47} Then use "txtsharpy" whenever you need it in an osc command.
/sharpy/1/Dimmer 0.234
Not sure if values like 0.234 can be converted into an array.
Good Luck,
B.
Win7 64, Ipad Lemur, Cubase6 and a bunch of Roland Synths and Samplers
bxsj
Regular
Posts: 116
Joined: 24 Dec 2011 06:47
Location: Vienna

Re: How can I concatenate strings?

Post by bxsj »

Great job, really slick 8-) Yep, I agree some more string functions would be helpfull.
Cheers,
B.
Win7 64, Ipad Lemur, Cubase6 and a bunch of Roland Synths and Samplers
dBlicious
Newbie
Posts: 25
Joined: 12 Jan 2013 06:49

Re: How can I concatenate strings?

Post by dBlicious »

memosan wrote:
A http://www.processing.org sketch that converts a string text to an array in the format of lemur:
Thanks for this. You saved me hours.

-A
shanekoss
Newbie
Posts: 23
Joined: 27 Jun 2012 13:27

Re: How can I concatenate strings?

Post by shanekoss »

thanks for posting this - very cool. One question. What if the lemur object is the variable as opposed to message you wanted to send?

using the example above - what if the object you are referring to is the variable that you've defined with your arraytosring

like this:

setattribute(s, 'content', 'test'); // check address string

or in my case:

setexpression(s, 'x', 1); // turn button on

can't seem to make that work. i've confirmed s is correct (in this case s = LOOPER1.record, which is the name of the object i want to set the expression of) If i replace s with LOOPER1.record, it works, but with the declared variable s, it doesn't.

Any ideas?

Thanks!
Post Reply