For-like loop in .ini configuration file

954 views
Skip to first unread message

Alex Shpiner

unread,
Jun 5, 2014, 3:47:23 AM6/5/14
to omn...@googlegroups.com

Hi,

Is is possible to define for-like loop in the .ini files?

For example, assume that I have an array of hosts (host[*]) and I need to set some parameter based on the index in the array like:
**.host[i].my_index = i

Is there a way to do it in the .ini file? 

Thanks,
Alex.

Michael Kirsche

unread,
Jun 5, 2014, 4:30:52 AM6/5/14
to omn...@googlegroups.com
There is a possibility to define loops / iterations for parameter studies...
Check the chapter 9.4 and the following subsections (especially 9.4.2, 9.4.3 and 9.4.5) in the OMNeT manual, maybe you can use those structures to get what you want.

Rudolf Hornig

unread,
Jun 6, 2014, 6:22:15 AM6/6/14
to omn...@googlegroups.com
**.host[i].my_index = parentIndex()

However I don't see why you need this in the INI file. In C++ code you can access the index directly using C++ API

Alex Shpiner

unread,
Jun 10, 2014, 3:32:15 AM6/10/14
to omn...@googlegroups.com
Thanks Michael.
I read this chapter. It is not enough for me, since I need the configuration for a single simulation and not for separate runs.
Alex.

Alex Shpiner

unread,
Jun 10, 2014, 3:38:09 AM6/10/14
to omn...@googlegroups.com
Thanks Rudolf.
Indeed I wasn't aware of the parentIndex() function. I would propably use it in some configurations.
Yet, I feel that a function that returns my index instead of parent index is what would fit my needs best. I couldn't find that in the manual.
Of course, I could adapt the C++ code to do that, and, actually, avoid INI configurations at all, but configure it in the INI seems more natural.

Alex.

Alex Shpiner

unread,
Jun 10, 2014, 4:12:02 AM6/10/14
to omn...@googlegroups.com
I succeed to use index() to get my index in the INI file.
It is not documented in the manual.

Rudolf Hornig

unread,
Jun 11, 2014, 4:08:39 AM6/11/14
to omn...@googlegroups.com

On Tuesday, 10 June 2014 10:12:02 UTC+2, Alex Shpiner wrote:
I succeed to use index() to get my index in the INI file.
It is not documented in the manual.

Actually it is :)


For historical reasons it is implemented as an operator (so it is part of the language) and not as a function.

For completeness: int ancestorIndex(int numLevels) is also available. This one is the most generic function in this regard.
Rudolf  
Reply all
Reply to author
Forward
0 new messages