Condition Macros

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
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 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
search terms
script macro