#if()

DESCRIPTION
    returns one number, if a logical expression is TRUE;
    else another number, if the logical expression is FALSE

    or:

    returns a number, if a logical expression is TRUE;
    else the special numerical value NIL, if the logical expression is false
SYNOPSIS
    #if(x,n1,n2)

    or:

    #if(x,n)
ARGUMENTS
     x - a logical condition, or conditional expression
    n1 - a number, or numerical expression
    n2 - a number, or numerical expression

    or:

     x - a logical condition, or conditional expression
     n - a number, or numerical expression
EXAMPLES
        rule    // set $gname, stripping off "+" or "-", if present
                set $gname = $substr($group,#if(#nis,2,1))
        rule    // get log file size, in lines for text files, and KB for
                // binary files
                set #size = #if(#binary, #filesize($name)/=KB,
                                         #val($command("=wc -l $name | =awk '{print \$1}'")))
        rule    // if it's been more than #hrs hours since the last piktd_log
                // entry, piktd is not logging, hence appears to be hung/dead;
                do #split($time, ":")
                set #t =   #datevalue(#yrnow -
                                      #if(#monnow == 1 && $mon eq "Dec", 1, 0),
                                          #monthnumber($mon), #date)
                         + #timevalue(#val($[1]), #val($[2]), #val($[3]))
                if #timenow - #t > #hrs*60*60
                        output mail "piktd appears to be hung/dead on $sys"
                endif
SEE ALSO
    #and()
    #or()
    #true()
    #false()
    #not()

    Numerical Functions
    String Functions
 
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
core file
deletion
Pikt script