Home > front end >  How to pass a string to omnetpp simulation from the command prompt
How to pass a string to omnetpp simulation from the command prompt

Time:01-31

In my .ned file I have a simple module

simple Txc1
{
    parameters:
        int dummy_number = default(10);
}

When I run the simulation from the command prompt by specifying dummy_number I want i.e.,

opp_run -l tictoc omnetpp.ini --**.dummy_number=15

dummy_number equals 15 in my simulation.
But when instead of integer I want to specify a string

simple Txc1
{
    parameters:
        string dummy_string = default("Some dummy string");
}
opp_run -l tictoc omnetpp.ini --**.dummy_string="Test"

I get the following error

Cannot evaluate parameter 'dummy_string':(omnetpp::cModule)Tictoc1: unknown parameter 'Test' -- in module (Txc1) Tictoc1.tic (id=2), during network setup

Why my string is perceived as a parameter when it is just a value and how do I circumvent the problem? Thanks

CodePudding user response:

As long as your string does not contain a space, add backslashes before quotes, i.e.:

opp_run -l tictoc omnetpp.ini --**.dummy_string=\"TestWithoutSpace\"
  •  Tags:  
  • Related