Archive: How to detect if Section exists?


How to detect if Section exists?
Is there a way to detect if Section exist by Id?

For example I have 2 section:

Section "mod1" mod1
SectionEnd
Section "mod2" mod2
SectionEnd

I am dynamically generate my sections blocks.
So I might get in situation when my section mod1 exists, but mod2 dose not.

Problem arise when I try ro set Section flag.
when my mod2 does not exists, call like that:
SectionSetFlags ${mod2} ${SF_SELECTED}
will set flag for section with index 0, which is my mod1.

If I could detect that mod2 does not exist, I could avoid this call.


Only workaround I found is to create dummy hidden section as first section:
Section "" dummy
SectioEnd
In this case all calls to undefined section will affect this dummy section.
Is there a better way?


Sections 'define' their variable. You can test if the variable exists using !ifdef.

Another option is to have a dummy final section and to create a loop that runs from 0 up to the last section (which you could detect by looking for a predefined section name with SectionGetText).

Don


!ifdef
is perfect, thanks a lot.