Using the value of a variable defined in NED file in omnetpp.ini file

Viewed 27

I want to use "numHosts" variable value in the second command [output-scalar-file] in omnetpp.ini by referring the "numHosts" variable defined in NED file.

*.numHosts = 4
output-scalar-file = ${resultdir}/${configname}-h${par("numHosts").strValue}.sca

But this error is generated in simulation running phase:

Scenario generator: Missing '=' after '${varname' at output-scalar-file=${resultdir}/${configname}-h${par("numHosts").strValue}.sca

How to solve it?

1 Answers

One cannot use NED parameters in an ini file. However, iteration variables may be used. Therefore in order to achieve your goal you can create and use a "temporary" iteration variable:

*.numHosts = ${nh=4}
output-scalar-file = ${resultdir}/${configname}-${iterationvarsf}.sca

It generates the following file:

General-nh=4-.sca
Related