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)
follow-up: 2 comment:1 by , 10 years ago
comment:2 by , 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 , 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 , 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).
Yes, because you did not escape your override flag. The following works fine:
Note that to do what you want to without caring about shell escapes, simflags would need to be an array of arguments, like: