What would you like to see in a TiddlyWiki calculator?

New phase for this effort moved to new discussion: TW “Calculator” prototype ready to play with.

The idea for a calculator spawned from [tw5] A simple macro for basic arithmetic.


(Screenshots at the end.)

Pretend for a second you were desperate for a calculator.

What buttons should your kick-bum TiddlyWiki calculator have?

(I’m building a calculator just for the fun of it, but it might be interesting code to dissect.)

At the moment, I’m basing my calculator (well, I’m treating it like an equation builder, planning on adding tiddler field transclusion button as a calculator button only TiddlyWiki could have.) on the calculator on Chromebooks.

If there’s anything else you think would be also good to have, let me know.

Buttons on Chromebook calculator:

What I’ve got working so far:

Exciting stuff. Could it output katex?

@Charlie_Veniot I think this is a great idea, especially if it interacts with tiddlywiki both inputs outputs and possibly even allowing named variable or text/field references to be accessed from the calculator.

For example if you could have a variable or field called interest-rate and you could insert its current value in, from a drop down a bit like one may use Pi. Perhaps in the white space you could guide the user but presenting a text guide eg the formula.

  • This is not so much a smart calculator, technically complex or anything but a tiddlywiki interactive one.

I imagine you can pull some good ones from an open source project and it can subsequently evolve to include tiddlywiki interactive features.

To be honest since my early days with DOS and TSR’s (Terminate and stay resident) apps that provided calculators, I came to discover it is just as easy to have an actual physical desktop calculator, and now the one that comes with the windows desktop, I now have a few on my mobile.

It would be an interesting exercise, like the chess game someone integrated before but it value and its raison d’être would come from integration with tiddlywiki elements. But “Rome was not built in a day”.

I would be happy to explore some of the possibilities, here is but a few.

  • Record and playback what is entered
  • Allow algebraic calcs to be stored and computed with references to fields and variables
  • Invoke the calculator with one or more named fields that the result(s) will be saved in
  • Assist in the collection of numbers ie; to fill in a form provide the variables and save the inputs and result in fields/text references.
    • or save the keystrokes or formula used to achieve the save result.
  • more possible features would arise as each new feature becomes available.

Interesting idea in the long run :nerd_face:

Katex, whether as input or as output, weren’t on my mind at all. I’ll have to (and I’d like to) think about that.

Insta-thought: we already have a KaTeX plugin, so why bother?

My immediate goal now is to have a way to do arithmetic in an alternative way, me finding doing math with filter operators a little bit clumsy.

The idea is to visually put together the math, verify correctness of the math in the result and then:

  • copy the math and paste it into a macro reference, a macro that will just return the value in an iframe, a macro that can be in a $list loop and calculated results in an iframe for each $list item
  • OR, just use this to “prototype” and validate the math, which will then be re-implemented with filter operators

I will eventually also add a calculator button to insert transclusions into the math. So press a button, search for a tiddler (maybe also a field), and add that to the arithmetic string.

“{{ … }}” and “{{{ … }}}” already work. Just need to add the buttons.

You read my mind, except that I have intentionally knee-capped myself a little.

{{…}} and {{{…}}} are already working A-1, but I do plan on adding calculator buttons for those, much like in the tiddler edit toolbar.

Me disliking building javascript macros in TiddlyWiki as much as I dislike working with javascript, I’m using my goto approach for adding TiddlyWiki things with javascript: iframe for dynamically generated HTML that evaluates the math.

This time, though: without the javascript EVAL statement, which I’m not a fan of.

So wikified TiddlyWiki arithmetic gets inserted into the HTML, and that fed to an iframe means TiddlyWiki does not have available to it the result displayed in the iframe.

Easy enough to just pass the result from the iframe to TiddlyWiki via local storage, though.

I might do that eventually.

For now, I’ll just finish it up with a “bah, folk just need the value displayed” mindset.

Then somebody can take what I’ve done and move it to TiddlyWiki javascript macro land.

Status of progress:

More buttons added, starting to think about groupings and group colors, and button label changes.

I just spend too much time doing the calculation and then typing the equation up. Two birds one stone was my thought.

Excellent I’m with you on that one.

That makes sense to me.

Though sometimes I think: poor birds. I picture the last two dodo birds side-by-each, not sure about what is hurtling towards them, and they lean their heads together to make sure they are seeing the same thing. WHAM!

Moving buttons around in this TiddlyWiki calculator as I add new buttons takes a bit too much effort, so I put aside the TiddlyWiki for a little bit and went to Google Sheets to list all of the calculator buttons I think would be good to have, and then organized them into groups for layout of the user interface.

Colour-coded to make the groups pop out a smidgen.

If you can think of any other buttons that would be useful, or even organization that would be more pleasing, let me know.

BTW, not just buttons related to any kind of math. But also buttons related to TiddlyWiki things that would be useful (for example, I’ve put two buttons for transclusion, the “{{ }}” one which will bring up the TW dialog to pick a tiddler, and the “{{{ }}}” for whatever kind of transclusion expression that yields a number.

EXP or x10^x button for 4x10^6 type notation
Degs/ Rads
n!

Those are good ones.

I was thinking HEX, OCT, BIN, DEC too.

I think I’ll tackle EXP right away, and make the rest of them part of a “version 2”. (EDIT: nah, I’ll tackle EXP later. EXP is different in the sense that it can only apply to the end result, I think. All of the other buttons are behave like the tiddler editor toolbar.)

Well, depending on time and mood.

Thank-you much!

2 Likes

I use EXP in calcs, so for example, if something is given in mm, say 3mm, I will enter 3EXP-3 or 7GPa goes in as 7EXP9. I really can’t be bothered working out the number of zeros or where the point goes!

1 Like

Ugh. Not having a real calculator, and being right scatter-brained: I somehow confused exp with scientific notation.

EXP back in version 1, maybe ready in a week or so.

1 Like

What would you like to see in a TiddlyWiki calculator?

A CAT :smiley: icon that interfaces with the wiki!

Just a thought

TT

@Charlie_Veniot another source of what to include in a TW Calculator would be reviewing the existing Maths operators in tiddlywiki and bring forward each relevant to the calculator.

  • I dream that the statistical operations could be made available but it will need some kind of set handling within the calculator. I can imagine a filter to specify the list such as extracting from multiple tiddlers then allowing statical operations on that data.
  • This would be quite challenging so perhaps this type of solution may wait until later iterations or versions of a calculator. But yes I “would you like to see [this] in a TiddlyWiki calculator”! one day.

Update on progress.

I’m working on a custom link button based on the link button in TW’s Tiddler Edit Toolbar.

I have the current as-is button working, but I intend to change it signficantly.

It will allow picking a tiddler and a tiddler field, inserting into the calculator edit field’s the tiddler name (without square brackets) and appending !!field_name to the tiddler name if a field is chosen.

And wrapping with either {{ and }} or {{{ and }}}, leaving you to manually adjust in the calculator editor as needed if the triple curly brakets are chosen.

Something like that. I’m still in investigative design mode.

NOTE: this is a calculator and math builder tool for straight-up math, not meant to create TiddlyWiki filter operators for complex math, although this could be a really useful tool to prototype/test math before trying to do the same thing with filter operators.

Screenshots below of calculator as-is (using flex to shift buttons around depending on screen size) and the default look-feel of the link button at the moment.

Pretty sure I’ll be dumping the “{{}}" and "{{{}}}” buttons on the calculator, and changing the link button to something indicating TW transclusion that opens the do-it-all-transclusion-related-stuff popup.

Screenshot 2022-07-02 10.11.21 PM

1 Like

Looking awesome! Looking forward to this one.

New phase, new thread. (I find long threads in TiddlyTalk unbearable, so I figured best to move to a new discussion.)

TW “Calculator” prototype ready to play with