COnditionally load include files

Hello,
is it possible to check if an include file has already been loaded by an #include directive and if not to load the include file?
I need such a mechanism because my main DXL program code loads include files, but sometimes the include files among themselves are loading each other.

Thanks in advance, Helko
Helko - Wed Jul 11 11:44:52 EDT 2012

Re: COnditionally load include files
Mathias Mamsch - Wed Jul 11 11:53:36 EDT 2012

Hi Helko,

DXL has no mechanism to do that. Therefore it is common practice in DXL that an include file will not load other includes. Instead the main DXL scripts will need to list all include files and all dependencies in the right order. We use a header in every include file:
 

REQUIRES THE FOLLOWING INCLUDE FILES INCLUDED BEFORE ITSELF IN THIS ORDER:
    --------------------------------------------------------------------------
          #include <src/lib/errorHandler.inc>
          #include <src/lib/Access.inc>
    ----------------------   Tue Jul 20 14:21:41 2010   ----------------------

 


This way whenever you include that file, you can copy paste the includes to your main script, deleting duplicates when they already are included. Maybe that helps, regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: COnditionally load include files
Helko - Wed Jul 11 12:38:39 EDT 2012

Mathias Mamsch - Wed Jul 11 11:53:36 EDT 2012

Hi Helko,

DXL has no mechanism to do that. Therefore it is common practice in DXL that an include file will not load other includes. Instead the main DXL scripts will need to list all include files and all dependencies in the right order. We use a header in every include file:
 

REQUIRES THE FOLLOWING INCLUDE FILES INCLUDED BEFORE ITSELF IN THIS ORDER:
    --------------------------------------------------------------------------
          #include <src/lib/errorHandler.inc>
          #include <src/lib/Access.inc>
    ----------------------   Tue Jul 20 14:21:41 2010   ----------------------

 


This way whenever you include that file, you can copy paste the includes to your main script, deleting duplicates when they already are included. Maybe that helps, regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Thank you!

Re: COnditionally load include files
llandale - Wed Jul 11 13:36:48 EDT 2012

Yes it is complicated with an include includes its dependant includes.

I have a couple of master includes that include the basic stuff in the correct order. The Mains include one of them, and then any of the specialty includes they need. The Includes themselves say which other includes they are dependant, hadn't thought of doing that in the Mains.

But then, I've got 32 Generic Includes and 6 project specific includes. The first 14 basic ones must be in a specific order, a few of the specialty ones depend on other specialty ones.

-Louie