findchild question

Discuss problems and solutions.
AkaMed
Newbie
Posts: 37
Joined: 31 Mar 2014 00:26

findchild question

Post by AkaMed »

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?
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: findchild question

Post by Softcore »

Is there a particular reason you choose findchild() and not findobject()?
AkaMed
Newbie
Posts: 37
Joined: 31 Mar 2014 00:26

Re: findchild question

Post by AkaMed »

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...
AkaMed
Newbie
Posts: 37
Joined: 31 Mar 2014 00:26

Re: findchild question

Post by AkaMed »

i.e.
I would love to get something like...

decl preset=firstof(x);
Container2.Seq.Load.x[preset]=1;
oldgearguy
Regular
Posts: 315
Joined: 02 Nov 2013 11:19

Re: findchild question

Post by oldgearguy »

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);
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: findchild question

Post by Softcore »

Franky Im also at loss as to what findchild(object, name) means!

As in...does it expect the object AND name (string) of the parent or what? Not sure...if it expects the parent and the name of the child then why couldnt we just go

findobject('child') per se...Im lost
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: findchild question

Post by Softcore »

yes and oldgear guy is correct - I missed that....

Its setexpression(object, name-of-expression, val)

So the object msut be a direct reference, the expression must be the string name of the expression
AkaMed
Newbie
Posts: 37
Joined: 31 Mar 2014 00:26

Re: findchild question

Post by AkaMed »

Thanks for the responses,
yes, the problem is if the expression contains a vector...what can we do then?
oldgearguy
Regular
Posts: 315
Joined: 02 Nov 2013 11:19

Re: findchild question

Post by oldgearguy »

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.
AkaMed
Newbie
Posts: 37
Joined: 31 Mar 2014 00:26

Re: findchild question

Post by AkaMed »

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!
Post Reply