Find and share HowTos to various installations / configurations!
philipp.wechsler
Posts: 13 Joined: Tue May 17, 2016 2:27 pm
ctrl++ object transfer via dollar parameter
Post
by philipp.wechsler » Tue Dec 04, 2018 3:43 pm
Is it possible to transfer ctrl++ object via dollar parameter to an other panel?
There is a mwe:
Library
Code: Select all
class AlertItem
{
protected string mName;
protected bool mState;
public AlertItem( string pName, bool pState )
{
mName = pName;
mState = pState;
}
public string getName()
{
return mName;
}
public bool getState()
{
return mState;
}
};
Initialize panel-code:
Code: Select all
main()
{
AlertItem ai1 = new AlertItem( "MyAlert", true );
addSymbol( myModuleName(), myPanelName(), "oo-test-object.xml", "MyRef", makeDynString( "$ai:" + ai1 ), 20, 20 );
}
Initialize oo-test-object.xml:
Code: Select all
main()
{
AlertItem ai1 = $ai;
lblText.text = ai1.getName();
rect.backCol = ai1.getState() ? "blue" : "white";
}
How can I transfer an object to a next reference?
With kind regards
Philipp
leoknipp
Posts: 2928 Joined: Tue Aug 24, 2010 7:28 pm
Re: ctrl++ object transfer via dollar parameter
Post
by leoknipp » Tue Dec 04, 2018 4:54 pm
The parameters which can be passed to a reference are of type dyn_string.
I think therefore you cannot pass "objects" to a reference.
Best Regards
Leopold Knipp
Senior Support Specialist
mkoller
Posts: 741 Joined: Fri Sep 17, 2010 9:03 am
Re: ctrl++ object transfer via dollar parameter
Post
by mkoller » Tue Dec 04, 2018 7:02 pm
You can not pass an object via $-parameter.
However you can call a public function in that Panel Reference, which has any datatype as argument.
So do it in 2 steps:
1) addSymbol()
2) call the public function in the newly added symbol
philipp.wechsler
Posts: 13 Joined: Tue May 17, 2016 2:27 pm
Re: ctrl++ object transfer via dollar parameter
Post
by philipp.wechsler » Wed Dec 05, 2018 8:34 am
Thanks a lot Martin!
Yes, that works with the public method. I can fix it by moving the statements from the init method to this public method. The construction happens now two steps. I want to investigate the building process.
With kind regards
Philipp