Multi-purpose include/standalone files - neat trick

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

{{{ 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

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 blink)). You also need only the one dummy routine above as many includes as you have.

Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu