Some Useful Defines

[posted 2001/03/24]

Here's a useful tip.  Whenever we install PIKT on a new system, we register it in the newsys group:

newsys                  // set '-D doexec +D verbose' for these (or just
                        // set these in defines.cfg accordingly)

        members         laki

                        // nantes
                        // murmansk

and we install files on the system with, for example,

#piktc -iv -D doexec +D verbose +A all +O all +P all +F all +H laki

so that (a) no 'exec' or 'exec wait' statements will be acted on (just e-mail of intention will be sent) and (b) PIKT will be exceptionally chatty. This gives us the opportunity to review the situation before we commit to doing exec's and turning off the chattiness.

All well and good, but sometimes we forget to use the '-D doexec +D verbose', and we therefore commit to full production mode before we're ready.

PIKT preprocessor directives to the rescue! Now, instead of setting a domain-wide uniform default for doexec and verbose in defines.cfg, we set them conditionally with some useful defines:

doexec
#if newsys
                false   // if FALSE, don't exec any commands or take any
                        // actions that might change anything; output
                        // messages (logs, etc.) or take other innocuous
                        // actions only; you might unset doexec if you are
                        // checking out PIKT for the first time and want
                        // to proceed cautiously, or if you have just
                        // set up PIKT on a new machine and want to check
                        // out the config for that machine first
#else
                true
#endif

verbose
#if newsys
                TRUE    // if TRUE, output mail about routine execs, such as
                        // "deleting <this>" or "truncating <that>"; usually
                        // set this to FALSE; but occasionally set this to
                        // TRUE to get a fuller report of all that PIKT is
                        // doing silently, behind-the-scenes
#else
                off
#endif

So, even if we forget to use the '-D doexec +D verbose' with a newsys, the new defines.cfg settings do the remembering for us.  Moving a new system from provisional to full production status is as easy as removing its registration as a newsys in systems.cfg.

Similarly, on test systems we want to use '+D debug' regularly:

testsys                 // set '+D debug' for these (or just
                        // set this in defines.cfg accordingly)

        members         laki
                        // piktmaster

But we might forget to specify the '+D debug'.  This revised debug specification in defines.cfg enforces the 'debug TRUE' setting for us:

debug
#if testsys
                true
#else
                false   // by default, don't run any debug code
#endif

(Note that, in addition to 0, 1, FALSE, TRUE, you may now also use any of

1, TRUE, true, YES, yes, ON, on
0, FALSE, false, NO, no, OFF, off

in your defines.cfg settings.)

Speaking of debug, there is a new PIKT.conf setting

debug           TRUE    // or true, FALSE, false, ...

that turns on debug logging for all PIKT binaries without your having always to specify '-G' when running PIKT programs.

For more examples, see Developer's Notes.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2018-01-02.   This site is PIKT® powered.
Copyright © 1998-2018 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
Learn about the
script development &
testing process