Multi-purpose include/standalone files - neat trick
- Posted by petelomax at blueyonder.co.uk Oct 21, 2002
- 401 views
{{{ 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 FlagTrue 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
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