arraytostring?
arraytostring?
The last piece of my puzzle. Now that I have my array
a={8,12,5}
I want to concatenate this into the number 8125
Not sure why but arraytostring just gives me a bunch of ''''''''' in my monitor. Not sure if I have the syntax right:
arraytostring(a[0, 1, 2])
a={8,12,5}
I want to concatenate this into the number 8125
Not sure why but arraytostring just gives me a bunch of ''''''''' in my monitor. Not sure if I have the syntax right:
arraytostring(a[0, 1, 2])
Re: arraytostring?
It's not obvious but arraytostring converts an array of ASCII codes to a string. For single-digit numbers you just need to add 48 to get the ASCII code. It's a little more complicated for numbers > 9. I wrote a function intToArray(n) that converts a number n with any number of digits to an array of ASCII codes. There's also a script arrayIntToArray(arr) that converts an array of numbers to an array of ASCII. Hope this helps.
-A
-A
Re: arraytostring?
Hello dBlicious,
Inspired by your idea and the lack of string-functions I made two scripts to generate strings out of an array of chars.
I searched the forum for anything that helps concatenate numbers with strings but didn't found anything. So I hope this is useful and not already done.
Until now I had to use a list/array of object-names as a reference for object-related functions. With these scripts I can concatenate an array of chars (the fixed part of the object-names) with a variable part of the name as an increasing number i.e. in a for-loop.
Because my Lemur-Editor crashes every time I want to open your Module (I use lemur-editor on win7) i wrote my own int2array-Script, wich makes an array of digits out of every number.
But it only works for numbers with up to eight digits. Perhaps someone can see the bug in the script.
Examplecode only to show the concept:
best regards
Alex
Inspired by your idea and the lack of string-functions I made two scripts to generate strings out of an array of chars.
I searched the forum for anything that helps concatenate numbers with strings but didn't found anything. So I hope this is useful and not already done.
Until now I had to use a list/array of object-names as a reference for object-related functions. With these scripts I can concatenate an array of chars (the fixed part of the object-names) with a variable part of the name as an increasing number i.e. in a for-loop.
Because my Lemur-Editor crashes every time I want to open your Module (I use lemur-editor on win7) i wrote my own int2array-Script, wich makes an array of digits out of every number.
But it only works for numbers with up to eight digits. Perhaps someone can see the bug in the script.
Examplecode only to show the concept:
Code: Select all
decl objectname = {'m','y','f','a','d','e','r'};
decl numofaders = 25;
decl i;
for (i = 0; i < numofaders; i++)
{
setexpression(findobject(charstostring({objectname, int2array(i)})), 'x', i^2);
}
best regards
Alex
- Attachments
-
- charstostring.jzml
- To call the script press "Execute".
The variables are set in the script in the button - (4.03 KiB) Downloaded 156 times
Re: arraytostring?
Hello again,
I found that int2array works fine to a size of 0xffffff7 for the integer value. This must be the maximum size for integer variables. But I think I will never use such a big index for an object.
best regards
Alex
I found that int2array works fine to a size of 0xffffff7 for the integer value. This must be the maximum size for integer variables. But I think I will never use such a big index for an object.
best regards
Alex
Re: arraytostring?
Nice script, Alex. Yeah, Lemur seems to have some limitations that are not too difficult to run up against.
Re: arraytostring?
I just realized I couldn't open my script either. This one should work better. It has the same max value limitation that Alex noted.
Re: arraytostring?
Hi
Yeah - meant to mention that - I copied the script out of the .jzml anyway
And did some versions as well that do similar stuff - might post them later . .
Max value is 32bit limit . . .
Cheers
MM
Yeah - meant to mention that - I copied the script out of the .jzml anyway
And did some versions as well that do similar stuff - might post them later . .
Max value is 32bit limit . . .
Cheers
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Re: arraytostring?
just uploaded a useful ascii calculator in the modules section
eg
setattribute(text3,'content','min'); will result in the displayed text having quotation marks........ 'min' looks crap
name_array={109,105,110};}
Text object = arraytostring(name_array) will result in the ........ min looks much better {109,105,110} being the ascii code within lemur for the letters min
suppose the example could have used the string maj, dim, aug. i wonder what i've been working on recently
eg
setattribute(text3,'content','min'); will result in the displayed text having quotation marks........ 'min' looks crap
name_array={109,105,110};}
Text object = arraytostring(name_array) will result in the ........ min looks much better {109,105,110} being the ascii code within lemur for the letters min
suppose the example could have used the string maj, dim, aug. i wonder what i've been working on recently
Re: arraytostring?
cheers for the ascii conversion script!
Incredibly helpful! Just made my life a hundred times easier
Incredibly helpful! Just made my life a hundred times easier