#abs(), #absval(), #absolutevalue()

DESCRIPTION
    returns the absolute value of a number
SYNOPSIS
    #abs(n)
    #absval(n)
    #absolutevalue(n)
ARGUMENTS
    n - a number, or numerical expression
EXAMPLES
# pikt +C 'output $text(#abs(-3))'
3

# pikt +C 'output $text(#abs(3))'
3
        rule    // there is a problem with autotruncating just any system log
                // file:  if we time this wrong, we might lose sight of vital
                // signs that other alarms might detect; we *could* try to
                // time this just right, but it's safer, in the case of
                // security-related logs (like authlog and sulog) simply to
                // report that they are oversized, and leave the truncation
                // to the human operator, after he/she has had the chance
                // to review the tail end of the log file; report-no-truncate
                // is indicated by #maxsize being set to a negative number
                if    #size > #abs(#maxsize)
                   && #maxsize < 0      // negative number signals report only
                        output mail "$name is due for truncation,
                                     is $text(#size) " . $if(#binary, "KB", "lines")
                        output mail "review the file, then do:  " .
                                     $if($preproc eq ".", "", "$preproc; ") .
                                     "=trunc " .
                                     $if(#binary, "0", "100") .
                                     " $name" .
                                     $if($postproc eq ".", "", "; $postproc")
                        next
                endif

        rule    // if oversized, do special pre-truncation actions
                if    #size > #abs(#maxsize)
                        if $preproc ne "."
                                =execwait $preproc
                        endif
                endif

        rule    // if oversized, truncate
                if #size > #abs(#maxsize)
                        =outputmail "Truncating $name, was $text(#size) " .
                                     $if(#binary, "KB", "lines")
                        =execwait "=trunc " . $if(#binary, "0", "100") . " $name"
                endif

        rule    // if oversized, do special post-truncation actions
                if #size > #abs(#maxsize)
                        if $postproc ne "."
                                =execwait $postproc
                        endif
                endif
SEE ALSO
    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
system file owners
& permissions changes
Pikt script