1. Re: [now unprivate] Re: Multi-purpose include/standalone files - neat trick

Pete I tried to send this to you privately, but

----- Forwarded message from postmaster at blueyonder.co.uk -----

From: postmaster at blueyonder.co.uk
To: jbrown105 at jbrown.mylinuxbox.org
Subject: Nondeliverable mail

------Transcript of session follows -------
pl015b1363 at blueyonder.co.uk
The intended recipient's mailbox is full.

as you can see I can't. Hope you don't mind if I reply here instead.

....... the message ................

On  0, Pete Lomax <petelomax at blueyonder.co.uk> wrote:
<snip>
> >which actually lets the file count how many times its been included.
> erm, I'm intrigued again. exw.exe (et al) deliberately do not include
> an include file more than once (bar namespace stuff)...
> 
> I see: control.e: global integer why=0
> 	  include.e: include control.e
> 				if why=0 then standalone
> 				elsif why=1 then accounts package
> 				elsif why=2 then graphics package
> 				...
> & accounts.exw: include control.e why=1 include include.e;
>     graphics.exw: include control.e why=2 include include.e...
> 
> >>
> All that is neat, but "lets the file count how many times its been
> included."; I'm lost.
> 
> Pete

Well try this code out under Euphoria:

	control.e: global integer why=0
	  include.e: include control.e
				if why=0 then standalone
				elsif why=1 then included once
				elsif why=2 then included twice
				...
accounts.exw: include control.e why+=1 include include.e
graphics.exw: include control.e why+=1 include include.e

I use a namespace parser which bypasses Euphoria's use of include files.
hence this is untested for plain Eu (I only do clever inclusion tricks
with
my parser - RDS's vision of namespaces and such disagree with mine, and I
find my version is more flexible.)

So this trick works for me (but I rarely use it) but it may not work for
you.

jbrown

-- 

Linux User:190064
Linux Machine:84163


-- 

----- End forwarded message -----

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu