a spin off from the visual filter builder a basic calculator using just TW filter math operators
[image: sbarcalc.jpg]
Can be expanded for more numbers/equation steps and using the other math
filter operators Tiddlywiki provides (abs, ceil, exponential, fixed, floor,
max, maxall, min, minall, negate, precision, product, remainder, round,
sign, sum, trunc, untrunc)
\define ragscalculator(cnumb1,copera,cnumb2)
[[$cnumb1$]$copera$[$cnumb2$]]
\end
<div style="padding:10px; text-align:center; border:solid 2px;
border-radius:6px;">
<div style=""><span style="font-size:120%;">CALCULATOR</span>
</div>
<div style="display: table; width:80%; margin:0px auto; padding:5px;
border:inset 4px;">
<div style="display: table-row;">
<div style="display: table-cell;">
<$edit-text tiddler="$:/temp/ragscalculator" field="cnum1" placeholder=""
tag="input" type="text" size="3"/>
</div>
<div style="display: table-cell;">
{{$:/temp/ragscalculator!!coper2}}
</div>
<div style="display: table-cell;">
<$edit-text tiddler="$:/temp/ragscalculator" field="cnum2" placeholder=""
tag="input" type="text" size="3"/>
</div>
<div style="display: table-cell;">
= <$list
filter={{$:/temp/ragscalculator!!cfinal}}><<currentTiddler>></$list>
</div>
</div>
</div>
<div style="margin-top:15px;">
<!-- -->
<$button class="tc-btn-rounded" style="font-size:120%;" set="$:/temp/
ragscalculator!!coper" setTo="add" ><$action-setfield $tiddler="$:/temp/
ragscalculator" coper2="+" /> + </$button>
<!-- -->
<$button class="tc-btn-rounded" style="font-size:120%;" set="$:/temp/
ragscalculator!!coper" setTo="subtract" ><$action-setfield $tiddler="$:
/temp/ragscalculator" coper2="-" /> - </$button>
<!-- -->
<$button class="tc-btn-rounded" style="font-size:120%;" set="$:/temp/
ragscalculator!!coper" setTo="multiply" ><$action-setfield $tiddler="$:
/temp/ragscalculator" coper2="x" /> x </$button>
<!-- -->
<$button class="tc-btn-rounded" style="font-size:120%;" set="$:/temp/
ragscalculator!!coper" setTo="divide" ><$action-setfield $tiddler="$:/temp/
ragscalculator" coper2="÷" /> ÷ </$button>
<!-- -->
<$set name="rcnum1" value={{$:/temp/ragscalculator!!cnum1}}>
<$set name="rcopera" value={{$:/temp/ragscalculator!!coper}}>
<$set name="rcnum2" value={{$:/temp/ragscalculator!!cnum2}}>
<$set name="rcfinalres" value={{$:/temp/ragscalculator!!cfinal}}>
<$button class="tc-btn-rounded" style="font-size:120%;" set="$:/temp/
ragscalculator!!cfinal" setTo=<<ragscalculator $(rcnum1)$ $(rcopera)$
$(rcnum2)$>> > = </$button>
<!-- -->
<$button class="tc-btn-rounded" style="padding:0px
5px;font-size:120%;"><$action-setfield
$tiddler="$:/temp/ragscalculator" cnum1="" /><$action-setfield $tiddler="$:
/temp/ragscalculator" cnum2="" /> AC </$button>
<div style="width:60%; margin:30px auto; border:dotted 2px;">
//powered by WikiFilters//<br/>
__FILTER__: <$text text=<<ragscalculator $(rcnum1)$ $(rcopera)$
$(rcnum2)$>>/> = <$list
filter={{$:/temp/ragscalculator!!cfinal}}><<currentTiddler>></$list>
</div>
</div>
</$set></$set></$set></$set>
</div>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/f5da8ef1-68c3-4ef3-9f8b-b6b290ded953%40googlegroups.com.
calculator.tid
Description: Binary data

