Re: Conditional includes

new topic     » goto parent     » topic index » view thread      » older message » newer message
irv said...

How would I do a conditional include?

If x then  
  include foo.e 
end if 

Files are included during the parsing phase and not at execution phase. The "if" statement is a runtime thing so by the time the "if" is executed, all the included files are already included.

However, to have a file optionally included during parsing, you can use the "ifdef" statement, which is a parse-time thing.

ifdef x then  
  include foo.e 
end ifdef 

Also note that files can only be included at the 'top level', which means that you cannot include a file inside a function, for example.

Eu4 uses the "ifdef" a great deal to include things that are only relevant to Unix or to Windows systems as appropriate.

irv said...

Or, somewhat related question: how can I include a file specified as a string:

sequence s = "myfile.e" 
include s 

Being able to do one (or both) of these would be a great help.

Note: the second seems like it 'should' work -

include "myfile.e" -- this does 

You can't. The syntax ...

include "myfile.e" -- this does 

is used when you have spaces embedded in the included file's path. For example...

include "C:/program files/Euphoria Utilities/myfile.e"  

Maybe we can better help you if you explain what it is you are trying to do rather telling us how you want to do it.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu