#defined()

DESCRIPTION
    returns TRUE (1) if the argument resolves to a value, or in the case of
    variables has appeared in a previous dat or set statement, or has a
    previous or preceding value; FALSE (0) otherwise

    #defined(ERR), #defined(NIL), #defined("<<ERR>>"), and
    #defined("<<NIL>>") are always FALSE (0)
SYNOPSIS
    #defined(x)

    or:

    #defined(s)

    or:

    #defined(n)
ARGUMENTS
    x - a logical value, or logical expression

    or:

    s - a quoted string, or string expression

    or:

    n - a number, or numerical expression
EXAMPLES
        rule    // duplicate users
                if #defined($passwdentry[$user])
                        output mail "Duplicate users ($user):"
                        output mail "  $passwdentry[$user]"
                        output mail "  $inlin"
                endif
                set $passwdentry[$user] = $inlin
        rule
                set #fmt[$fil] = #filemtime($fil)

        rule    // make a history copy of all new scripts
                if ! #defined(%fmt[$fil])
                        if =offhours(#hour())
                                doexec wait "=cp -p $fil $hstfil"
                                output log "(L)" "new script:  $fil"
                        fi
                        next
                fi
        rule
                if $state eq "+"
#ifdef verbose
                        // for high-level alerts, report if systems back up
                        if =highlevelalert
                                // if state was "-", is now "+", report change
                                if #defined(%state) && $state ne %state
                                        output mail $upmsg
                                fi
                        fi
#endifdef
                        next
                fi
        rule    // for exceeding max thresholds
                if $typ eq "+"
                        set $msg = "$dev: $oid $text(#oidval) >= mailval $text(#mailval)"
                        // email if greater than or equal to #mailval,
                        // and thereafter only if is rising
                        if    #oidval >= #mailval
                           && (! #defined(%oidval) || #oidval > %oidval )
                                output mail $msg
                                =shout($msg, =always)
                        fi
                        // page if greater than or equal to #pageval,
                        // but only once every hour
                        if    #oidval >= #pageval
                                =hourly(=page($msg, =allpager, =always), )
                        fi
                fi

        rule    // for falling short of min thresholds
                if $typ eq "-"
                        set $msg = "$dev: $oid $text(#oidval) <= mailval $text(#mailval)"
                        // email if lesser than or equal to #mailval,
                        // and thereafter only if is falling
                        if    #oidval <= #mailval
                           && (! #defined(%oidval) || #oidval < %oidval )
                                output mail $msg
                                =shout($msg, =always)
                        fi
                        // page if lesser than or equal to #pageval,
                        // but only once every hour
                        if    #oidval <= #pageval
                                =hourly(=page($msg, =allpager, =always), )
                        fi
                fi
        rule    // report sum change
                if    #defined(%sum)
                   && $sum ne %sum
                        output log "=piktfileproblems_log" "$name has changed sum to $sum,
                                                            was %sum"
#ifdef verbose
                        output mail                        "$name has changed sum to $sum,
                                                            was %sum"
#endifdef
                        set #changed = #true()
                endif

        rule    // report blocks change
                if    #defined(%blk)
                   && $blk ne %blk
#ifdef verbose
                        output mail                        "$name has changed blk to $blk,
                                                            was %blk"
#endifdef
                        output log "=piktfileproblems_log" "$name has changed blk to $blk,
                                                            was %blk"
                        set #changed = #true()
                endif

        rule    // report size change
                if    #defined(%size)
                   && $size ne %size
#ifdef verbose
                        output mail                        "$name has changed size to $size, was %size"
#endifdef
                        output log "=piktfileproblems_log" "$name has changed size to $size,
                                                            was %size"
                        set #changed = #true()
                endif
        end
                // report new procs not in old proc list
                foreach #keys($p, #procs)
                        if ! #defined(%procs[$p])
                                output log "=acmeprocesslistchange_log" "alive:   $p"
                        fi
                endforeach
                // report old procs not in new proc list
                foreach #keys($p, %procs)
                        if ! #defined(#procs[$p])
                                output log "=acmeprocesslistchange_log" "dead:  $p"
                        fi
                endforeach
SEE ALSO
    #err()
    #error()
    #nil()

    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 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
kill idle
user sessions
Pikt script