sidebar calculator

117 views
Skip to first unread message

A Gloom

unread,
Oct 21, 2019, 9:59:28 PM10/21/19
to TiddlyWiki
a spin off from the visual filter builder

a basic calculator using just TW filter math operators

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>


calculator.tid

TonyM

unread,
Oct 22, 2019, 12:26:40 AM10/22/19
to TiddlyWiki
Impressive

Thanks for sharing. It demonstrates how much the mathematics opperators have extended tiddlywiki.

Lets see if you work can inspire others like a compound interest calculator and more.

Tony

A Gloom

unread,
Oct 22, 2019, 1:06:18 AM10/22/19
to TiddlyWiki
Thanks for sharing. It demonstrates how much the mathematics opperators have extended tiddlywiki.

Lets see if you work can inspire others like a compound interest calculator and more.


TY Tony, thats what I was hoping for, someone to see an opportunity to use the rest of the operators and make a full function calculator or speciality calculator like you suggested-- why I put up the note about expanding it wih the list of the rest of the operators.

I made a conversion utility since I have to do a lot of standard to metric conversions. It's nowhere as streamline and probably not understandable to someone not faliliar with Gloominese so I haven't released it.

Gloominese-- I almost responded to your diversity thread with a mini bio-- still have it in a tiddler in WikiWitchery where I wrote it on a whim-- perhaps hide it as an Easter Egg in the wiki...

Mat

unread,
Oct 22, 2019, 3:14:52 AM10/22/19
to TiddlyWiki
Sidebar calculator

What a perfectly neat idea!!! Makes so much sense!

BTW, testing it out, I note a loose </div> tag seen in the visual display.

<:-)

A Gloom

unread,
Oct 22, 2019, 3:53:10 AM10/22/19
to TiddlyWiki
What a perfectly neat idea!!! Makes so much sense!

BTW, testing it out, I note a loose </div> tag seen in the visual display.

TY Mat, also for pointing out the stray </div> that should be easy to fix : )
Reply all
Reply to author
Forward
0 new messages