Support Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Can I recognize numbers and text in a script at once?

seokwoo seo Oct 02, 2018 03:50AM CEST

I am using the OSCOUT code. I want to generate and send the following OSC code

/ aaa 1, "text"

I created the code in the script as follows

decl a=2;
decl b='text';
decl c=a+b;


When i create the code like this, I get the results.

/aaa 2

How can I get the results I want?

Up 0 rated Down
MiluX Oct 12, 2018 08:55AM CEST
As far as I know, you can't concatenate a string and an integer. That's why you have to convert your integer to a string first. There's no such function in Lemur, so I tried to create one. It doesn't work with big numbers, but I should work for your case.
Create a script at the top of your project called itoa(n).
Then in it just copy this code :

if (n==0) return '0';
//'string-length' of the integer
decl nDigits = floor(log10(abs(n))) + 1;

decl i, sign, array;
//remember the sign for negative numbers
sign = n;
if (sign < 0) n = -n;

//extract every digit
for (i=0; i<nDigits; i++)
array[i] = n % 10;
n = floor(n/10);
//reverse array
decl temp;
decl count = sizeof(array);
for (i = 0; i < count/2; ++i)
temp = array[i];
array[i] = array[count-i-1];
array[count-i-1] = temp;
//make a string from the array
decl text = '';
for (i=0;i<count;i++)
text += array[i];
return text;

Then you would have to adjust your code like this :

decl c = itoa(a)+b;

Hope you can make it work ;)

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found