hi - in the manual:
String Concatenation
It is now possible to construct strings through concatenation. For example, the following produces the string ‘Fader2’:
decl i = 2;
decl name = "Fader" + i;
I take this to mean if you had several arrays defined in your project (array1, array2, array3, etc)
you could address array1 like this:
decl i = 1;
decl array = 'array'+i;
Monitor.value=array;
also tried:
decl i = 1;
decl array = findobject('array'+i);
Monitor.value=array;
however these both produce the string 'array1', not the contents of array1.
any ideas?
String Concatenation for dynamically selected arrays
Re: String Concatenation for dynamically selected arrays
You cannot get the content of an array by calling the array name - string concatenation is irrelevant to this.
If you have an array of values array1 = {1,34,45,565,7}
and you want to display the array in a monitor you simply type:
Monitor.value=array1;
If you have an array of values array1 = {1,34,45,565,7}
and you want to display the array in a monitor you simply type:
Monitor.value=array1;
Re: String Concatenation for dynamically selected arrays
Not exactly what you want, but on a side note a little trick my girlfriend showed me last night to get integers and floats to string just do:
''+array/number;
example:
decl arr = {2,4,99};
decl stringArr = ''+arr;
now stringArr would equal: {'2','4','99'};
maybe people already know that, but it blew me away!
(thinking on it now, I should've noticed it since you do the same thing with findobject() and findchild()
''+array/number;
example:
decl arr = {2,4,99};
decl stringArr = ''+arr;
now stringArr would equal: {'2','4','99'};
maybe people already know that, but it blew me away!
(thinking on it now, I should've noticed it since you do the same thing with findobject() and findchild()
Re: String Concatenation for dynamically selected arrays
Thanks for the reply - not sure i understand what you mean bySoftcore wrote:You cannot get the content of an array by calling the array name - string concatenation is irrelevant to this.
Isn't monitor.value=array1 doing just that? ( assuming i have an array defined with that name in the project)Softcore wrote:You cannot get the content of an array by calling the array name - string concatenation is irrelevant to this.
The problem here is i want to assign numbers to different arrays dynamically. Some to array1, some to array2, etc.
it would be great to be able to do something like:
decl i - MIDI_ARGS[0];
decl tempArray = 'array'+i;
tempArray = set(tempArray, MIDI_ARGS[1], MIDI_ARGS[2]);
cheers
Re: String Concatenation for dynamically selected arrays
When you convert something to string it becomes a string, a TEXT....it is no longer an object you can reference
decl tempArray = 'array'+i;
becomes essentially a text!
You need to find other ways - for example for objects you can use a string query like so:
findobject('nameofobject')
I think you can also perform the same operation if you cunningly "nest" your arrays in an object. Then, since arrays are really custom expressions of that object, where they are nested you could go:
decl temparray = getexpression(Container, 'array')
So in this case, you can use a string for that array name.
decl tempArray = 'array'+i;
becomes essentially a text!
You need to find other ways - for example for objects you can use a string query like so:
findobject('nameofobject')
I think you can also perform the same operation if you cunningly "nest" your arrays in an object. Then, since arrays are really custom expressions of that object, where they are nested you could go:
decl temparray = getexpression(Container, 'array')
So in this case, you can use a string for that array name.
Last edited by Softcore on 05 Apr 2015 20:22, edited 1 time in total.
Re: String Concatenation for dynamically selected arrays
I understand your confusion because it took me a while to understand so myself.....
Notice in the internal functions of Lemur that sometimes the functions accept a "direct reference" to an object - example: setattribute(object, name, value)
and some other times it accepts a "string" reference - example setattribute(object, name, value)
The above becomes clear with a specific example - if you want to change the expression of a Fader then you type:
setexpression(Fader, 'x', 0.5)
NOW, notice that "Fader" is NOT a string - its a direct reference, while 'x' is a string that refers to the Fader's x expression.
It took me while to understand that you cannot "interchange" direct references with string references.
Notice in the internal functions of Lemur that sometimes the functions accept a "direct reference" to an object - example: setattribute(object, name, value)
and some other times it accepts a "string" reference - example setattribute(object, name, value)
The above becomes clear with a specific example - if you want to change the expression of a Fader then you type:
setexpression(Fader, 'x', 0.5)
NOW, notice that "Fader" is NOT a string - its a direct reference, while 'x' is a string that refers to the Fader's x expression.
It took me while to understand that you cannot "interchange" direct references with string references.