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 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
|
.ig >>
<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.33 Jun'06
</small><br><a href="../doc/scripthome.html">Scripts</a>
<td></tr></table>
</td></tr>
<td>
<br>
<br>
.>>
.TH functions PL "02-JUN-2006 PL ploticus.sourceforge.net"
.LP
Categories of available functions:
.LP
.ig >>
<a href="functions.html#ploticus">
.>>
\0plotting
.ig >>
</a>
.>>
.br
.ig >>
<a href="functions.html#arithmetic">
.>>
\0arithmetic
.ig >>
</a>
.>>
.br
.ig >>
<a href="functions.html#strings">
.>>
\0strings
.ig >>
</a>
.>>
.br
.ig >>
<a href="functions.html#commalists">
.>>
\0commalists
.ig >>
</a>
.>>
.br
.ig >>
<a href="shell.html">
.>>
\0shell
.ig >>
</a>
.>>
.br
.ig >>
<a href="sql.html">
.>>
\0sql
.ig >>
</a>
.>>
.br
.ig >>
<a href="functions.html#dates">
.>>
\0dates
.ig >>
</a>
.>>
.br
.ig >>
<a href="functions.html#times">
.>>
\0times
.ig >>
</a>
.>>
.br
.ig >>
<a href="functions.html#misc">
.>>
\0misc
.ig >>
</a>
.>>
.ig >>
<br><br><br>
.>>
.SH HOW TO USE FUNCTIONS
.LP
A number of functions are available for use in
.ig >>
<a href="scripts.html">
.>>
\0ploticus scripts
.ig >>
</a>
.>>
and
.ig >>
<a href="getdata.html">
.>>
\0proc getdata filters
.ig >>
</a>
.>>
, for a wide range of purposes including processing of arithmetic, strings
dates, times,
.ig >>
<a href="commalist.html">
.>>
\0commalists
.ig >>
</a>
.>>
, and so on.
Functions usually take one or more arguments and return a value.
Functions may be used with
.ig >>
<a href="scriptsyntax.html#set">
.>>
\0#set
.ig >>
</a>
.>>
,
.ig >>
<a href="scriptsyntax.html#call">
.>>
\0#call
.ig >>
</a>
.>>
or as operands in
.ig >>
<a href="scriptsyntax.html#if">
.>>
\0#if/#elseif
.ig >>
</a>
.>>
.ig >>
<a href="condex.html">
.>>
\0conditional expressions
.ig >>
</a>
.>>
\0.
.LP
Custom functions may be coded and added to the file \fCcustom.c\fR,
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.
.ig >>
<br><br><br>
.>>
.SH FUNCTION SYNTAX
Function names always start with a dollar sign (\fB$\fR).
Function arguments are enclosed by parentheses and if more than one
argument, separated by commas (,). For example:
.IP \0
\fC$formatfloat( @NUM, "%7.2f" )\fR
.LP
Function calls may not be nested, ie. function arguments may not be functions.
.ig >>
<br><br><br>
.>>
.LP
In the following summaries, the function name appears along with a
template for arguments that must be supplied.
.ig >>
<br><br><br>
.>>
.ig >>
<a name=ploticus></a>
.>>
.SH PLOTTING
Note: the functions in this section may be used with a double dollar sign ($$)
for faster function name search.
Because of the way ploticus script files are parsed,
\fC#endproc\fR should be used to terminate any #proc previous to these function calls,
so that the proc executes before the function call.
.LP
\fB$inrange( value, axis )\fR or
.br
\fB$inrange( value, axis, min, max )\fR
.IP \0
Return 1 if \fIvalue\fR within a range on the given \fIaxis\fR.
\fImin\fR and \fImax\fR are optional; if given they determine the range.
If they are not given the range is the range of the axis within the
plotting area.
.ig >>
<br><br>
.>>
.LP
\fB$icolor( i )\fR
.IP \0
Return one of 20 preselected colors. The color sequence was
selected to give good contrast between nearby entries.
\fIi\fR allowable range is 1 to 20; values out of this range
are modulo into range.
.br
Example: \fC#set COLOR = $icolor( 2 )
.ig >>
<br><br>
.>>
.LP
\fB$fieldname( n )\fR
.IP \0
Return the field name assigned to field \fIn\fR. First is 1.
If no field name was defined, \fCnoname\fR is returned.
.ig >>
<br><br>
.>>
.LP
\fB$dataitem( row, field )\fR
.IP \0
Return the contents of the item in \fIrow\fR and \fIfield\fR of
the current data set. \fIrow\fR is a number, first is 1.
\fIfield\fR is either a number or an assigned name.
.ig >>
<br><br>
.>>
.LP
\fB$defaultinc( min, max )\fR
.IP \0
Return a reasonable increment given numeric \fImin\fR and \fImax\fR,
using the same algorithm used with axis stub increments.
.br
Example: \fC#set inc = $defaultinc( 0, 200 )\fR
.ig >>
<br><br>
.>>
.LP
\fB$squelch_display( mode )\fR
.IP \0
\0 #call $squelch_display( 1 ) .. will squelch all drawing activity.
.br
\0 #call $squelch_display( 0 ) .. will resume drawing activity.
.br
Note that \fC#endproc\fR must terminate any #proc previous to these function calls. (version 2.30+)
.ig >>
<br><br>
.>>
.LP
\fB$bounding_box( mode )\fR
.IP \0
\0 #call $boundingbox( 0 ) .. subsequent drawing does not influence the bounding box and hence the crop
.br
\0 #call $boundingbox( 1 ) .. restore to normal mode of operation.
.br
Note that \fC#endproc\fR must terminate any #proc previous to these function calls. (version 2.30+)
.ig >>
<br><br>
.>>
.LP
\fB$data_to_absolute( axis, val )\fR
.IP \0
Given a data location \fIva\fR in either X or Y space (specified by
\fIaxis\fR), return the absolute location.
.ig >>
<br><br>
.>>
.LP
\fB$sleep( n )\fR
.IP \0
Delay for \fIn\fR seconds.
Occasionally useful when viewing plots interactively.
.ig >>
<br><br>
.>>
.LP
\fB$getclick()\fR
.IP \0
Produce a "More.." button and wait for user to click on it.
Upon the click, return.
Occasionally useful when viewing plots interactively.
.ig >>
<br><br>
.>>
.LP
\fB$errmsgpre( tag )\fR
.IP \0
Allows developer to set the first portion of all ploticus error messages to \fCtag\fR
(it will stay in effect until explicitly set again).
For example, where a web page generates multiple plots it may be useful in identifying
which plot had the error.
.ig >>
<br><br>
.>>
.LP
\fB$textwidth( text, font, size)\fR
.IP \0
Return horizontal width of freetype bounding box.
Useful only with freetype fonts, otherwise it returns 0. Suggested/contributed by Erik Zachte.
.ig >>
<br><br>
.>>
.LP
\fB$rewritenums( f )\fR
.IP \0
takes a numeric quantity \fIf\fR and
returns it rewritten for display purposes, applying
numbernotation (as specified in your proc settings or config file).
.ig >>
<br><br>
.>>
.ig >>
<a name=arithmetic></a>
.>>
.ig >>
<br><br><br>
.>>
.SH ARITHMETIC AND NUMBERS
.LP
\fB$arith( exp, format )\fP
.IP \0
Simplistic arithmetic expression evaluator.
\fIexp\fR is an expression made up of numbers and the arithmetic operators
\fC+ - * /\fR.
No embedded spaces nor parentheses are allowed within the expression.
Evaluation is strictly left to right.
Unary plus/minus are allowed.
In versions 2.30+ scientific notation eg. \fC3.74e-07\fR is supported.
\fIformat\fR is an optional printf(3) display format specifier controlling
the format of the result,
eg. \fC%.0f\fR. Default format is \fC%g\fR, which should suffice for all but very
large or very small values. For more on format specifiers see your manual page on printf(3).
.br
Example: \fC#set RESULT = $arith(2+8/5)\fP (result: 2)
.br
Example: \fC#set RESULT = $arith(2+-8)\fP (result: -6)
.br
Example: \fC#set RESULT = $arith( 18*1000000000 , "%.f" )
.br
Example: \fC#set RESULT = $arith( 18*.0000001 , "%.9f" )
.LP
\fB$arithl(exp)\fP
.IP \0
Same as \fB$arith()\fP except
lazy, i.e. non-numeric operands
are accepted and treated as if they were 0.
.LP
\fB$isnumber(s)\fP
.IP \0
Returns 1 if \fIs\fP is a valid number, 0 if not.
In versions 2.30+ scientific notation is supported.
.br
Example: \fC#set RESULT = $isnumber(-0.24)\fR (result: 1)
.br
Example: \fC#set RESULT = $isnumber(=)\fR (result: 0)
.LP
\fB$formatfloat(x,fmt)\fR
.IP \0
Format \fIx\fR using printf-style format string \fIfmt\fR.
May also be used to format integers by using a \fIfmt\fR such as \fC%03.0f\fR.
.br
Example: \fC#set RESULT = $formatfloat( 3.4425, "%3.2f" )\fR (result: 3.44)
.LP
\fB$inr(n,lo,hi)\fR
.IP \0
See if \fIn\fR is within the numeric range of \fIlo\fR
to \fIhi\fR. Returns 1 if so, 0 if not. Non-numeric \fIn\fR always returns 0.
.LP
\fB$numgroup( val, h, mode )\fR
.IP \0
Convert \fIval\fR to a nearby multiple of \fIh\fR.
Useful in grouping a set of numbers into bins.
\fImode\fR may be either \fClow\fR, \fCmid\fR, or \fChigh\fR.
For example, if f is 73 and h is 10, function returns 70, 75, or 80 for modes
\fClow\fR, \fCmid\fR, \fChigh\fR respectively.
.LP
\fB$autoround(val,d)\fR
.IP \0
Round \fIval\fR to a reasonable precision.
Use a value of 0 for \fId\fR for normal behavior. Increase \fId\fR to
get more precision, reduce \fId\fR to get less precision.
.br
Example: \fC#set X = $autoround( @X, 0 )\fR
.LP
\fB$math(what,a,b)\fR
.IP \0
Various mathematical functions. \fIa\fR and \fIb\fR can be integer or floating point
unless otherwise noted below.
.nf
what returns
---- -------
abs absolute value of \fIa\fR
mod \fIa\fR modulo \fIb\fR
div integer division \fIa\fR / \fIb\fR (\fIa\fR and \fIb\fR must be integers)
pow \fIa\fR raised to \fIb\fR
mag \fIa\fR multiplied by 10 to the \fIb\fR
log+1 the natural log of \fIa\fR, plus 1.0
exp-1 the exponential of \fIa\fR, minus 1.0
sqrt the square root of \fIa\fR
.fi
.br
Example: \fC#set X = $math(abs,-57)\fR would return \fC57\fR.
.br
Example: \fC#set X = $math(mod,10,6)\fR would return \fC4\fR.
.LP
\fB$random()\fR
.IP \0
Returns a random number between 0.0 and 1.0.
.LP
\fB$ranger( rangespec )\fR
.IP
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.
Example:
.br
\fC
\0 #set RANGE = "5,8,11-15"
.br
\0 #set LIST = $ranger( @RANGE )
\fR
.br
LIST would then contain \fC 5,8,11,12,13,14,15 \fR
.ig >>
<a name=strings></a>
.>>
.ig >>
<br><br><br>
.>>
.SH STRINGS
.LP
\fB$len(s)\fR
.IP \0
Return the length of \fIs\fR.
.LP
\fB$change(s1,s2,string)\fR
.IP \0
Change all occurances of \fIs1\fR to \fIs2\fR in string.
.br
Example: \fC#set T = $change( "<", "<sup>", @T )\fR
.LP
\fB$expand( s )\fR
.IP \0
Expand all @variables present in \fIs\fR.
Example:
.nf
\0#set B = "@A world"
\0#set A = hello
\0#set C = $expand( @B )
.fi
Variable C would then contain \fChello world\fR.
.LP
\fB$substring(s,n,len)\fR
.IP \0
Return a substring of \fIs\fR. Substring begins at character \fIn\fR (first is 1)
for a maximum length of \fIlen\fR.
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 \fIn\fR (see 2nd example below).
.br
Example: \fC$substring( "abcde", 3, 99 )\fR would give \fCcde\fR
.br
Example: \fC$substring( "abcde", -2, 99 )\fR would give \fCde\fR
.LP
\fB$changechars(clist,s,newchar)\fR
.IP \0
If string \fIs\fR contains any of chars in \fIclist\fR, change that
character to \fInewchar\fR.
\fBclist\fR may be passed as the word \fCcomma\fR to represent a comma (,).
.br
Example: \fC#set RESULT = $changechars("*'", @S, "_" )\fR
.LP
\fB$deletechars(clist,s)\fR
.IP \0
If string \fIs\fR contains any of chars in \fIclist\fR, delete that character.
.br
Example: \fC#set RESULT = $deletechars("*'",@S)\fR
.LP
\fB$stripws( s, mode )\fR
.IP \0
Remove whitespace characters from \fIs\fR.
If mode is "any", all whitespace characters are removed.
Otherwise only leading and trailing whitespace is stripped off.
.LP
\fB$contains(clist,s)\fR
.IP \0
If string \fIs\fR contains any of chars in \fIclist\fR, return position
(first=1) of the first occurance. Return 0 if none found.
\fIclist\fR may be passed as the word \fCcomma\fR to represent a comma (,).
.br
Example: \fC#set RESULT = $contains( "*'", @S )\fR
.br
Example: \fC#set RESULT = $contains( ",", @S )\fR
.LP
\fB$lowerc(string)\fP
.IP \0
Return the lower-case equivalent of \fIstring\fP.
.br
Example: \fC#set RESULT = $lowerc(HELLO)\fP (result: \fChello\fP)
.LP
\fB$upperc(string)\fP
.IP \0
Return the upper-case equivalent of \fIstring\fP
.br
Example: \fC#set RESULT = $upperc(Hello)\fP (result: \fCHELLO\fP)
.LP
\fB$strcmp(s,t)\fP
.IP \0
Return an integer representation of the difference in magnitude of \fIs\fP and \fIt\fP,
using ascii order.
.br
Note: don't use this for #if statement equality comparisons; simple \fC=\fR and \fC!=\fR should
be used instead.
.br
Example: \fC#set RESULT = $strcmp(ABC,XY)\fP (result will be a negative integer)
.br
Example: \fC#set RESULT = $strcmp(XY,ABC)\fP (result will be a positive integer)
.LP
\fB$strcat(s,t)\fP
.IP \0
Return the concatenatation of strings \fIs\fP and \fIt\fP
.br
Example: \fC#set RESULT = $strcat(ABC,XY)\fP (result: \fCABCXY\fP)
.LP
\fB$ntoken( n, s )\fR
.IP \0
Return the \fIn\fRth whitespace-delimited token in \fIs\fR.
.LP
\fB$extractnum( s )\fR
.IP \0
Extract the first numeric entity embedded anywhere in \fIs\fR and return it.
.LP
\fB$wildcmp( s1, s2 )\fR
.IP \0
Return the result of a wildcard-enabled match s1 vs. s2. s2 can contain wild cards.
Return value is 0 on a match, -1 if s1 is "less than" s2, and 1 if s1 is "greater than" s2.
.ig >>
<a name=commalists></a>
.>>
.ig >>
<br><br><br>
.>>
.SH COMMALISTS
These functions operate on a string which is in the form of a
.ig >>
<a href="commalist.html">
.>>
\0commalist
.ig >>
</a>
.>>
\0.
.LP
\fB$count(str,list)\fP
.IP \0
Count the number of times \fIstr\fP appears in
\fIlist\fP. If \fIstr\fR is passed as \fC*\fR then this function
will count the number of members in the list.
.br
Example: \fC#if $count( "*", "a,b,c" ) = 3\fR (true)
.br
Example: \fC#set RESULT = $count( "hello", "aba,gabba,jabba" )\fP (result: 0)
.br
Example: \fC#set RESULT = $count( "x", "x,y,x,y,y,z,x" )\fP (result: 3)
.LP
\fB$addmember(newmem,list)\fP
.IP \0
Append a new member \fInewmem\fR to end of \fIlist\fR.
If \fIlist\fR is empty before call, result will have one member.
.br
Example: \fC#set RESULT = $addmember( "red", @MYLIST )\fR
.LP
\fB$deletemember(mem,list)\fP
.IP \0
Remove a member \fImem\fR from \fIlist\fR.
.br
Example: \fC#set RESULT = $deletemember( "red", @MYLIST )\fR
.LP
\fB$nmember(n,list)\fP
.IP \0
Get the \fIn\fPth member of \fIlist\fP.
.br
Example: \fC#set RESULT = $nmember( 2, "a,b,c,d,e" )\fP (result: \fCb\fB)
.LP
\fB$commonmembers( list1, list2, mode )
.IP \0
Detect if \fIlist1\fR and \fIlist2\fR have any members in common.
Returns 0 if no members in common.
If \fImode\fR is \fC"count"\fR, 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).
Otherwise, when a match is found 1 is returned immediately.
.br
Example: \fC#set MATCH = $commonmembers( "a,b,c,d,e", "c,d,ee", "count" )\fR (result: \fC2\fR)
.LP
\fB$homogenous( list )\fR
.IP \0
Return 1 if all members of list are the same, 0 if there are any differences
among members.
If \fIlist\fR has only 1 member, 1 is returned.
If \fIlist\fR is empty, 0 is returned.
.LP
\fB$makelist( s )\fR
.IP \0
Convert \fIs\fR, a list of items separated by commas and/or whitespace,
and return a commalist.
Useful for building commalists from user input.
.br
Example: \fC#set LIST = $makelist( "1101 1102 1103" )\fR (result: \fC1101,1102,1103\fR)
.br
Example: \fC#set LIST = $makelist( "1101, 1102, 1103" )\fR (result: \fC1101,1102,1103\fR)
.ig >>
<a name=shell></a>
.>>
.ig >>
<br><br><br>
.>>
.SH SHELL COMMAND INTERFACE
Functions related to the shell interface are described on the
.ig >>
<a href="shell.html">
.>>
\0#shell manual page
.ig >>
</a>
.>>
\0.
.ig >>
<a name=sql></a>
.>>
.ig >>
<br><br><br>
.>>
.SH SQL DATABASE INTERFACE
Functions related to SQL interface are described on the
.ig >>
<a href="sql.html">
.>>
\0#sql manual page
.ig >>
</a>
.>>
\0.
.ig >>
<a name=dates></a>
.>>
.ig >>
<br><br><br>
.>>
.SH DATES
.LP
These functions work with
.ig >>
<a href="dates.html">
.>>
\0dates in various notations.
.ig >>
</a>
.>>
.LP
The default date format is \fCmmddyy\fR.
Unless otherwise specified, these functions expect date arguments
to be in the "current date format".
.LP
\fB$setdatefmt(format)\fR
.IP \0
Set the current date format.
.br
Example: \fC#call $setdatefmt( "yyyymmdd" )\fR
.LP
\fB$formatdate(date,newformat)\fR
.IP \0
Return \fIdate\fR, formatted to \fInewformat\fR.
Use to convert dates to different notations, to extract year, month, day
components, or to get weekday equivalent.
Available formats are described
.ig >>
<a href="dates.html">
.>>
\0here
.ig >>
</a>
.>>
.br
Example: \fC#set RESULT = $formatdate( @D, "yyyymmmdd" )\fR
.LP
\fB$datevalid(date)\fR
.IP \0
Return 1 if \fIdate\fR is a valid one in the current date format;
return 0 if it is not.
.br
Example: \fC#if $datevalid(@apptdate) != 1\fR
.LP
\fB$todaysdate()\fR
.IP \0
Return the current date. It will be in the date format currently in effect.
.br
Example: \fC#set RESULT = $todaysdate()\fR
.LP
\fB$daysdiff(date1,date2)\fR
.IP \0
Return the difference in days between \fIdate1\fR and \fIdate2\fR.
.br
Example: \fC#set RESULT = $daysdiff( 011298, 010198 )\fR (result: 11)
.LP
\fB$julian(date)\fR
.IP \0
Return the julian (number of days since Jan 1, 1970) equivalent of \fIdate\fR.
\fIdate\fR should be a date in current format, or the special symbol \fCtoday\fR.
.LP
\fB$jultodate(jul)\fR
.IP \0
Return the date (in current format) that is equivalent to julian value \fIjul\fR.
.LP
\fB$dateadd(date,ndays)\fR
.IP \0
Return the date resulting when \fIndays\fR are added to \fIdate\fR.
.br
Example: \fC#set RESULT = $dateadd( 010198, 11 )\fR (result: 011298)
.LP
\fB$dategroup( interval, mode, input )\fR
.IP \0
Take date, datetime, or time \fIinput\fR value, and adjust it for
grouping purposes. For example, after a set of dates
are processed using \fC$dategroup( week, mid, .. )\fR, the result can be tabulated to
get a weekly distribution.
Allowable \fIinterval\fR values are \fCweek month quarter year day hour\fR.
Allowable \fImode\fR values are \fCmid\fR and \fCfirst\fR.
First character is sufficient for these two args.
.LP
\fB$yearsold(birthdate,testdate)\fR
.IP \0
Return the integer age in years as of
\fItestdate\fR of a person born on \fIbirthdate\fR.
.br
Example: \fC#set RESULT = $yearsold( 062661, 022098 )\fR (result: 36)
.LP
\fB$setdateparms(parmname,value)\fR
.IP \0
Set a date parameter.
You can set the
\fBpivotyear\fR, \fBstrictdatelengths\fR, or \fBlazydates\fR attributes.
See the
.ig >>
<a href="config.html">
.>>
\0config file documentation
.ig >>
</a>
.>>
for descriptions of these parameters.
.br
Example of setting the pivot year: \fC#set STATUS = $setdateparms(Pivotyear,90)\fR
.br
Example of allowing lazy days: \fC#set STATUS = $setdateparms(Lazydates,days)\fR
.br
Example of allowing lazy days and months: \fC#set STATUS = $setdateparms(Lazydates,both)\fR
.ig >>
<a name=times></a>
.>>
.ig >>
<br><br><br>
.>>
.SH TIMES
These functions work with
.ig >>
<a href="times.html">
.>>
\0time values
.ig >>
</a>
.>>
in various notations.
.LP
\fB$settimefmt(fmt)\fR
.IP \0
Set the current time notation to \fIfmt\fR.
Available notations are \fCHH:MM:SS\fR, \fCHH:MM\fR, and \fCMM:SS\fR.
(A leading HH can handle single digit hour values; a leading MM
can handle single digit minute values).
.br
Example: \fC#set RESULT = $settimefmt(MM:SS)\fR
These functions work with time values.
.LP
\fB$time()\fP
.IP \0
Return the current time in \fChh:mm:ss\fR format.
.br
Example: \fC#set RESULT = $time()\fP
.LP
\fB$timevalid(time)\fR
.IP \0
Return 1 if \fItime\fR is valid in the current time format;
return 0 if it is not.
.br
Example: \fC#if $timevalid(@appttime) != 1\fR
.LP
\fB$formattime(time,newformat)\fR
.IP \0
Take \fItime\fR, which is in the current time format,
and reformat it using \fInewformat\fR.
.br
Example: \fC#set t2 = $formattime( "14:22", "hh:mma" )
.LP
\fB$timesec()\fP
.IP \0
Get number of seconds since midnight for the current time.
.br
Example: \fC#set RESULT = $timesec()\fP
.LP
\fB$tomin(t)\fR
.IP \0
Take \fIt\fR (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: \fC#set RESULT = $tomin( "3:45" )\fR
.LP
\fB$frommin(m)\fR
.IP \0
Inverse of $tomin(), where \fIm\fR is a float minutes value.
Result is equivalent time in current notation.
.br
Example: \fC#set RESULT = $frommin( 3.75 )\fR
.LP
\fB$timediff(t1,t2)\fR
.IP \0
Find the difference between two times
\fIt1\fR and \fIt2\fR (both in current notation). Result is expressed
in float minutes (any seconds expressed as fraction of a minute)
.br
Example: \fC#set RESULT = $timediff( "3:43", "2:28" )\fR
.ig >>
<a name=checksums></a>
.>>
.ig >>
<br><br><br>
.>>
.SH CHECKSUMS
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.
.LP
\fB$checksumvalid(s)\fP
.IP \0
Returns 1 if \fIs\fR is a valid
number with checksum. 0 if not.
.br
Example: \fC#if $checksumgood(39) = 1\fR (result: true)
.LP
\fB$checksumencode(i)\fR
.IP \0
Result is integer \fBi\fR with
a checksum digit appended.
.br
Example: \fC#set CHECKNUM = $checksumencode(29)\fR (result: 294)
.LP
\fB$checksumnext(s)\fR
.IP \0
Take \fIs\fR which is a number
including trailing checksum digit, and increment the number and
recompute new checksum digit. Result is returned.
Example: \fC#set RESULT = $checksumnext(39) = 1\fR (result: 41)
.ig >>
<a name=misc></a>
.>>
.ig >>
<br><br><br>
.>>
.SH MISCELLANEOUS
.LP
\fB$getenv(varname)\fR
.IP \0
Return the contents of environment variable \fIvarname\fR.
.LP
\fB$whoami()\fR
.IP
Return a string containing \fIeuid,egid\fR, where \fIeuid\fR is the
current effective user id, and \fIegid\fR is the current effective group id.
.LP
\fB$errormode( mode )\fR
.IP \0
Control the display of error messages. Allowable values for \fImode\fR are
\fCstderr\fR and \fCstdout\fR. For command line applications the default is
generally \fCstderr\fR; for CGI applications it is \fCstdout\fR, so that messages
are visible. To hide error messages in CGI applications, set \fImode\fR to \fCstderr\fR.
.LP
\fB$uniquename()\fR
.IP \0
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.
.LP
\fB$tmpfilename(tag)\fR
.IP \0
Generate a unique (on a per-host basis) temporary file name, suitable
for use in shell commands. Uses \fBtmpdir\fR as specified in
.ig >>
<a href="config.html">
.>>
\0project config file
.ig >>
</a>
.>>
\0. Format of the name is \fItmpdir\fC/\fItag\fC.\fIuniquename\fR where
\fIuniquename\fR is a short name generated using the current date, current time
to the second, and process id. \fItag\fR may be passed as a zero length string
if desired.
.LP
\fB$fileexists( dir, name )\fR
.IP \0
Return 1 if the requested file can be opened, 0 otherwise.
\fIdir\fR indicates the directory that \fIname\fR is relative to
and may be one of \fC/\fR, \fCscriptdir\fR, \fCtmpdir\fR.
\fIdir\fR may also be \fCdatadir\fR if using shSQL.
.br
Example: \fC#set A = $fileexists( tmpdir, "mytmp" )\fR
.LP
\fB$cleanname( name )\fR
.IP \0
Strip out any punctuation and control characters
from \fIname\fR, leaving only letters, digits, and underscores.
.br
Example: \fC#set name = $cleanname( @name )\fR
.LP
\fB$ref( varname ) \fR
.IP \0
Return the contents of \fIvarname\fR. May be useful when a variable contains
the name of another variable, to extract the value of the other variable.
Example:
.br
.nf
\0 #set A = "hello"
\0 #set B = "A"
\0 #set C = $ref(@B)
.fi
.br
C would then contain \fChello\fR.
.LP
\fB$def( varname ) \fR
.IP \0
Return 1 if varname has been set to a value (even if the value is "").
Return 0 otherwise.
.LP
\fB$isleep( n )\fR
.IP \0
Delay for \fIn\fR seconds.
.LP
\fB$fflush()\fR
.IP \0
Flush standard output buffer. With \fCquisp\fR this can be used to immediately display
all content available so far.
.ig >>
<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>
Ploticus is hosted at http://ploticus.sourceforge.net <br>
<img src="http://sourceforge.net/sflogo.php?group_id=38453" width="88" height="31" border="0" alt="SourceForge Logo">
</center>
.>>
|