Troubleshooting

combining arrays

Started by electrofux on .

Sign in or create an account to join the conversation.

13 posts

Topic starter
Hello,

i have two array looking like this:

arrayA={'Instrument1','Instrument2'}
arrayB={'Thor','Antidote'}

is there a way to combine those two to get:

arrayC={"Instrument1 Thor",'Instrument2 Antidote'}

?
I think with subarray you can separate arrayA and arrayB. Then just combine the subarrays into one array.

A1=subarray(arrayA,0,length)
A2=subarray(arrayA,start,length)
B1=subarray(arrayB,0,length)
B2=subarray(arrayB,start,length)

arrayC={A1,B1,A2,B2}

if I'm not mistaken, this should work. Haven't tried it out yet.
Thats not quite what i am after though i think it got me a step nearer. What i want to do is set the 2 labels of a switch object to 1) "Instrument1 Thor" and 2.) "Instrument2 Antidote". Therefor i must combine the values of the two arrays into one item each.

I have interlaced the two arrays now, so i have arrayC={'Instrument1', 'Thor', 'Instrument2', 'Antidote'} but i am struggeling to set the labels to 2 consecutive arrayitems.

There are no arrays of arrays in Lemur, are there?
there are, just like

arrayC={A1,B1,A2,B2}

the arrays between {} separated by a comma, are consecutively combined. Tested now, and it's true.

Maybe still not what you're looking for, but with the above method we can combine arrays, and with subarray() we can extract portions of an array.
Hi
The crux of your problem is that you are really talking about 'strings' here rather than 'arrays' as such . . .
Remember how we got the 'Thor' text in the first place - as an ASCII array which we then converted . . .
If you can get the 'Instrument 1' text the same way then it is simply a matter of combining those arrays (maybe add a space between them) and then arraytostring() on them
You can otherwise create and store the strings as ascii arrays if they are not being sent . . .

So if INST1 and THOR are variables with the ascii arrays needed and SPACE =32 (ascii for space) then arraytostring(INST1,SPACE,THOR) returns "Instrument1 Thor"

I believe they have been working on implementing built-in String functions at some point so this will change when they are introduced . . .

Hope that helps . .
Ok i am nearly at it then. But what is the best way to make one array out of three?

Example:
a={34,55}
b={32,32}
c={44,46}

d={34,55,32,32,44,46}

Is there an easy way or do i have to loop through everything and built a new one? Simply adding doesnt really work, interlace mixes everything up.
Yes
Adding arrays is a maths operation that adds the array contents together - so d=a+b+c would give {110,113} in this instance
Interlace and interlace3 take successive values from each array to be place sequentially in the new array
Oh man, i am still fighting with my scripts.

while i understood how to use arraytostring now, i have the problem that during the scanning process i need to save the ASCII somewhere, at best in an array because combining is only possible after the scanning process as the different items come in with different orders.
So what i need is an array of arrays. Is that doable?

Edit: Finally, out of some weird accident wihile trying this and that everything works now and is labelled nicely. That was a big fight with the reason codec and the lemur arrays :-)
Still it would be nice to know if there is a way to use arraysof arrays.