<html> <head> <!-- This file has been generated by unroff 1.0, 03/11/09 12:56:15. --> <!-- Do not edit! --> <STYLE TYPE="text/css"> <!-- A:link{text-decoration:none} A:visited{text-decoration:none} A:active{text-decoration:none} OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; } H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; } H2 { font-size: large; font-family: arial,helvetica,sans-serif; } H3 { font-size: medium; font-family: arial,helvetica,sans-serif; } H4 { font-size: small; font-family: arial,helvetica,sans-serif; } --> </STYLE> <title>ploticus: functions</title> <body bgcolor=D0D0EE vlink=0000FF> <br> <br> <center> <table cellpadding=2 bgcolor=FFFFFF width=550><tr> <td> <table cellpadding=2 width=550><tr> <td><br><h2>functions</h2></td> <td align=right> <small> <a href="../doc/welcome.html"><img src="../doc/ploticus.gif" border=0></a><br> Version 2.41 Mar2009 </small><br><a href="../doc/scripthome.html">Scripts</a> <td></tr></table> </td></tr> <td> <br> <br> <title>Manual page for functions(PL)</title> </head> <body> <p> Categories of available functions: <p> <a href="functions.html#ploticus"> plotting </a> <br> <a href="functions.html#arithmetic"> arithmetic </a> <br> <a href="functions.html#strings"> strings </a> <br> <a href="functions.html#commalists"> commalists </a> <br> <a href="shell.html"> shell </a> <br> <a href="sql.html"> sql </a> <br> <a href="functions.html#dates"> dates </a> <br> <a href="functions.html#times"> times </a> <br> <a href="functions.html#misc"> misc </a> <br><br><br> <h2>HOW TO USE FUNCTIONS</h2> <p> A number of functions are available for use in <a href="scripts.html"> ploticus scripts </a> and <a href="getdata.html"> proc getdata filters </a> , for a wide range of purposes including processing of arithmetic, strings dates, times, <a href="commalist.html"> commalists </a> , and so on. Functions usually take one or more arguments and return a value.<tt> </tt> Functions may be used with <a href="scriptsyntax.html#set"> #set </a> , <a href="scriptsyntax.html#call"> #call </a> or as operands in <a href="scriptsyntax.html#if"> #if/#elseif </a> <a href="condex.html"> conditional expressions </a> . <p> Custom functions may be coded and added to the file <tt>custom.c</tt>, and accessed like any of the built in functions, except that the names of custom functions should begin with a double dollar sign ($$) when invoked from scripts.<tt> </tt> <br><br><br> <h2>FUNCTION SYNTAX</h2> Function names always start with a dollar sign (<b>$</b>).<tt> </tt> Function arguments are enclosed by parentheses and if more than one argument, separated by commas (,). For example: <dl> <dt> <dd> <tt>$formatfloat( @NUM, "%7.2f" )</tt> </dl> <p> Function calls may not be nested, ie. function arguments may not be functions.<tt> </tt> <br><br><br> <p> In the following summaries, the function name appears along with a template for arguments that must be supplied.<tt> </tt> <br><br><br> <a name=ploticus></a> <h2>PLOTTING</h2> Note: the functions in this section may be used with a double dollar sign ($$) for faster function name search.<tt> </tt> Because of the way ploticus script files are parsed, <tt>#endproc</tt> should be used to terminate any #proc previous to these function calls, so that the proc executes before the function call.<tt> </tt> <p> <b>$inrange( value, axis )</b> or <br> <b>$inrange( value, axis, min, max )</b> <dl> <dt> <dd> Return 1 if <i>value</i> within a range on the given <i>axis</i>.<tt> </tt> <i>min</i> and <i>max</i> are optional; if given they determine the range.<tt> </tt> If they are not given the range is the range of the axis within the plotting area.<tt> </tt> <br><br> </dl> <p> <b>$icolor( i )</b> <dl> <dt> <dd> Return one of 20 preselected colors. The color sequence was selected to give good contrast between nearby entries.<tt> </tt> <i>i</i> allowable range is 1 to 20; values out of this range are modulo into range.<tt> </tt> <br> Example: <tt>#set COLOR = $icolor( 2 ) <br><br> </tt></dl> <p> <b>$fieldname( n )</b> <dl> <dt> <dd> Return the field name assigned to field <i>n</i>. First is 1.<tt> </tt> If no field name was defined, <tt>noname</tt> is returned.<tt> </tt> <br><br> </dl> <p> <b>$dataitem( row, field )</b> <dl> <dt> <dd> Return the contents of the item in <i>row</i> and <i>field</i> of the current data set. <i>row</i> is a number, first is 1.<tt> </tt> <i>field</i> is either a number or an assigned name.<tt> </tt> <br><br> </dl> <p> <b>$defaultinc( min, max )</b> <dl> <dt> <dd> Return a reasonable increment given numeric <i>min</i> and <i>max</i>, using the same algorithm used with axis stub increments.<tt> </tt> <br> Example: <tt>#set inc = $defaultinc( 0, 200 )</tt> <br><br> </dl> <p> <b>$changeunits( axis, newunitspec )</b> <dl> <dt> <dd> Change the scaling units associated with an existing axis.<tt> </tt> <br> Example: <tt>#call $changeunits( x, "date nqyy" )</tt> <br><br> </dl> <p> <b>$squelch_display( mode )</b> <dl> <dt> <dd> #call $squelch_display( 1 ) .. will squelch all drawing activity. <br> #call $squelch_display( 0 ) .. will resume drawing activity. <br> Note that <tt>#endproc</tt> must terminate any #proc previous to these function calls. (version 2.30+) <br><br> </dl> <p> <b>$boundingbox( mode )</b> <dl> <dt> <dd> #call $boundingbox( 0 ) .. subsequent drawing does not influence the bounding box and hence the crop <br> #call $boundingbox( 1 ) .. restore to normal mode of operation.<tt> </tt> <br> Note that <tt>#endproc</tt> must terminate any #proc previous to these function calls. (version 2.30+) <br><br> </dl> <p> <b>$data_to_absolute( axis, val )</b> <dl> <dt> <dd> Given a data location <i>va</i> in either X or Y space (specified by <i>axis</i>), return the absolute location.<tt> </tt> <br><br> </dl> <p> <b>$sleep( n )</b> <dl> <dt> <dd> Delay for <i>n</i> seconds. Occasionally useful when viewing plots interactively.<tt> </tt> <br><br> </dl> <p> <b>$getclick()</b> <dl> <dt> <dd> Produce a "More.." button and wait for user to click on it.<tt> </tt> Upon the click, return.<tt> </tt> Occasionally useful when viewing plots interactively.<tt> </tt> <br><br> </dl> <p> <b>$errmsgpre( tag )</b> <dl> <dt> <dd> Allows developer to set the first portion of all ploticus error messages to <tt>tag</tt> (it will stay in effect until explicitly set again).<tt> </tt> For example, where a web page generates multiple plots it may be useful in identifying which plot had the error.<tt> </tt> <br><br> </dl> <p> <b>$textwidth( text, font, size)</b> <dl> <dt> <dd> Return horizontal width of freetype bounding box.<tt> </tt> Useful only with freetype fonts, otherwise it returns 0. Suggested/contributed by Erik Zachte.<tt> </tt> <br><br> </dl> <p> <b>$rewritenums( f )</b> <dl> <dt> <dd> takes a numeric quantity <i>f</i> and returns it rewritten for display purposes, applying numbernotation (as specified in your proc settings or config file).<tt> </tt> <br><br> <a name=arithmetic></a> <br><br><br> </dl> <h2>ARITHMETIC AND NUMBERS</h2> <p> <b>$arith( exp, format )</b> <dl> <dt> <dd> Simplistic arithmetic expression evaluator. <i>exp</i> is an expression made up of numbers and the arithmetic operators <tt>+ - * /</tt>.<tt> </tt> No embedded spaces nor parentheses are allowed within the expression.<tt> </tt> Evaluation is strictly left to right.<tt> </tt> Unary plus/minus are allowed.<tt> </tt> In versions 2.30+ scientific notation eg. <tt>3.74e-07</tt> is supported.<tt> </tt> <i>format</i> is an optional printf(3) display format specifier controlling the format of the result, eg. <tt>%.0f</tt>. Default format is <tt>%g</tt>, which should suffice for all but very large or very small values. For more on format specifiers see your manual page on printf(3).<tt> </tt> <br> Example: <tt>#set RESULT = $arith(2+8/5)</tt> (result: 2) <br> Example: <tt>#set RESULT = $arith(2+-8)</tt> (result: -6) <br> Example: <tt>#set RESULT = $arith( 18*1000000000 , "%.f" ) <br> Example: </tt><tt>#set RESULT = $arith( 18*.0000001 , "%.9f" ) </tt></dl> <p> <b>$arithl(exp)</b> <dl> <dt> <dd> Same as <b>$arith()</b> except lazy, i.e. non-numeric operands are accepted and treated as if they were 0. </dl> <p> <b>$isnumber(s)</b> <dl> <dt> <dd> Returns 1 if <i>s</i> is a valid number, 0 if not.<tt> </tt> In versions 2.30+ scientific notation is supported.<tt> </tt> <br> Example: <tt>#set RESULT = $isnumber(-0.24)</tt> (result: 1) <br> Example: <tt>#set RESULT = $isnumber(=)</tt> (result: 0) </dl> <p> <b>$formatfloat(x,fmt)</b> <dl> <dt> <dd> Format <i>x</i> using printf-style format string <i>fmt</i>.<tt> </tt> May also be used to format integers by using a <i>fmt</i> such as <tt>%03.0f</tt>.<tt> </tt> <br> Example: <tt>#set RESULT = $formatfloat( 3.4425, "%3.2f" )</tt> (result: 3.44) </dl> <p> <b>$inr(n,lo,hi)</b> <dl> <dt> <dd> See if <i>n</i> is within the numeric range of <i>lo</i> to <i>hi</i>. Returns 1 if so, 0 if not. Non-numeric <i>n</i> always returns 0.<tt> </tt> </dl> <p> <b>$numgroup( val, h, mode )</b> <dl> <dt> <dd> Convert <i>val</i> to a nearby multiple of <i>h</i>.<tt> </tt> Useful in grouping a set of numbers into bins.<tt> </tt> <i>mode</i> may be either <tt>low</tt>, <tt>mid</tt>, or <tt>high</tt>. For example, if f is 73 and h is 10, function returns 70, 75, or 80 for modes <tt>low</tt>, <tt>mid</tt>, <tt>high</tt> respectively.<tt> </tt> </dl> <p> <b>$autoround(val,d)</b> <dl> <dt> <dd> Round <i>val</i> to a reasonable precision.<tt> </tt> Use a value of 0 for <i>d</i> for normal behavior. Increase <i>d</i> to get more precision, reduce <i>d</i> to get less precision.<tt> </tt> <br> Example: <tt>#set X = $autoround( @X, 0 )</tt> </dl> <p> <b>$math(what,a,b)</b> <dl> <dt> <dd> Various mathematical functions. <i>a</i> and <i>b</i> can be integer or floating point unless otherwise noted below.<tt> </tt> <pre> what returns ---- ------- abs absolute value of <i>a</i> mod <i>a</i> modulo <i>b</i> div integer division <i>a</i> / <i>b</i> (<i>a</i> and <i>b</i> must be integers) pow <i>a</i> raised to <i>b</i> mag <i>a</i> multiplied by 10 to the <i>b</i> log+1 the natural log of <i>a</i>, plus 1.0 exp-1 the exponential of <i>a</i>, minus 1.0 sqrt the square root of <i>a</i> </pre> <br> Example: <tt>#set X = $math(abs,-57)</tt> would return <tt>57</tt>.<tt> </tt> <br> Example: <tt>#set X = $math(mod,10,6)</tt> would return <tt>4</tt>.<tt> </tt> </dl> <p> <b>$random()</b> <dl> <dt> <dd> Returns a random number between 0.0 and 1.0.<tt> </tt> </dl> <p> <b>$ranger( rangespec )</b> <dl> <dt><dd><p> Convert an integer range specification to an enumerated list of all integers covered. Range specifications can contain integers separated by commas or dashes, with no embedded spaces.<tt> </tt> Example: <br> <tt> #set RANGE = "5,8,11-15" <br> #set LIST = $ranger( @RANGE ) </tt> <br> LIST would then contain <tt> 5,8,11,12,13,14,15 </tt> <a name=strings></a> <br><br><br> </dl> <h2>STRINGS</h2> <p> <b>$len(s)</b> <dl> <dt> <dd> Return the length of <i>s</i>.<tt> </tt> </dl> <p> <b>$change(s1,s2,string)</b> <dl> <dt> <dd> Change all occurances of <i>s1</i> to <i>s2</i> in string.<tt> </tt> <br> Example: <tt>#set T = $change( "<", "<sup>", @T )</tt> </dl> <p> <b>$expand( s )</b> <dl> <dt> <dd> Expand all @variables present in <i>s</i>.<tt> </tt> Example: <pre> #set B = "@A world" #set A = hello #set C = $expand( @B ) </pre> Variable C would then contain <tt>hello world</tt>.<tt> </tt> </dl> <p> <b>$substring(s,n,len)</b> <dl> <dt> <dd> Return a substring of <i>s</i>. Substring begins at character <i>n</i> (first is 1) for a maximum length of <i>len</i>.<tt> </tt> This function may also be used to count back from the end of the string and take a substring-- to do this, specify a negative <i>n</i> (see 2nd example below).<tt> </tt> <br> Example: <tt>$substring( "abcde", 3, 99 )</tt> would give <tt>cde</tt> <br> Example: <tt>$substring( "abcde", -2, 99 )</tt> would give <tt>de</tt> </dl> <p> <b>$changechars(clist,s,newchar)</b> <dl> <dt> <dd> If string <i>s</i> contains any of chars in <i>clist</i>, change that character to <i>newchar</i>. <b>clist</b> may be passed as the word <tt>comma</tt> to represent a comma (,).<tt> </tt> <br> Example: <tt>#set RESULT = $changechars("*'", @S, "_" )</tt> </dl> <p> <b>$deletechars(clist,s)</b> <dl> <dt> <dd> If string <i>s</i> contains any of chars in <i>clist</i>, delete that character.<tt> </tt> <br> Example: <tt>#set RESULT = $deletechars("*'",@S)</tt> </dl> <p> <b>$stripws( s, mode )</b> <dl> <dt> <dd> Remove whitespace characters from <i>s</i>.<tt> </tt> If mode is "any", all whitespace characters are removed.<tt> </tt> Otherwise only leading and trailing whitespace is stripped off.<tt> </tt> </dl> <p> <b>$contains(clist,s)</b> <dl> <dt> <dd> If string <i>s</i> contains any of chars in <i>clist</i>, return position (first=1) of the first occurance. Return 0 if none found. <i>clist</i> may be passed as the word <tt>comma</tt> to represent a comma (,).<tt> </tt> <br> Example: <tt>#set RESULT = $contains( "*'", @S )</tt> <br> Example: <tt>#set RESULT = $contains( ",", @S )</tt> </dl> <p> <b>$lowerc(string)</b> <dl> <dt> <dd> Return the lower-case equivalent of <i>string</i>.<tt> </tt> <br> Example: <tt>#set RESULT = $lowerc(HELLO)</tt> (result: <tt>hello</tt>) </dl> <p> <b>$upperc(string)</b> <dl> <dt> <dd> Return the upper-case equivalent of <i>string</i> <br> Example: <tt>#set RESULT = $upperc(Hello)</tt> (result: <tt>HELLO</tt>) </dl> <p> <b>$capit(string)</b> <dl> <dt> <dd> Return the <i>string</i> with first letter capitalized. (added 5/15/08).<tt> </tt> <br> Example: <tt>#set RESULT = $upperc(hello)</tt> (result: <tt>Hello</tt>) </dl> <p> <b>$strcmp(s,t)</b> <dl> <dt> <dd> Return an integer representation of the difference in magnitude of <i>s</i> and <i>t</i>, using ascii order. <br> Note: don't use this for #if statement equality comparisons; simple <tt>=</tt> and <tt>!=</tt> should be used instead.<tt> </tt> <br> Example: <tt>#set RESULT = $strcmp(ABC,XY)</tt> (result will be a negative integer) <br> Example: <tt>#set RESULT = $strcmp(XY,ABC)</tt> (result will be a positive integer) </dl> <p> <b>$strcat(s,t)</b> <dl> <dt> <dd> Return the concatenatation of strings <i>s</i> and <i>t</i> <br> Example: <tt>#set RESULT = $strcat(ABC,XY)</tt> (result: <tt>ABCXY</tt>) </dl> <p> <b>$ntoken( n, s [,c] )</b> <dl> <dt> <dd> Return the <i>n</i>th whitespace-delimited token in <i>s</i>.<tt> </tt> Or if <i>c</i> is specified as a single character, it is used as the delimiter... return the <i>n</i>th field in <i>s</i> (added 3/28/08).<tt> </tt> </dl> <p> <b>$counttokens( s [,c] )</b> <dl> <dt> <dd> Return the number of whitespace-delimited tokens in <i>s</i>.<tt> </tt> Or if <i>c</i> is specified as a single character, it is used as the delimiter... return the <i>n</i>th field in <i>s</i> (added 5/15/08).<tt> </tt> </dl> <p> <b>$extractnum( s )</b> <dl> <dt> <dd> Extract the first numeric entity embedded anywhere in <i>s</i> and return it.<tt> </tt> </dl> <p> <b>$wildcmp( s1, s2 )</b> <dl> <dt> <dd> Return the result of a wildcard-enabled match s1 vs. s2. s2 can contain wild cards.<tt> </tt> Return value is 0 on a match, -1 if s1 is "less than" s2, and 1 if s1 is "greater than" s2.<tt> </tt> </dl> <p> <b>$encrypt( s, salt )</b> <dl> <dt> <dd> Returns the result of one-way encryption of s. Uses crypt(3C). salt is optional 2 character perturbation string.<tt> </tt> </dl> <p> <b>$urlencode( s )</b> <dl> <dt> <dd> Returns the url-encoded version of s.<tt> </tt> </dl> <p> <b>$urldecode( s )</b> <dl> <dt> <dd> Returns the url-decoded version of s.<tt> </tt> <a name=commalists></a> <br><br><br> </dl> <h2>COMMALISTS</h2> These functions operate on a string which is in the form of a <a href="commalist.html"> commalist </a> .<tt> </tt> <p> <b>$count(str,list)</b> <dl> <dt> <dd> Count the number of times <i>str</i> appears in <i>list</i>. If <i>str</i> is passed as <tt>*</tt> then this function will count the number of members in the list.<tt> </tt> <br> Example: <tt>#if $count( "*", "a,b,c" ) = 3</tt> (true) <br> Example: <tt>#set RESULT = $count( "hello", "aba,gabba,jabba" )</tt> (result: 0) <br> Example: <tt>#set RESULT = $count( "x", "x,y,x,y,y,z,x" )</tt> (result: 3) </dl> <p> <b>$addmember(newmem,list)</b> <dl> <dt> <dd> Append a new member <i>newmem</i> to end of <i>list</i>.<tt> </tt> If <i>list</i> is empty before call, result will have one member.<tt> </tt> <br> Example: <tt>#set RESULT = $addmember( "red", @MYLIST )</tt> </dl> <p> <b>$deletemember(mem,list)</b> <dl> <dt> <dd> Remove a member <i>mem</i> from <i>list</i>.<tt> </tt> <br> Example: <tt>#set RESULT = $deletemember( "red", @MYLIST )</tt> </dl> <p> <b>$nmember(n,list)</b> <dl> <dt> <dd> Get the <i>n</i>th member of <i>list</i>. <br> Example: <tt>#set RESULT = $nmember( 2, "a,b,c,d,e" )</tt> (result: <tt>b</tt><b>) </b></dl> <p> <b>$commonmembers( list1, list2, mode ) </b><dl> <dt> <dd> Detect if <i>list1</i> and <i>list2</i> have any members in common.<tt> </tt> Returns 0 if no members in common.<tt> </tt> If <i>mode</i> is <tt>"count"</tt>, then the number in common is returned (for a,b,c vs. c,d,e this would be 1; for a,a,a vs a,b,c it would be 3).<tt> </tt> Otherwise, when a match is found 1 is returned immediately.<tt> </tt> <br> Example: <tt>#set MATCH = $commonmembers( "a,b,c,d,e", "c,d,ee", "count" )</tt> (result: <tt>2</tt>) </dl> <p> <b>$homogenous( list )</b> <dl> <dt> <dd> Return 1 if all members of list are the same, 0 if there are any differences among members.<tt> </tt> If <i>list</i> has only 1 member, 1 is returned. If <i>list</i> is empty, 0 is returned.<tt> </tt> </dl> <p> <b>$makelist( s )</b> <dl> <dt> <dd> Convert <i>s</i>, a list of items separated by commas and/or whitespace, and return a commalist.<tt> </tt> Useful for building commalists from user input.<tt> </tt> <br> Example: <tt>#set LIST = $makelist( "1101 1102 1103" )</tt> (result: <tt>1101,1102,1103</tt>) <br> Example: <tt>#set LIST = $makelist( "1101, 1102, 1103" )</tt> (result: <tt>1101,1102,1103</tt>) <a name=shell></a> <br><br><br> </dl> <h2>SHELL COMMAND INTERFACE</h2> Functions related to the shell interface are described on the <a href="shell.html"> #shell manual page </a> .<tt> </tt> <a name=sql></a> <br><br><br> <h2>SQL DATABASE INTERFACE</h2> Functions related to SQL interface are described on the <a href="sql.html"> #sql manual page </a> .<tt> </tt> <a name=dates></a> <br><br><br> <h2>DATES</h2> <p> These functions work with <a href="dates.html"> dates in various notations.<tt> </tt> </a> <p> The default date format is <tt>mmddyy</tt>.<tt> </tt> Unless otherwise specified, these functions expect date arguments to be in the "current date format".<tt> </tt> <p> <b>$setdatefmt(format)</b> <dl> <dt> <dd> Set the current date format.<tt> </tt> <br> Example: <tt>#call $setdatefmt( "yyyymmdd" )</tt> </dl> <p> <b>$formatdate(date,newformat)</b> <dl> <dt> <dd> Return <i>date</i>, formatted to <i>newformat</i>.<tt> </tt> Use to convert dates to different notations, to extract year, month, day components, or to get weekday equivalent.<tt> </tt> Available formats are described <a href="dates.html"> here </a> <br> Example: <tt>#set RESULT = $formatdate( @D, "yyyymmmdd" )</tt> </dl> <p> <b>$datevalid(date)</b> <dl> <dt> <dd> Return 1 if <i>date</i> is a valid one in the current date format; return 0 if it is not.<tt> </tt> <br> Example: <tt>#if $datevalid(@apptdate) != 1</tt> </dl> <p> <b>$todaysdate()</b> <dl> <dt> <dd> Return the current date. It will be in the date format currently in effect.<tt> </tt> <br> Example: <tt>#set RESULT = $todaysdate()</tt> </dl> <p> <b>$daysdiff(date1,date2)</b> <dl> <dt> <dd> Return the difference in days between <i>date1</i> and <i>date2</i>.<tt> </tt> <br> Example: <tt>#set RESULT = $daysdiff( 011298, 010198 )</tt> (result: 11) </dl> <p> <b>$julian(date)</b> <dl> <dt> <dd> Return the julian (number of days since Jan 1, 1970) equivalent of <i>date</i>.<tt> </tt> <i>date</i> should be a date in current format, or the special symbol <tt>today</tt>.<tt> </tt> </dl> <p> <b>$jultodate(jul)</b> <dl> <dt> <dd> Return the date (in current format) that is equivalent to julian value <i>jul</i>.<tt> </tt> </dl> <p> <b>$dateadd(date,ndays)</b> <dl> <dt> <dd> Return the date resulting when <i>ndays</i> are added to <i>date</i>. <br> Example: <tt>#set RESULT = $dateadd( 010198, 11 )</tt> (result: 011298) </dl> <p> <b>$dategroup( interval, mode, input )</b> <dl> <dt> <dd> Take date, datetime, or time <i>input</i> value, and adjust it for grouping purposes. For example, after a set of dates are processed using <tt>$dategroup( week, mid, .. )</tt>, the result can be tabulated to get a weekly distribution. Allowable <i>interval</i> values are <tt>week month quarter year day hour</tt>.<tt> </tt> Allowable <i>mode</i> values are <tt>mid</tt> and <tt>first</tt>.<tt> </tt> First character is sufficient for these two args.<tt> </tt> </dl> <p> <b>$yearsold(birthdate,testdate)</b> <dl> <dt> <dd> Return the integer age in years as of <i>testdate</i> of a person born on <i>birthdate</i>.<tt> </tt> <br> Example: <tt>#set RESULT = $yearsold( 062661, 022098 )</tt> (result: 36) </dl> <p> <b>$setdateparms(parmname,value)</b> <dl> <dt> <dd> Set a date parameter. You can set the <b>pivotyear</b>, <b>strictdatelengths</b>, or <b>lazydates</b> attributes.<tt> </tt> See the <a href="config.html"> config file documentation </a> for descriptions of these parameters.<tt> </tt> <br> Example of setting the pivot year: <tt>#set STATUS = $setdateparms(Pivotyear,90)</tt> <br> Example of allowing lazy days: <tt>#set STATUS = $setdateparms(Lazydates,days)</tt> <br> Example of allowing lazy days and months: <tt>#set STATUS = $setdateparms(Lazydates,both)</tt> <a name=times></a> <br><br><br> </dl> <h2>TIMES</h2> These functions work with <a href="times.html"> time values </a> in various notations.<tt> </tt> <p> <b>$settimefmt(fmt)</b> <dl> <dt> <dd> Set the current time notation to <i>fmt</i>.<tt> </tt> Available notations are <tt>HH:MM:SS</tt>, <tt>HH:MM</tt>, and <tt>MM:SS</tt>.<tt> </tt> (A leading HH can handle single digit hour values; a leading MM can handle single digit minute values).<tt> </tt> <br> Example: <tt>#set RESULT = $settimefmt(MM:SS)</tt> These functions work with time values.<tt> </tt> </dl> <p> <b>$time()</b> <dl> <dt> <dd> Return the current time in <tt>hh:mm:ss</tt> format.<tt> </tt> <br> Example: <tt>#set RESULT = $time()</tt> </dl> <p> <b>$timevalid(time)</b> <dl> <dt> <dd> Return 1 if <i>time</i> is valid in the current time format; return 0 if it is not.<tt> </tt> <br> Example: <tt>#if $timevalid(@appttime) != 1</tt> </dl> <p> <b>$formattime(time,newformat)</b> <dl> <dt> <dd> Take <i>time</i>, which is in the current time format, and reformat it using <i>newformat</i>.<tt> </tt> <br> Example: <tt>#set t2 = $formattime( "14:22", "hh:mma" ) </tt></dl> <p> <b>$timesec()</b> <dl> <dt> <dd> Get number of seconds since midnight for the current time.<tt> </tt> <br> Example: <tt>#set RESULT = $timesec()</tt> </dl> <p> <b>$tomin(t)</b> <dl> <dt> <dd> Take <i>t</i> (a value in the current time notation) and return the equivalent, expressed in # of minutes since 0:00:00. Result is float, with any seconds expressed as the decimal portion of a minute. <br> Example: <tt>#set RESULT = $tomin( "3:45" )</tt> </dl> <p> <b>$frommin(m)</b> <dl> <dt> <dd> Inverse of $tomin(), where <i>m</i> is a float minutes value.<tt> </tt> Result is equivalent time in current notation.<tt> </tt> <br> Example: <tt>#set RESULT = $frommin( 3.75 )</tt> </dl> <p> <b>$timediff(t1,t2)</b> <dl> <dt> <dd> Find the difference between two times <i>t1</i> and <i>t2</i> (both in current notation). Result is expressed in float minutes (any seconds expressed as fraction of a minute) <br> Example: <tt>#set RESULT = $timediff( "3:43", "2:28" )</tt> <a name=checksums></a> <br><br><br> </dl> <h2>CHECKSUMS</h2> Checksum routines use an odd-even algorithm that takes an integer and computes a checksum digit 0 - 9 or x. This checksum digit may be used to guard against key errors and transposed digits.<tt> </tt> <p> <b>$checksumvalid(s)</b> <dl> <dt> <dd> Returns 1 if <i>s</i> is a valid number with checksum. 0 if not.<tt> </tt> <br> Example: <tt>#if $checksumgood(39) = 1</tt> (result: true) </dl> <p> <b>$checksumencode(i)</b> <dl> <dt> <dd> Result is integer <b>i</b> with a checksum digit appended.<tt> </tt> <br> Example: <tt>#set CHECKNUM = $checksumencode(29)</tt> (result: 294) </dl> <p> <b>$checksumnext(s)</b> <dl> <dt> <dd> Take <i>s</i> which is a number including trailing checksum digit, and increment the number and recompute new checksum digit. Result is returned.<tt> </tt> Example: <tt>#set RESULT = $checksumnext(39) = 1</tt> (result: 41) <a name=misc></a> <br><br><br> </dl> <h2>MISCELLANEOUS</h2> <p> <b>$getenv(varname)</b> <dl> <dt> <dd> Return the contents of environment variable <i>varname</i>.<tt> </tt> </dl> <p> <b>$whoami()</b> <dl> <dt><dd><p> Return a string containing <i>euid,egid</i>, where <i>euid</i> is the current effective user id, and <i>egid</i> is the current effective group id.<tt> </tt> </dl> <p> <b>$errormode( mode )</b> <dl> <dt> <dd> Control the display of error messages. Allowable values for <i>mode</i> are <tt>stderr</tt> and <tt>stdout</tt>. For command line applications the default is generally <tt>stderr</tt>; for CGI applications it is <tt>stdout</tt>, so that messages are visible. To hide error messages in CGI applications, set <i>mode</i> to <tt>stderr</tt>.<tt> </tt> </dl> <p> <b>$uniquename()</b> <dl> <dt> <dd> Return a short identifier generated using the current date, time to the current second, and process id. The name will be unique on a per-host basis.<tt> </tt> </dl> <p> <b>$tmpfilename(tag)</b> <dl> <dt> <dd> Generate a unique (on a per-host basis) temporary file name, suitable for use in shell commands. Uses <b>tmpdir</b> as specified in <a href="config.html"> project config file </a> . Format of the name is <i>tmpdir</i><tt>/</tt><i>tag</i><tt>.</tt><i>uniquename</i> where <i>uniquename</i> is a short name generated using the current date, current time to the second, and process id. <i>tag</i> may be passed as a zero length string if desired.<tt> </tt> </dl> <p> <b>$fileexists( dir, name )</b> <dl> <dt> <dd> Return 1 if the requested file can be opened, 0 otherwise.<tt> </tt> <i>dir</i> indicates the directory that <i>name</i> is relative to and may be one of <tt>/</tt>, <tt>scriptdir</tt>, <tt>tmpdir</tt>.<tt> </tt> <i>dir</i> may also be <tt>datadir</tt> if using shSQL.<tt> </tt> <br> Example: <tt>#set A = $fileexists( tmpdir, "mytmp" )</tt> </dl> <p> <b>$rename( pathname, newpathname )</b> <dl> <dt> <dd> Rename a file.<tt> </tt> </dl> <p> <b>$unlink( pathname )</b> <dl> <dt> <dd> Remove a file.<tt> </tt> </dl> <p> <b>$chmod( pathname, mode )</b> <dl> <dt> <dd> Do a chmod on pathname, setting it's file permissions to mode.<tt> </tt> Allowable modes are: 644, 664, 666, 444, 640, and 660.<tt> </tt> </dl> <p> <b>$cleanname( name )</b> <dl> <dt> <dd> Strip out any punctuation and control characters from <i>name</i>, leaving only letters, digits, and underscores.<tt> </tt> <br> Example: <tt>#set name = $cleanname( @name )</tt> </dl> <p> <b>$ref( varname ) </b> <dl> <dt> <dd> Return the contents of <i>varname</i>. May be useful when a variable contains the name of another variable, to extract the value of the other variable.<tt> </tt> Example: <br> <pre> #set A = "hello" #set B = "A" #set C = $ref(@B) </pre> <br> C would then contain <tt>hello</tt>.<tt> </tt> </dl> <p> <b>$def( varname ) </b> <dl> <dt> <dd> Return 1 if varname has been set to a value (even if the value is "").<tt> </tt> Return 0 otherwise.<tt> </tt> </dl> <p> <b>$isleep( n )</b> <dl> <dt> <dd> Delay for <i>n</i> seconds. </dl> <p> <b>$showvars(mode)</b> <dl> <dt> <dd> For debug purposes. Writes a list of every existing internal variable name to standard output, along with a count.<tt> </tt> If mode is given as "values" variable contents are also written.<tt> </tt> </dl> <p> <b>$fflush()</b> <dl> <dt> <dd> Flush standard output buffer. With <tt>quisp</tt> this can be used to immediately display all content available so far.<tt> </tt> <br> <br> </td></tr> <td align=right> <a href="../doc/welcome.html"> <img src="../doc/ploticus.gif" border=0></a><br><small>data display engine <br> <a href="../doc/Copyright.html">Copyright Steve Grubb</a> <br> <br> <center> <img src="../gallery/all.gif"> </center> </td></tr> </table> <br> <center> <table><tr><td> Ploticus is hosted at http://ploticus.sourceforge.net</td><td> </td><td> <a href="http://sourceforge.net/projects/ploticus"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=38453&type=12" width="120" height="30" border="0" alt="Get ploticus data display engine at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </td></tr></table> </center> </dl> <p><hr> Markup created by <em>unroff</em> 1.0, <tt> </tt> <tt> </tt>March 11, 2009. </body> </html>