Why we can't declare array/vector in .ned file?

742 views
Skip to first unread message

Athar

unread,
Nov 21, 2012, 2:27:30 PM11/21/12
to omn...@googlegroups.com
Hi,

I know that we can not declare array or vector in .ned file. But, is there any reason behind it? 

Thank you,

Best Regards,

jan holfeld

unread,
Nov 21, 2012, 3:25:37 PM11/21/12
to omn...@googlegroups.com
Hi,
I don't know why this is not possible.
But you can use strings as an array by defining comma-seperated-strings
and in your c++ code, you just need to cut the whole string into substrings.
This is really easy.

Athar

unread,
Nov 22, 2012, 3:50:55 AM11/22/12
to omn...@googlegroups.com
Thank you for the reply.

But i think this method is suitable for fixed string value. What if the value is change during the simulation, will the previous value will be retained in the original string variable. I mean, if at T=1 i add "20" and then at T=2 i add "30" will the previous value will be retained. I think we have to do little more programming for it.

Best Regards,

jan holfeld

unread,
Nov 23, 2012, 4:08:26 AM11/23/12
to omn...@googlegroups.com
Hi,

I'm not shire, if I understand your problem correctly. With T=1 and T=2, do you mean that this are the different timepositions in the same simulation? Because if yes, then why do you want to change the parameters in the file omnetpp.ini? Because in this file you will give your ned-parameters any fixed value and in the initialization-method you will copy this values in attributes of your class. This attributes can be changed however you want. but you can not change the values in the omnetpp.ini file out of a running simulation (if it is possible and you need to do this, then this is no good programming).

Regards
Jan

jan holfeld

unread,
Nov 23, 2012, 4:08:27 AM11/23/12
to omn...@googlegroups.com

Rudolf Hornig

unread,
Nov 23, 2012, 5:28:17 AM11/23/12
to omn...@googlegroups.com
For the original questions, the answer is rather simple:

The vector parameters are simply not implemented. There are no particular technical issues with them except the lack of time before omnet 4.0 was released. We don't want to change the NED syntax for the 4.x releases so now language features were postponed to the 5.0 version.

Additionally sometimes even vectors are not enough and you need more complex compound data structures. JSON would be suitable for these tasks.

You can workaround the problem with the comma separated list way, or you may use also XML valued parameters (this is definitely for more complex structures).

Rudolf

Athar

unread,
Nov 23, 2012, 5:48:32 AM11/23/12
to omn...@googlegroups.com
Thank you so much for the detail answer. 
Reply all
Reply to author
Forward
0 new messages