Re: Conditional includes

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

At any rate - that's what I'm trying to do. IF we could do that (I think it's impossible in Euphoria) it would make for much cleaner, easier to use code (The Glade IDE could, for example, be used to create an entire Eu program)

You could do something were you require the file to be a particular name, and to be in the same directory as the main file. This directory would be in the include path. So, suppose you require that the user puts their stuff in a file called gtk_custom.e, then you could:

-- funks.e 
-- This file is fixed, non-editable. It cannot 'see' the user-written includes,  
-- but it must access the user-written functions in those includes.  
  
export procedure do_fn(sequence s)  
atom rid = routine_id(s)  
printf(1,"do_fn sez routine_id is: %d\n",{rid})  
--call_func(rid)  
end procedure  
  
-- code here decides which routine will be called.  
-- based on which button pushed, etc.  
  
-- if btn.name = "file_close" then  
do_fn("custom:close") -- as an example  
include gtk_custom.e as custom 
 

Note also that default namespaces (which are declared using namespace foo at the top of a file) are public symbols, meaning that they can be transmitted via indirect includes:

-- a.e 
namespace a_e 
 
procedure foo() 
   ... 
end procedure 
 
-- b.e 
public include a.e 
 
-- c.ex 
include b.e 
 
-- c.ex can see namespace a_e since b.e used public include, and  
-- c.ex includes b.e 
a_e:foo() 

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu