1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
|
<html>
<head>
<!-- This file has been generated by unroff 1.0, 12/14/01 09:57:52. -->
<!-- Do not edit! -->
<STYLE TYPE="text/css">
<!--
A:link{text-decoration:none}
A:visited{text-decoration:none}
A:active{text-decoration:none}
-->
</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>
<a href="../doc/Welcome.html">Welcome</a>
<a href="../gallery/index.html">Gallery</a>
<a href="../doc/Contents.html">Handbook</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>
<br><br><br>
<h2>HOW TO USE FUNCTIONS</h2>
<p>
A number of functions are available for use in
<a href="scripts.html">
scripts
</a>
, for a wide range of purposes including processing of arithmetic, strings
dates, times,
, and so on.
Functions usually take one or more arguments and return a value.<tt> </tt>
Functions may be used with
<a href="set.html">
#set
</a>
,
<a href="call.html">
#call
</a>
, or as operands in
<a href="if.html">
#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><p>
<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>
<p>
<b>$inrange( value, axis )</b> or
<br>
<b>$inrange( value, axis, min, max )</b>
<dl>
<dt><dd><p>
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>
</dl>
<p>
<b>$icolor( i )</b>
<dl>
<dt><dd><p>
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 )
</tt></dl>
<p>
<b>$fieldname( n )</b>
<dl>
<dt><dd><p>
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>
</dl>
<p>
<b>$dataitem( row, field )
</b><dl>
<dt><dd><p>
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>
</dl>
<p>
<b>$data_to_absolute( axis, val )</b>
<dl>
<dt><dd><p>
Given a data location <i>va</i> in either X or Y space (specified by
<i>axis</i>), return the absolute location.<tt> </tt>
</dl>
<p>
<b>$nextstub( maxlen )</b>
<dl>
<dt><dd><p>
Returns the text of a defined category or pltab row stub.<tt> </tt>
Usually called multiple times within a loop; the result is used to build an expression to
select data rows. The first time it is called, the first category or row stub text will
be returned; second time, the second category or row stub text will be returned, and so on.<tt> </tt>
The length will be limited to <i>maxlen</i>. Any embedded spaces will be converted to underscores.<tt> </tt>
<dt><dd><p>
Example: <tt>#set S = $nextstub(5)</tt>
<dt><dd><p>
A gallery example where this is used is
<a href="../tabgallery/caselist.html">
caselist
</a>
</dl>
<p>
<b>$sleep( n )</b>
<dl>
<dt><dd><p>
Delay for <i>n</i> seconds.
Occasionally useful when viewing plots interactively.<tt> </tt>
</dl>
<p>
<b>$getclick()</b>
<dl>
<dt><dd><p>
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>
<a name=arithmetic></a>
<br><br><br>
</dl>
<h2>ARITHMETIC AND NUMBERS</h2>
<p>
<b>$arith(exp)</b>
<dl>
<dt><dd><p>
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>
<br>
Example: <tt>#set RESULT = $arith(2+8/5)</tt> (result: 2)
<br>
Example: <tt>#set RESULT = $arith(2+-8)</tt> (result: -6)
</dl>
<p>
<b>$arithl(exp)</b>
<dl>
<dt><dd><p>
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><p>
Returns 1 if <i>s</i> is a valid number, 0 if not.<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><p>
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><p>
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><p>
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><p>
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,val)</b>
<dl>
<dt><dd><p>
Mathematical functions on <i>val</i>.
<pre>
what returns
---- -------
abs absolute value (integer or floating point)
</pre>
<br>
Example: <tt>#set X = $math(abs,@X)</tt>
</dl>
<p>
<b>$random()</b>
<dl>
<dt><dd><p>
Returns a random number between 0.0 and 1.0.<tt> </tt>
<a name=strings></a>
<br><br><br>
</dl>
<h2>STRINGS</h2>
<p>
<b>$len(s)</b>
<dl>
<dt><dd><p>
Return the length of <i>s</i>.<tt> </tt>
</dl>
<p>
<b>$change(s1,s2,string)</b>
<dl>
<dt><dd><p>
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><p>
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><p>
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>
<br>
Example: <tt>$substring( "abcde", 3, 99 )</tt> would give <tt>cde</tt>
</dl>
<p>
<b>$changechars(clist,s,newchar)</b>
<dl>
<dt><dd><p>
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><p>
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>$contains(clist,s)</b>
<dl>
<dt><dd><p>
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>$fuzzymatch(s1,s2,degree)</b>
<dl>
<dt><dd><p>
Perform an approximate match of <i>s1</i> against <i>s2</i>.<tt> </tt>
A wildcard character '*' at the beginning or end of <i>s2</i> indicates
that a match can occur anywhere within <i>s1</i> (eg. smith* would match
smithington and *smith would match harrowsmith; *smith* would match
both). If there are no asterisks, lengths of the two strings must be similar.<tt> </tt>
<br>
<i>degree</i> changes the 'looseness' of the match.<tt> </tt>
5 = strict, 4 = medium-strict, 3 = medium 2= loose, 1 = very loose.<tt> </tt>
<br>
Returns 1 on a match, 0 not.<tt> </tt>
<br>
Example: <tt>#set STAT = $fuzzymatch(hello,hillo,3)</tt> (result: <tt>1</tt>)
<br>
Example: <tt>#set STAT = $fuzzymatch(hello,hillo,5)</tt> (result: <tt>0</tt>)
</dl>
<p>
<b>$lowerc(string)</b>
<dl>
<dt><dd><p>
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><p>
Return the upper-case equivalent of <i>string</i>
<br>
Example: <tt>#set RESULT = $upperc(Hello)</tt> (result: <tt>HELLO</tt>)
</dl>
<p>
<b>$strcat(s,t)</b>
<dl>
<dt><dd><p>
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 )</b>
<dl>
<dt><dd><p>
return the <i>n</i>th whitespace-delimited token in <i>s</i>.<tt> </tt>
</dl>
<p>
<b>$extractnum( s )</b>
<dl>
<dt><dd><p>
extract the first numeric entity embedded anywhere in <i>s</i> and return it.<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><p>
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>#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><p>
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>$nmember(n,list)</b>
<dl>
<dt><dd><p>
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><p>
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><p>
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><p>
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
</a>
. Some date-related parameters may be set in the
<a href="config.html">
project config file
</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><p>
Set the current date format.<tt> </tt>
<br>
Example: <tt>#call $setdatefmt( "yyyymmdd" )</tt>
</dl>
<p>
<b>$formatdate(date,newformat)</b>
<dl>
<dt><dd><p>
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><p>
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><p>
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><p>
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><p>
Return the julian (number of days since Jan 1, 1977) 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><p>
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><p>
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><p>
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><p>
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><p>
Set a date parameter. See
<a href="config.html">
config file documentation
</a>
for descriptions of these parameters, including
strictness of date format checking,
the century pivot year, and lazy dates.<tt> </tt>
<br>
A pivot year is used to accomodate two-digit year values.<tt> </tt>
<br>
A lazy date has 00 as the day and/or month portion and is usually
used in situations where the day and/or month is unknown or unavailable.<tt> </tt>
<br>
Strictness of date format checking: by default the length of a presented date must be
consistent with the format specification. For example, an mm/dd/yy date must be
8 or 10 characters long; other lengths result in an error.<tt> </tt>
This strictness may be relaxed by doing: <tt>#set STATUS = $setdateparms(Strictdatelengths,no)</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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
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><p>
Return the contents of environment variable <i>varname</i>.<tt> </tt>
</dl>
<p>
<b>$uniquename()</b>
<dl>
<dt><dd><p>
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><p>
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><p>
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>datadir</tt>, <tt>tmpdir</tt>.<tt> </tt>
<br>
Example: <tt>#set A = $fileexists( tmpdir, "mytmp" )</tt>
</dl>
<p>
<b>$ref( varname ) </b>
<dl>
<dt><dd><p>
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><p>
Return 1 if varname has been set to a value.<tt> </tt>
Return 0 otherwise.<tt> </tt>
<br>
<br>
</td></tr>
<td align=right>
<a href="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>
</dl>
<p><hr>
Markup created by <em>unroff</em> 1.0, <tt> </tt> <tt> </tt>December 14, 2001.
</body>
</html>
|