ctrl++ object transfer via dollar parameter

Find and share HowTos to various installations / configurations!
Search

Post Reply
4 posts • Page 1 of 1
philipp.wechsler
Posts: 13
Joined: Tue May 17, 2016 2:27 pm

ctrl++ object transfer via dollar parameter

Post by philipp.wechsler »

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

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: ctrl++ object transfer via dollar parameter

Post by leoknipp »

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

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: ctrl++ object transfer via dollar parameter

Post by mkoller »

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 »

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

Post Reply
4 posts • Page 1 of 1