I think it's quite trivial, but I spent time on finding how to get a float as argument for an application.
It's a little application dealing with boundary conditions, let's name it JulienFoam
I want to be able to use it as:
JulienFoam <Boundary> -numericalarg <float>
for the moment, I have that:
int main(int argc, char *argv)
and I don't find how to get my numericalarg as a float, it seems that argList only gets strings.
If someone can give me any piece of advice, I think it would be very usefull for my future using, not just for that program.
yes, arguments are passed only as strings.
Have a look into fluentMeshToFoam.L where it says:
Perfect, that is exactly what I was looking for! I looked over other applications but not that one.
Thanks a lot!
Just for completeness (to followup on what Henrik mentioned), you might note that readScalar operates on an Istream, and IStringStream can be used to create an Istream from a string.
Thus the following would also work:
Of course, both solutions look fairly messy.
In OpenFOAM-1.6, the same thing becomes much more convenient:
|All times are GMT -4. The time now is 15:58.|