[math] calculates equations using numbers, dates or time. It can also set variables to be used throughout the page. One common use of a math variable is to create counters.
[math ResultType]Equation[/math]the name of a math variable is limited to 15 alphanumeric characters, and must begin with a letter.
You can assign multiple math variables at the same time using a semicolon to separate the assignments.
Example: [math show=f]var1=1;var2=2[/math].
[lineitems]
[quantity], [ref], [price], [math][price]*[quantity][/math]
[/lineitems]
[math show=f]counter=0[/math]
[founditems]
[hideif [somecondition]=something]
[math]counter=counter 1[/math]. [firstname] [lastname]<br>
[/hideif]
[/founditems]
There were [counter] names found.
sometimes you want to calculate something without displaying the results, perhaps while calculating a running total. To do this, put "show=F" into the math parameters, as in [Math show=F]total=total [subTotal][/Math]. This allows you to perform calculations in the middle of a web page without the intermediate numbers appearing to the visitor. Later, you can show the value of the math variable with [math]total[/Math].
[math](4.5 6.2)/17*95-12[/math] | 47.7941176470588 |
[math]{4/7/1997} + 10[/math] | 729496 (4/7/1997 + 10 days expressed as number of days since 00/00/0000) |
[math]{4/7/1997} + {02/00/0000}[/math] | 729547 (4/7/1997 + 2 months expressed as days since 00/00/0000) |
[math date]{4/7/1997} + 10[/math] | 04/17/1997 (4/07/1997 + 10 days expressed as date) |
[math date]{4/7/1997} + {02/00/0000}[/math] | 06/07/1997 (4/17/1997 + 2 months expressed as date) |
[math date]{[date]}-{00/07/0000}[/math] | 09/01/2008 (One week ago today) |
[math]{12:51:02}[/math] | 46262 (number of seconds between midnight and 12:51:02 expressed as seconds) |
[math time]{12:51:02} + {01:00:05}[/math] | 13:51:07 (12:51:02 pm plus 1 hour and 5 seconds expressed as time) |
[math]x=5/3[/math] | 1.66666666666667 |
[math]x=5%3[/Math](% = Modulo Operator) | 2 |
<SELECT NAME="StartYear">
[loop start=[date %Y]&end=[math][date %Y] + 10[/math]]
<OPTION[showif [date %Y]=[index]] selected[/showif]>[index]</option>
[/loop]
</SELECT>
[math]ceil(1.5)[/math]
[math]sin([formvalue])*cos(3.1415)[/math]
Function | Description |
---|---|
sin(x) | returns sine of x. |
cos(x) | returns cosine of x. |
tan(x) | returns tangent of x. |
asin(x) | returns arcsine of x. |
acos(x) | returns arccosine of x. |
atan(x) | returns arctangent of x. |
sinh(x) | returns hyperbolic sine of x. |
cosh(x) | returns hyperbolic cosine of x. |
tanh(x) | returns hyperbolic tangent of x. |
log(x) | return natural log of x. |
log10(x) | returns log base 10 of x. |
sqrt(x) | returns square root of x sqrt(16) = 4. |
floor(x) | rounds down to next-lower integer. floor(2.9) = 2. |
ceil(x) | rounds up to next-higher integer. ceil(3.1) = 4. |
abs(x) | returns absolute value of x. abs(-3.4) = 3.4. |
deg(x) | converts radians to degrees. |
rad(x) | converts degrees to radians. |
you may use [format] to convert an integer number to a date or time. Use [Format Days_To_Date] and [Format Seconds_To_Time] to convert integer numbers to their equivalent dates/times. As already noted above, the integer number represents the number of days since January 1, 0000 and for time, the number of seconds since midnight.
[math] variable names allow 15 characters. There is no such limit for [text] variable names
Terry WilsonDOWNLOAD WEBDNA NOW!
Amazon Web Services (AWS) README for Machine Image ID...
WebDNA ModulesA list of the currently available modules...
Download WebDNA ApplicationsWebDNA applications...
F.A.QA compilation of some user's questions...
Tips and TricksA list of user-submitted tips ...
Technical Change HistoryThis Technical Change History provides a reverse chronological list of WebDNA changes...
Displays the contents of a shopping cart...
[session][session] is a new WebDNA feature that recognises a browser through its "fingerprint"...
[spawn]Creates a new thread to execute WebDNA simultaneously with the current template...
[tcpsend]A powerful feature that sends text to a TCP server program on a remote machine...
[object]Embeds the results of an external function...
[append][append db=base...