- Index
- » Programming
- » Modelica Language
- » regex and system()
regex and system()
regex and system()
Hi,
this should be my last open problem:
From my final simulation I want to keep only a few variables in a .csv file, so I do:
Code:
system("mymodel -override startTime=243,stopTime=391,outputFormat=csv,variableFilter=mixer21.Out.*|mixer22.Out.*|effluentsink1.Out.*|sludgesink1.Out.* -iif start.mat -r results.csv")
When I filter only for one class of variables, e.g. mixer21.Out.* it works just fine, I get all my 16 state variables for that subsystem. Unfortunately it gives me an error (255) when I try more using the pipe (|). I have to admit I'm not very keen on regex. Is it a problem that using "system" my call to variableFilter is already within a string and I can't use the quote sign for the regex? Well, I didn't get it to work with "simulate" either... .
Any comments?
Thank you.
André
Re: regex and system()
You can use quote sign inside quotes using \", example: "some text \"quoted text\" some more text".
You could also try to escape the pipe use \\| instead of |.
- adrpo
- 885 Posts
Re: regex and system()
Alternatively you can use -overrideFile fileWithOverrideValues.txt which you can generate to contain:
Code:
startTime=243
stopTime=391
outputFormat=csv
variableFilter=mixer21.Out.*|mixer22.Out.*|effluentsink1.Out.*|sludgesink1.Out.*
Then you don't run into issues with command line escaping or the max size of the command line.
- adrpo
- 885 Posts
Re: regex and system()
thank you for the hint.
escaping the quote sign works "a little". I get 2 out of 4 variable classes.
escaping the pipe doesn't work.
I'll try the file approach on thursday, when I'm back.
Re: regex and system()
I have to correct myself, escaping the quote sign does do the trick, I had a typo in two of the 4 variable names (sinks do not have outputs, right?).
Thank you!
(well - no need trying the overrideFile approach)
- Index
- » Programming
- » Modelica Language
- » regex and system()