Opened 10 years ago

Last modified 10 years ago

#2825 new defect

Override of Q-Idents

Reported by: Lennart Ochel Owned by: somebody
Priority: high Milestone: Future
Component: Command Prompt Environment Version: trunk
Keywords: Cc: cbrinkrolf@…, Adrian Pop, Martin Sjölund, Adeel Asghar, Willi Braun

Description

The simulation command line flag -override is quite useful. Unfortunately, it is not working for Q-Idents, because inverted commas are not passed to the simulation. Has anyone an idea how to fix it?

The issue can be tried using the following example script.

loadString("
model foo
  Real x(start=1.0);
  Real 'y'(start=1.0);
  parameter Real p=1.0;
equation
  der(x) = p;
  der('y') = p;
end foo;
"); getErrorString();

simulate(foo, stopTime=0.0); getErrorString();
val(x, 0.0); getErrorString();
val('y', 0.0); getErrorString();

simulate(foo, stopTime=0.0, simflags="-override=p=-2,x=0,\'y\'=0 -lv=LOG_SOLVER"); getErrorString();
val(x, 0.0); getErrorString();
val('y', 0.0); getErrorString();

x is working as expected, whereas 'y' is not.

BTW: Whitespaces (and probably other strange valid characters) in Q-Idents will not work too.

Change History (4)

comment:1 by Martin Sjölund, 10 years ago

Yes, because you did not escape your override flag. The following works fine:

simflags="\"-override=p=-2,x=0,\'y\'=0\" -lv=LOG_SOLVER"

Note that to do what you want to without caring about shell escapes, simflags would need to be an array of arguments, like:

simflags={"-override=p=-2,x=0,\'y\'=0","-lv=LOG_SOLVER"}

in reply to:  1 comment:2 by Lennart Ochel, 10 years ago

Replying to sjoelund.se:

Yes, because you did not escape your override flag. The following works fine:

simflags="\"-override=p=-2,x=0,\'y\'=0\" -lv=LOG_SOLVER"

Great, thanks!

comment:3 by Lennart Ochel, 10 years ago

If you change 'y' to 'y y' even val fails.

NaN
"Error: 'y y' not found in /home/lochel/Documents/tests/ticket2825/foo_res.mat
"

comment:4 by Martin Sjölund, 10 years ago

readSimulationResultVars returns {"'yy'","der('yy')","der(x)","p","time","x"}, so it looks like the simulation reader converts the variable names (octave shows that the file contains the spaces).

Note: See TracTickets for help on using tickets.