- Index
- » Programming
- » Modelica Language
- » Change the type of variable...
Change the type of variable (protected or public) with a if condition
Change the type of variable (protected or public) with a if condition
Hello everyone,
I would like to know if it's possible to use a boolean to change the type protected or not of a bus?
I tried this code:
DataCoach3D dataCoach3D(ModeProtectedActivated=ModeProtectedActivated)
annotation (Placement(transformation(extent={{40,50},{60,70}})));
public
parameter Boolean ModeProtectedActivated=false;
if Boolean ModeProtectedActivated then
{ protected Modelica.Icons.SignalSubBus signalSubBus annotation (Placement(transformation(extent={{-32,58},{-12,78}})))";"}
[else
{ public Modelica.Icons.SignalSubBus signalSubBus annotation (Placement(transformation(extent={{-32,58},{-12,78}})))";"}
]
end if ;
But it sent me back the following syntax error:
Error: declaration window line 16 column 5, syntax error at "if" missing { "end" "external" }
Error: declaration window line 17 column 7, syntax error at "protected" missing "end" and missing ";" and missing EndOfFile
ERROR: 2 errors were found
Thanks you for your help and have a nice day.
Re: Change the type of variable (protected or public) with a if condition
Modelica does not allow to change public/protected on a boolean variable.
- sjoelund.se
- 1700 Posts
Re: Change the type of variable (protected or public) with a if condition
Thank you,
But it is possible to change the type of the variable easily?
because we have a lot of bus and we want to be able to put them all in protected on one click to hide some informations.
Re: Change the type of variable (protected or public) with a if condition
Code:
model M
protected
extends OtherModel; // Makes everything in OtherModel protected
end M;
- sjoelund.se
- 1700 Posts
- Index
- » Programming
- » Modelica Language
- » Change the type of variable...