Troubleshooting

findchild question

Started by AkaMed on .

Sign in or create an account to join the conversation.

14 posts

Topic starter
Hello,

I am trying to modify an object's expression that is in another container, but I get lost trying...
The goal is to call a pads object inside a container from another pads object from another container.
I tried:

decl preset = firstof(x);
decl a=findchild('Container2', 'Seq');
decl b=findchild(a, 'Load');
setexpression(b, x[preset], 1);

But it doesn't work...
Any help?
Hello Softcore,

because with findobject I believe I can only find and object that has an unique name...Am I wrong?
And I have several objects with the same name inside different containers.
I am confused...
I don't think setexpression ('someObject', x[number], 1); works. I thought setexpression() needed a quoted string as the second parameter.

So you'd have to build up a vector equal to the sixe of x and then do setexpression('someObject', 'x', newVectorOfValues);
AkaMed wrote:Thanks for the responses,
yes, the problem is if the expression contains a vector...what can we do then?

decl i, newVector = {0,0,0,0};

i = findfirst(x);
newVector = x;
setexpression('myObject', 'x', newVector);


You can be more clever using sizeof(x) and fill(newVector...) to create the initial vector, but you should have the general idea now.
Works!!!
Thanks oldgearguy!!!
My modified code is:

decl preset = firstof(x);
decl a=findobject('Container2.Seq.Load');
decl newVector = {0,0,0,0,0,0,0,0};
newVector[preset] = x[preset];
setexpression(a, 'x', newVector);

Now I can call any action from anywhere!
Thanks Softcore also!
Hi All
Aren't you overcomplicating things?
You have a multiple Pad object and you want it to set values of another Pad object? And you want them set the same? Standard dot notation should work...

From Pad in Container1 have a script (executing on x) - Container2.Seq.Load.x=x;

From the Lemur 5 thread
One can no longer use the dot notation indirectly, by placing a dot after a variable that was set to point to an object.
dot notation is still supported, the only case it is not supported is when the part AFTER the dot is a variable referring to an object. in that case you should use setexpression()

See Monitor object - handy for debugging various things . .
i.e. From top level a Monitor with value = C2.Seq.Load.x should show the x values

findchild() seems handy for traversing hierarchies in a more controlled fashion when needed, rather then only having find object....

MM