Re: Multi-purpose include/standalone files - neat trick
- Posted by jbrown105 at speedymail.org Oct 23, 2002
- 384 views
On 0, petelomax at blueyonder.co.uk wrote: > > On Wed, 23 Oct 2002 09:17:49 -0400, Sabal.Mike at notations.com wrote: > > >Both options are good and concise, > hmmm. I've just queried jbrown privately re what he meant. > Main.exw and Include.exw; no other source files, right? And i've sent a private response. > > > but rely on variables set outside the file. > Eh? Not me. > > *My* point was simply that routine_id("xxx") figures this out for you > by returning -1 or a valid routine number (see below). If you wanted > to communicate with the including app, I guess you could call the > isIncludeFile() procedure/function (via call_proc/func()) with various > parameters for each include file, possibly even passing/returning > routine-id()'s of procs/ funcs defined in include/main source the > other wishes to call... No, but you DO rely on a routine set outside the file. I believe this is what Mike is refering to. > > > Personally, I like my include files to be self-contained whenever > >possible. The use of command_line() accomplishes that goal. > > <SNIP some complex stuff> > OK, I'm listening. Explain to me how using command_line() is better. > It works, I agree, but better?!? I don't want to be aggressive > about this, but I really liked the idea I had & am worried you haven't > got it yet. (or you see a flaw I don't). > > Pete Probably means that the main file must be explicitly coded for your feature (or mine, for that matter) to work: if someone else took the include file and used in another program, but was too lazy to use the mechianism to tell the include file IT WAS INCLUDED (i.e. dont define the routine before including or not setting the global variable) then the include file will assume its standalone. The command_line() trick works automaticly, however. (I once used a similar trick when I was trying to emulate threads.) Mike's method works best for general libraries which can also be run stand-alone, while Pete's method and my own work best for specialized include files not meant to be used outside of a particular project. jbrown --