Re: Multi-purpose include/standalone files - neat trick
- Posted by jbrown105 at speedymail.org Oct 22, 2002
- 383 views
Before routine_id() (BTW I never did figure out this trick on my own), I used this method: file eubasic.e: global integer included included = 0 include/standalone file: include eubasic.e if included = 0 then .... else ... end if .... in main file: include eubasic.e included = 1 include the includable/standalone file My version doesnt require routine_id(), but yours is simpler. Just thought I'd share my variant of your idea as well :) jbrown On 0, petelomax at blueyonder.co.uk wrote: > > Trying to write code that could be equally used as part of a package > and/or as a standalone function. Not just for being nice sake, but for > ease of development. > > Long time ago I realised that: > > global Flag=True > include fred.ew > > would fail as Flag had not been declared, (runing fred s/alone), and: > > include fred.ew -- defines global Flag (=False) > Flag=True > > would be too late as fred would trigger standalone processes... > > * * HOWEVER * *: > =============== > > global procedure isIncludeFile() -- dummy > end procedure > > include fred.ew > > works a treat as fred.ew can simply ask: > > if routine_id("isIncludeFile")=-1 then > -- code to be run if standalone > else > -- probably little or no code to be run if an include > end if > ... > > > Thought I would share that as it just worked out rather well )). > You also need only the one dummy routine above as many includes as you > have. > > Pete > > ==^^=============================================================== > This email was sent to: jbrown105 at speedymail.org > > > -- Linux User:190064 Linux Machine:84163 --