PIKT

Samples: Condition Macros

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


The macros in the sample condition_macros.cfg configuration file below are used as shortcuts for specifying special, complicated conditional tests, for example if a value has increased or deviated by some amount.

///////////////////////////////////////////////////////////////////////////////

// conditional macros - logical conditions

///////////////////////////////////////////////////////////////////////////////

increased(V, T, I)
                // a logical condition that is true if the value of variable
                // (V) was not previously defined and is now > 0; or was
                // defined and if the value has equaled or exceeded
                // threshold (T) for the first time, or if the value has
                // increased by (I) or more
                // (V) is the variable (without type qualifier, e.g., cap)
                // (T) is the threshold (e.g., 75%)
                // (I) is the increase (e.g., 5%)
                (    
                     (    #defined(%(V))
                       && (    (    ( #(V) >= %(V) )
                                 && ( %(V) < (T) )
                               )
                            || (    (I)
                                 && ( #(V) - %(V) >= (I) )
                               )
                          )
                     )
                  || (    ! #defined(%(V))
                       && ( #(V) > 0 )
                     )
                )

///////////////////////////////////////////////////////////////////////////////

deviated(V, P)
                // a logical condition that is true if a value has increased
                // or decreased by a certain percentage or more, or was
                // non-existent or 0 bytes and is now > 0 bytes
                // (V) is the variable (without type qualifier, e.g., size)
                // (P) is the percentage (e.g., 20%)
                (
                     (    #defined(%(V))
                       && (    (    ( %(V) != 0 &&
                                      (#(V) - %(V))/%(V) >= (P) )
                                 || ( %(V) != 0 &&
                                      (#(V) - %(V))/%(V) <= -(P) )
                               )
                            || (    ( %(V) == 0 )
                                 && ( #(V) != 0 )
                               )
                           )
                     )
                  || (    ! #defined(%(V))
                       && ( #(V) != 0 )
                     )
                )

///////////////////////////////////////////////////////////////////////////////

isint(N)        // is (N) an integer?
                ( (N) == #trunc((N)) )

///////////////////////////////////////////////////////////////////////////////

[For more examples, see Samples.]

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

SUSE Linux 9 Bible
SUSE Linux 9 Bible

Red Hat Linux Administration: A Beginner's Guide
Red Hat Linux Administration: A Beginner's Guide

Essential CVS
Essential CVS

SuSE Linux Enterprise Server 9 Administrator's Handbook
SuSE Linux Enterprise Server 9 Administrator's Handbook

UNIX System Administration Handbook
UNIX System Administration Handbook