It just Does't add up!!!
This WebDNA talk-list message is from 1997
It keeps the original formatting.
numero = 15029
interpreted = N
texte = Hi... I cannot get this calculation to work!It works on paper but not with WebCatallog!All I want to do is:For every 2 items only charge 1 deliveryie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40I have to use [math] for the calculation and [format .1f] to do therounding up... as you can inly round up in the decimal places!Please take a look at the .tmpl file below and see it my math isincorrect or my coding is missing something!It is best viewed from web browser.WebStar 2.1 and WebCatalog Plugin 2.0ThanxMarko---------------------------------- Marko Bernyk---------------------------------- Senior System Engineer Technical Services Conexus Pty Ltd Sydney, Australia e-mail: marko@conexus.com.au http://www.conexus.com.au----------------------------------------markocalculations.tmpl---------For every 2 items only charge 1 delivery
ie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40
Simple... Work this out on paper
1 item
Half this = 0.5
Divide by 10 = 0.05
Round Up with [format .1f] = 0.1
Times by 10 = 1
2 items
Half this = 1
Divide by 10 = 0.1
Round Up with [format .1f] = 0.1
Times by 10 = 1
3 items
Half this = 1.5
Divide by 10 = 0.15
Round Up with [format .1f] = 0.2
Times by 10 = 2
4 items
Half this = 2
Divide by 10 = 0.2
Round Up with [format .1f] = 0.2
Times by 10 = 2
5 items
Half this = 2.5
Divide by 10 = 0.25
Round Up with [format .1f] = 0.3
Times by 10 = 3
Etc...
Here is how rounding works!
--------
Format Floating Point Numbers to 1 decimal place should round up at.x5
1.04=[format .1f] 1.04 [/format]
1.05=[format .1f] 1.05 [/format]
1.06=[format .1f] 1.06 [/format]
1.14=[format .1f] 1.14 [/format]
1.15=[format .1f] 1.15 [/format]
1.16=[format .1f] 1.16 [/format]
1.24=[format .1f] 1.24 [/format]
1.25=[format .1f] 1.25 [/format]
1.26=[format .1f] 1.26 [/format]
1.34=[format .1f] 1.34 [/format]
1.35=[format .1f] 1.35 [/format]
1.36=[format .1f] 1.36 [/format]
----Here are my calculations in a LOOP... they don't work!----
#items | /2 | /10 | Roundup | *10 | Total |
[loop start=1 &end=50 &advance=1][math]item[/math] | [math]roundup=temp/2[/math] | [math]roundup=roundup/10[/math] | [math]roundup=[format .1f][math]roundup[/math][/format][/math] | [math]total=roundup*10[/math] | $[math]total*10[/math] |
[/loop]
Associated Messages, from the most recent to the oldest:
Hi... I cannot get this calculation to work!It works on paper but not with WebCatallog!All I want to do is:For every 2 items only charge 1 deliveryie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40I have to use
[math] for the calculation and [format .1f] to do therounding up... as you can inly round up in the decimal places!Please take a look at the .tmpl file below and see it my math isincorrect or my coding is missing something!It is best viewed from web browser.WebStar 2.1 and WebCatalog Plugin 2.0ThanxMarko---------------------------------- Marko Bernyk---------------------------------- Senior System Engineer Technical Services Conexus Pty Ltd Sydney, Australia e-mail: marko@conexus.com.au http://www.conexus.com.au----------------------------------------markocalculations.tmpl---------For every 2 items only charge 1 delivery
ie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40
Simple... Work this out on paper
1 item
Half this = 0.5
Divide by 10 = 0.05
Round Up with [format .1f] = 0.1
Times by 10 = 1
2 items
Half this = 1
Divide by 10 = 0.1
Round Up with [format .1f] = 0.1
Times by 10 = 1
3 items
Half this = 1.5
Divide by 10 = 0.15
Round Up with [format .1f] = 0.2
Times by 10 = 2
4 items
Half this = 2
Divide by 10 = 0.2
Round Up with [format .1f] = 0.2
Times by 10 = 2
5 items
Half this = 2.5
Divide by 10 = 0.25
Round Up with [format .1f] = 0.3
Times by 10 = 3
Etc...
Here is how rounding works!
--------
Format Floating Point Numbers to 1 decimal place should round up at.x5
1.04=[format .1f] 1.04 [/format]
1.05=[format .1f] 1.05 [/format]
1.06=[format .1f] 1.06 [/format]
1.14=[format .1f] 1.14 [/format]
1.15=[format .1f] 1.15 [/format]
1.16=[format .1f] 1.16 [/format]
1.24=[format .1f] 1.24 [/format]
1.25=[format .1f] 1.25 [/format]
1.26=[format .1f] 1.26 [/format]
1.34=[format .1f] 1.34 [/format]
1.35=[format .1f] 1.35 [/format]
1.36=[format .1f] 1.36 [/format]
----Here are my calculations in a LOOP... they don't work!----
[math]temp=1[/math]>[math]item=1[/math]>[math]total=0[/math]>
#items | /2 | /10 | Roundup | *10 | Total |
[loop start=1 &end=50 &advance=1][math] roundup=0 [/math]>[math]item[/math] | [math]roundup=temp/2[/math] | [math]roundup=roundup/10[/math] | [math]roundup=[format .1f][math]roundup[/math][/format][/math] | [math]total=roundup*10[/math] | $[math]total*10[/math] |
[math]total=0[/math]>[math]item=item+1[/math]>[math]temp=item[/math]>[/loop]
Marko Bernyk
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
3rd request: What are SMSI's upgrade policies? (2003)
Help! WebCat2 bug (1997)
Now when I send TeaRoom Order fields it does not post in Invoice. (1997)
Email (1998)
Referrer problem - Truncation (1998)
WebCat name recognition (was MacFinder -- a new WebDNA website) (1998)
Search in 2 or more catalogs (1997)
CERT Advisory on malicious scripts (2000)
RE: [WebDNA] Bug in WebDNA or in my brain? (2013)
WebCat2b12 CGI Mac - [shownext] problem (1997)
Document contains no data... (1999)
[WebDNA] An alternative to hosting... (2009)
more cookie crumbling (1999)
Re:2nd WebCatalog2 Feature Request (1996)
[CART] inside a [LOOP] (1997)
What am I missing? (1998)
Password Authentication - request example (1998)
Platform Switch (1997)
I don't think my install worked (2003)
Cookies (1999)