Page 1 of 2
String functions - trying to get the best of them
Posted: 21 Mar 2014 23:24
by Softcore
So, lets say we have some custom expressions named Pr0, Pr1, Pr2, Pr3, Pr4...Pr15 inside a container.....
I cant "find" them to perform scripts on them by:
???
I thought I could....What am I missing?
I thought, ah well expressions are not objects per se, so I then tried
Code: Select all
decl list;
for (i=0;i<16;i++) {
list[i]='Pr'+i;
}
But still after that I cant fill Pr0, for example by going list[0]={1,2,32,1};
Any thoughts?
Re: String functions - trying to get the best of them
Posted: 22 Mar 2014 01:13
by oldgearguy
I have been using Monitor objects for this very reason. I never have been able to indirectly reference variables like that.
Re: String functions - trying to get the best of them
Posted: 22 Mar 2014 06:56
by Softcore
Hear ya! I thought that now with the string functions I might be able to pull it off!
Although, now that I look what I was trying to do with a fresh eye it makes sense that it wouldnt work. I think we need to request a getexpression() function for containers or the unification of "object" (actual reference of an object) with "name" (the name of an object described with string)
Thanks!
edit: OK, I getexpression(container, k) with a custom expression and it works...This will probably do what I want it to do.
Re: String functions - trying to get the best of them
Posted: 22 Mar 2014 11:23
by oldgearguy
The other reason I have been using Monitor objects is that you can instantiate them to longer arrays than regular variables inside the Lemur Windows Editor. The way the editor counts bytes in an array is different between the two, although it shouldn't be different.
Re: String functions - trying to get the best of them
Posted: 22 Mar 2014 17:04
by Blaakk
Mmm, very interesting. Cheers!
Re: String functions - trying to get the best of them
Posted: 12 Oct 2014 10:30
by Mike-L
I saw this thread and think I'm having a similar problem. Please bear with me as I am very much a newbie when it comes to both coding & lemur
I have a set of vectors inside a container e.g s1,s2,s3,s4,s5....s16 .
What i want to do is change every [n] element across some of these vectors, for example,i may want to change s1[2],s5[2],s9[2],s13[2] all to the same value.How do I reference 's' + 'x' and [n] ,where 's' is the vector's name ,'x' is the numerical suffix of the vector's name and [n] is the element in the vector I want to change?
Is this possible?
Thanks!
Re: String functions - trying to get the best of them
Posted: 12 Oct 2014 11:53
by Softcore
Not sure I get the question Mike-L....
If your vector is a string i.e
v = {'s1','s2'........'s16"};
Then by simply typing in a script
v[1] = 's23'
will change 's2' to 's23'
Is this what you are asking?
Re: String functions - trying to get the best of them
Posted: 12 Oct 2014 12:12
by Mike-L
Thanks Softcore,
No I have a set of vectors:
vector 1:0,0,0,0,0,0,0
vector2:0,0,0,0,0,0,0
vector3:0,0,0,0,0,0,0
vector4:0,0,0,0,0,0,0
etc ...
I would like to be able to change the nth element of all chosen vectors, in a repetitve way. In other words a script that will refer to Vector 'X' [n] and then I can repeat through the script changing the X value to address the different vectors. So if X starts as 1, increasese in increments by 1 and position [2] is assigned a value of 4 the final product would be:
vector 1:0,0,4,0,0,0,0
vector2:0,0,4,0,0,0,0
vector3:0,0,4,0,0,0,0
vector4:0,0,4,0,0,0,0
I know that I can use loops to repeat through an array changing values, but I don't know how or if you can loop through different expressions/vectors.
Re: String functions - trying to get the best of them
Posted: 12 Oct 2014 22:30
by Softcore
Ooooh that was a bit tricky! Here's one way to pull it off! Not sure its the best one - I only fiddled with it for 10 minutes. use the Pads to change an nth position of all vectors. The monitors display the 4 example vectors.
Re: String functions - trying to get the best of them
Posted: 14 Oct 2014 00:30
by Mike-L
ah! thank you so much for the help Softcore. I'll have a look at what you've done.
It seems im using a lot of trial and error with my scripting at the moment. Im especially getting knotted up with loops and making sure the braces are in the right place.