{
    "tiddlers": {
        "$:/plugins/telmiger/rpn/about": {
            "title": "$:/plugins/telmiger/rpn/about",
            "created": "20200524154716663",
            "modified": "20200604183147819",
            "tags": "",
            "type": "text/vnd.tiddlywiki",
            "text": "\n//rpn// is a lightweight Javascript macro for basic math operations. It is inspired by formerly popular calculators using Reverse Polish Notation (see [[Wikipedia|https://en.wikipedia.org/wiki/Reverse_Polish_notation]] for more info). Usage example:\n\n`<<rpn 5000 200 * 2 p en-GB>>` output: <<rpn 5000 200 * 2 p en-GB>>"
        },
        "$:/plugins/telmiger/rpn/examples": {
            "title": "$:/plugins/telmiger/rpn/examples",
            "created": "20170715121619734",
            "creator": "Thomas Elmiger",
            "modified": "20200604183147986",
            "modifier": "Thomas Elmiger",
            "tags": "[[ToDo Addons]]",
            "type": "text/vnd.tiddlywiki",
            "text": "!! Examples\n\n`<<rpn pi 2 * 3>>` results in <<rpn pi 2 * 3>>\n\n`<<rpn Pi \" was the name.\" &>>`  \n\n<<<\n<<rpn Pi \" was the name.\" &>>\n<<<\n\n\n`<<rpn a:100 b:200 precision:\"r\">>`  creates a random number in the range from a to b:\n\n<<<\nYour lucky number is <<rpn a:100 b:200 precision:\"r\">>.\n<<<\n\nCalculate the area of a circle with radius 2:\n\n```\n<$macrocall $name=\"rpn\" a=<<rpn 2 2 *>> b=pi operation=\"*\" decimals=\"4\"/>\n```\n<<<\n<$macrocall $name=\"rpn\" a=<<rpn 2 2 *>> b=pi operation=\"*\" decimals=\"4\"/>\n<<<\n\nA 50% discount price, rounded downwards with Swiss formatting applied: \n\n```\n<$macrocall $name=\"rpn\" a=<<rpn 2123.45 50 * 0 f>> b=100 operation=\"/\" decimals=\"2\" precision=\"p\" locale=\"de-CH\"/>\n```\n<<<\n<$macrocall $name=\"rpn\" a=<<rpn 2123.45 50 * 0 f>> b=100 operation=\"/\" decimals=\"2\" precision=\"p\" locale=\"de-CH\"/>\n<<<\n\nFor more examples see https://tid.li/tw5/hacks.html#rpnTest."
        },
        "$:/plugins/telmiger/rpn/fields": {
            "title": "$:/plugins/telmiger/rpn/fields",
            "created": "20181111064908459",
            "creator": "Thomas Elmiger",
            "modified": "20200604183147998",
            "modifier": "Thomas Elmiger",
            "tags": "",
            "type": "text/vnd.tiddlywiki",
            "text": "!! Calculate with Field Values and RPN\n\nThe //rpnFields// macro takes the value of a defined field from filtered tiddlers, applies the same operation to all and saves the result in a given tiddler. It produces a button to start the calculation and calculates using [[RPN|$:/plugins/telmiger/rpn]].\n\n\n!!! Attributes\n\n|!Attribute |!Description |!Default |\n|filter |a filter to select tiddlers – the macro makes sure to use only the ones containinig the specified //field// |all tiddlers except system tiddlers |\n|startvalue |a value to start with, e.g. the result of a preceding calculation |\"0\" |\n|field |the name of the field to take the (numeric) value from |\"text\" |\n|operation |operation to apply to all values |\"+\" |\n|saveTo |the tiddler to store the result in |$:/temp/telmiger/rpn/result |\n|saveField |the field to store the result in |\"text\" |\n|label |the label for the button |\"Calculate\" |\n\n!!! Usage\n\n```\n<<rpnFields \"[prefix[yourCODE]]\">>\n\n<<rpnFields filter:\"[prefix[ZEIT:]]\" field:\"time_used\" saveTo:\"\" saveField:\"time_total\" label:\"Add all\">>\n\n<<rpnFields filter:\"[prefix[ZEIT:]]\" startvalue:\"1000\" field:\"time_used\" operation:\"-\" label:\"Remaining from 1000\">>\n```\n\n{{rpnDemo}}\n"
        },
        "$:/plugins/telmiger/rpn/icon": {
            "title": "$:/plugins/telmiger/rpn/icon",
            "created": "20170715123511072",
            "modified": "20200604183148010",
            "tags": "",
            "type": "text/vnd.tiddlywiki",
            "text": "<svg width=\"22pt\" height=\"22pt\" viewBox=\"0 0 22 22\" xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" stroke-linejoin=\"round\" stroke-miterlimit=\"2\">\n  <path d=\"M11.1.2l9.2 5.4v10.8L11.1 22 2 16.4V5.6L11 .2z\" fill=\"#ff7\" fill-rule=\"nonzero\"/>\n  <path d=\"M11.1 20a9 9 0 100-18 9 9 0 000 18zm-1.8-2.8c.5 0 1-.6 1.3-.9.3-.4.5-1 .5-1.7v-1.3c0-.8.1-1.4.5-1.7.3-.3.8-.6 1.5-.7h0c-.9-.1-1.5-.4-1.8-1-.2-.4-.3-1-.3-1.7v-1a3 3 0 00-.3-1.5c-.3-.5-.7-1-1.4-1v-.1h.3c1.3 0 2.1.4 2.6 1 .2.5.4 1.2.4 2v1.2c0 .7.1 1.1.3 1.4.3.3.8.5 1.5.6l.2.1h-.2a5.5 5.5 0 00-1.1.5c-.2 0-.4.2-.5.4l-.2.6V14c0 1-.2 1.6-.4 2-.5.7-1.4 1.1-2.6 1.2h-.3v-.1z\" fill=\"#e2001a\" fill-rule=\"nonzero\"/>\n</svg>"
        },
        "$:/plugins/telmiger/rpn/readme": {
            "title": "$:/plugins/telmiger/rpn/readme",
            "created": "20170714205116352",
            "creator": "Thomas Elmiger",
            "modified": "20200604183148017",
            "modifier": "Thomas Elmiger",
            "tags": "[[ToDo Addons]]",
            "type": "text/vnd.tiddlywiki",
            "text": "!! Simple calculations\n\n{{$:/plugins/telmiger/rpn/about}}\n\n* the macro takes two operands (//a// and //b//) as input – this may be macros or transclusions\n** operands are sent through a simplified [[wikify|http://tiddlywiki.com/#WikifyWidget]] function before calculation starts\n** use //pi// to get π (Math.PI)\n* standard operations: +, -, /, * \n** advanced operations: modulus (%) and rounding (optional: Math.floor or Math.ceil)\n* output formatting\n** limit digits after comma (//decimals//), force //precision// display with //precision:\"p\"// (.toPrecision)\n** //locale// formatting (.toLocaleString)\n* string concatenation (&)\n** the resulting string is sent through the internal [[wikify|http://tiddlywiki.com/#WikifyWidget]] function \n* random numbers in a range from a to b with //precision:\"r\"// (including both a and b)\n\n!!! New: Wikitext Macros\n* calculate using filters and tiddler fields, see //fields// tab (since version 0.7.1)\n\n!!! Installation\nThe plugin available on https://tid.li/tw5/plugins.html includes the documentation.<br>\nIf you want the functionality only, you can drag this tiddler to your wiki: $:/plugins/telmiger/rpn/rpn.js – then save and reload. \n\n!!! Alternatives\n* [[TW mathematic filter operators (see tiddlywiki.com)|https://tiddlywiki.com/#Mathematics%20Operators]]\n* https://evanbalster.com/tiddlywiki/formulas.html – process numbers and other data just like popular spreadsheet software, with the additional flexibility of functional programming for those who need it\n* http://mathcell.tiddlyspot.com/ – tries to replace spreadsheet applications and uses some identical operators as rpn\n* http://tobibeer.github.io/tb5/#calc – does calculations based on tiddler fields\n* eval – calc combined with ''math.js'' – a heavy math library\n** http://mklauber.github.io/tiddly-mathjs/ \n** http://tobibeer.github.io/tw5-plugins/#math.js"
        },
        "$:/plugins/telmiger/rpn/rpn.js": {
            "title": "$:/plugins/telmiger/rpn/rpn.js",
            "text": "/*\\\ntitle: $:/plugins/telmiger/lib/rpn.js\ntype: application/javascript\nmodule-type: macro\n\nMacro to execute simple calculations in reverse Polish notation\nDocumentation see https://tid.li/tw5/plugins.html\nVersion 0.6.2\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\n*/\n\nexports.name = \"rpn\";\n\nexports.params = [\n\t{name: \"a\"},\n\t{name: \"b\"},\n        {name: \"operation\", default: \"+\"},\n        {name: \"decimals\", default: \"\"},\n        {name: \"precision\", default: \"\"},\n        {name: \"locale\", default: \"false\"},\n        {name: \"sd\", default: \".\"},\n        {name: \"st\", default: \"\"}\n];\n\n/*\nWikify\n*/\nfunction wikifyText(t) {\n\tvar Parser = $tw.wiki.parseText(\"text/vnd.tiddlywiki\",t,{\n\t\t\tparseAsInline: true\n\t\t});\n\tvar WidgetNode = $tw.wiki.makeWidget(Parser,{\n\t\t\tdocument: $tw.fakeDocument\n\t\t});\n\tvar Container = $tw.fakeDocument.createElement(\"div\");\n\tWidgetNode.render(Container,null);\n\treturn Container.textContent;\n}\n\n/*\nFormat decimals and (TODO!) thousands\n*/\nfunction formatNumber(value,sd,st) {\n\tlet string = value.toString();\n\t// string = string; // TODO separator for thousands\n\treturn string.replace(\".\",sd); // separator for decimals\n}\n\n/*\nFormatting with locale\n*/\nfunction formatLocale(value,decimals,precision,locale) { \n\tlet result = \"NaN\";\n\tif(decimals == \"\" || decimals >= 0) {\n\t\tlet minFracDig = (precision == \"p\" ? decimals : \"\");\n\t\tresult = value.toLocaleString(locale, { minimumFractionDigits: minFracDig });\n\t}\n\telse {\n\t\tresult = \"invalid decimals\";\n\t}\n\treturn result;\n}\n\n/*\nPrecision for decimals\n*/\nfunction addPrecisionDecimals(result,decimals) { \n    let di = parseInt(decimals);\n    let rInteger = result.toString().split('.')[0].length;\n    let p = rInteger + di;\n    if(p > 0 && p < 101) {\n\tresult = result.toPrecision(p);\n    }\n    else {\n        result = \"invalid decimals\";\n    }\n    return result;\n}\n\n/*\nRandom numbers including a and b\n*/\nfunction randomInteger(a,b) {\n\tlet min = Math.ceil(a);\n\tlet max = Math.floor(b + 1);\n\treturn Math.floor(Math.random() * (max - min)) + min; \n}\n\n/*\nMath\n*/\nfunction calculate(a,b,operation) {\n    let result = \"NaN\";\n    switch(operation) {\n        case \"-\":\n            result = a - b;\n            break;\n        case \"*\":\n            result = a * b;\n            break;\n        case \"/\":\n            result = a / b;\n            break;\n        case \"%\":\n            result = a % b;\n            break;\n        default:\n            result = a + b;\n    }\n    return result;\n}\n\n/*\nRun the macro\n*/\nexports.run = function(a,b,operation,decimals,precision,locale,sd,st) {\n\tlet aw = wikifyText(a);\n\tlet bw = wikifyText(b);\n\tlet result = \"\";\n\tif(operation == \"&\") {\n\t\tresult = wikifyText(a + b);\n\t}\n\telse {\n\t\t// prepare values\n\t\tvar af = aw.replace(\",\",\".\");\n\t\tvar bf = bw.replace(\",\",\".\");\n\t\taf = (af == \"pi\" ? Math.PI : parseFloat(af));\n\t\tbf = (bf == \"pi\" ? Math.PI : parseFloat(bf));\n\t\t// do the math\n\t\tresult = calculate(af,bf,operation);\n\t\t// precision modes\n\t\tif(precision == \"r\") {\n\t\t\tresult = randomInteger(af,bf); \n\t\t}\n\t\telse if(precision == \"p\" && locale == \"false\") {\n\t\t\tresult = addPrecisionDecimals(result,decimals);\n\t\t}\n\t\telse if(precision == \"c\") {\n\t\t\tresult = Math.ceil(result);\n\t\t}\n\t\telse if(precision == \"f\") {\n\t\t\tresult = Math.floor(result);\n\t\t}\n\t\telse if(precision != \"\" && locale == \"false\") {\n\t\t// formatLocale ignores precision values other than p\n\t\t\tresult = \"invalid precision\";\n\t\t}\n\t\t// if precision is not defined, round based on (max.) decimals\n\t\telse if(decimals != \"\") {\n\t\t\tvar di = parseInt(decimals);\n\t\t\tresult = Math.round(result * Math.pow(10, di)) / Math.pow(10, di);            \n\t\t}\n\t\t// format output\n\t\tif(locale != \"false\") {\n\t\t\tresult = formatLocale(result,decimals,precision,locale);\n\t\t}\n\t\telse {\n\t\t\tresult = formatNumber(result,sd,st);\n\t\t}\n\t}\n\treturn result;\n};\n\n})();\n",
            "type": "application/javascript",
            "module-type": "macro",
            "created": "20170626211546891",
            "creator": "Thomas Elmiger",
            "modified": "20200604183148030",
            "modifier": "Thomas Elmiger",
            "tags": "[[ToDo Addons]]"
        },
        "$:/plugins/telmiger/rpn/rpnFields": {
            "title": "$:/plugins/telmiger/rpn/rpnFields",
            "created": "20181111075024851",
            "creator": "Thomas Elmiger",
            "modified": "20200604183148043",
            "modifier": "Thomas Elmiger",
            "tags": "$:/tags/Macro",
            "type": "text/vnd.tiddlywiki",
            "text": "\\define rpnFields(filter:\"[tags[]!is[system]]\",startvalue:\"0\",field:\"text\",operation:\"+\",\n saveTo:\"$:/temp/telmiger/rpn/result\",saveField:\"text\",label:\"Calculate\")\n<$button>\n<$vars filter=\"\"\"$filter$\"\"\" startvalue=\"\"\"$startvalue$\"\"\" field=\"\"\"$field$\"\"\" operation=\"\"\"$operation$\"\"\" saveTo=\"\"\"$saveTo$\"\"\" saveField=\"\"\"$saveField$\"\"\">\n<$wikify name=\"countfilter\" text=\"\"\"$filter$ +[has[<<field>>]] +[count[]]\"\"\">\n<$set name=\"items\" filter=<<countfilter>> emptyValue=\"0\">\n<$macrocall $name=\"calcAll\" startvalue=<<startvalue>> counter=<<items>>/>\n\"\"\"$label$\"\"\"\n</$set>\n</$wikify>\n</$vars>\n</$button>\n\\end\n\n\\define saveResult(a:\"0\")\n<$action-setfield $tiddler=\"$(saveTo)$\" $field=\"$(saveField)$\" $value=\"\"\"$a$\"\"\"/>\n\\end\n\n\\define calculate(a:\"0\",b:\"0\",counter)\n<$wikify name=\"result\" text='<$macrocall $name=\"rpn\" a=$a$ b=$b$ operation=$(operation)$/>'>\n<$macrocall $name=\"calcAll\" startvalue=<<result>> counter=$counter$/>\n</$wikify>\n\\end\n\n\\define calcAll(startvalue,counter)\n<$wikify name=\"next\" text='<$macrocall $name=\"rpn\" a=$counter$ b=1 operation=\"-\"/>'>\n<$wikify name=\"restfilter\" text=\"\"\"$(filter)$  +[has[$(field)$]] +[rest[<<next>>]limit[1]]\"\"\">\n<$set name=\"proceed\" filter=\"[<next>prefix[-]]\" value=\"saveResult\" emptyValue=\"calculate\">\n<$list filter=<<restfilter>> variable=\"tid\">\n<$vars a=$startvalue$>\n<$wikify name=\"b\" text='<$transclude tiddler=<<tid>> field=$(field)$/>'>\n<$macrocall $name=<<proceed>> a=<<a>> b=<<b>> counter=<<next>>/>\n</$wikify>\n</$vars>\n</$list>\n</$set>\n</$wikify>\n</$wikify>\n\\end\n"
        },
        "$:/plugins/telmiger/rpn/support": {
            "title": "$:/plugins/telmiger/rpn/support",
            "created": "20181111202222852",
            "modified": "20200604183148049",
            "tags": "",
            "type": "text/vnd.tiddlywiki",
            "text": "{{$:/plugins/telmiger/support}}"
        },
        "$:/plugins/telmiger/rpn/usage": {
            "title": "$:/plugins/telmiger/rpn/usage",
            "created": "20170715121502832",
            "creator": "Thomas Elmiger",
            "modified": "20200604183148059",
            "modifier": "Thomas Elmiger",
            "tags": "[[ToDo Addons]]",
            "type": "text/vnd.tiddlywiki",
            "text": "!! Usage\n\n`<<rpn 5000 200 * 2 p en-GB>>` output: <<rpn 5000 200 * 2 p en-GB>>\n\nThe following operations can be used with two operands:\n\n|Operation |Description |h\n|+ |Addition |\n|- |Subtraction |\n|* |Multiplication |\n|/ |Division |\n|% |Modulo (remains after division) |\n|& |Concatenation of two strings^^1^^ |\n| |[none] when generating random numbers, any value would be ignored |\n\n<small>1 – The list of operators found at Stephen Kimmel’s Mathcell project (see readme section) inspired me to implement this easter egg – it has nothing to do with math.</small>\n\n|Parameter |Description |h\n|a |first operand |\n|b |second operand |\n|operation |see above |\n|decimals |digits after comma (number) |\n|precision |defaults to \"\"<br>\"p\" to show all digits after comma (precision)<br>\"f\" to round downwards to the next integer (Math.floor)<br>\"c\" to round upwards to the next integer (Math.ceil) <br>\"r\" to get a random integer in the range from a to b, a and b included (Math.random) |\n|locale |Formatting according to language or country specific standards, e.g. \"en\", \"de-DE\" or \"de-CH\" – [[toLocaleString|https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#Browser_compatibility]] is used, including minimumFractionDigits option if decimals and precision \"p\" are provided. |\n|sd |separator for decimals if //locale// is not used, defaults to \".\" |\n|st |TODO separator for thousands if //locale// is not used, defaults to \"\" |\n\n!!! Known limitations\n* //st// is not implemented yet"
        },
        "$:/plugins/telmiger/rpn": {
            "text": "{\n    \"tiddlers\": {\n        \"$:/plugins/telmiger/rpn/examples\": {\n            \"created\": \"20170715121619734\",\n            \"creator\": \"Thomas Elmiger\",\n            \"text\": \"!! Examples\\n\\n`<<rpn pi 2 * 3>>` results in <<rpn pi 2 * 3>>\\n\\n`<<rpn Pi \\\" was the name.\\\" &>>`  \\n\\n<<<\\n<<rpn Pi \\\" was the name.\\\" &>>\\n<<<\\n\\n\\n`<<rpn a:100 b:200 precision:\\\"r\\\">>`  creates a random number in the range from a to b:\\n\\n<<<\\nYour lucky number is <<rpn a:100 b:200 precision:\\\"r\\\">>.\\n<<<\\n\\nCalculate the area of a circle with radius 2:\\n\\n```\\n<$macrocall $name=\\\"rpn\\\" a=<<rpn 2 2 *>> b=pi operation=\\\"*\\\" decimals=\\\"4\\\"/>\\n```\\n<<<\\n<$macrocall $name=\\\"rpn\\\" a=<<rpn 2 2 *>> b=pi operation=\\\"*\\\" decimals=\\\"4\\\"/>\\n<<<\\n\\nA 50% discount price, rounded downwards with Swiss formatting applied: \\n\\n```\\n<$macrocall $name=\\\"rpn\\\" a=<<rpn 2123.45 50 * 0 f>> b=100 operation=\\\"/\\\" decimals=\\\"2\\\" precision=\\\"p\\\" locale=\\\"de-CH\\\"/>\\n```\\n<<<\\n<$macrocall $name=\\\"rpn\\\" a=<<rpn 2123.45 50 * 0 f>> b=100 operation=\\\"/\\\" decimals=\\\"2\\\" precision=\\\"p\\\" locale=\\\"de-CH\\\"/>\\n<<<\\n\\nFor more examples see https://tid.li/tw5/hacks.html#rpnTest.\",\n            \"title\": \"$:/plugins/telmiger/rpn/examples\",\n            \"tags\": \"[[ToDo Addons]]\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20170814063737796\"\n        },\n        \"$:/plugins/telmiger/rpn/icon\": {\n            \"created\": \"20170715123511072\",\n            \"text\": \"<svg width=\\\"22pt\\\" height=\\\"22pt\\\" viewBox=\\\"0 0 22 22\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" fill-rule=\\\"evenodd\\\" clip-rule=\\\"evenodd\\\" stroke-linejoin=\\\"round\\\" stroke-miterlimit=\\\"2\\\">\\n  <path d=\\\"M11.1.2l9.2 5.4v10.8L11.1 22 2 16.4V5.6L11 .2z\\\" fill=\\\"#ff7\\\" fill-rule=\\\"nonzero\\\"/>\\n  <path d=\\\"M11.1 20a9 9 0 100-18 9 9 0 000 18zm-1.8-2.8c.5 0 1-.6 1.3-.9.3-.4.5-1 .5-1.7v-1.3c0-.8.1-1.4.5-1.7.3-.3.8-.6 1.5-.7h0c-.9-.1-1.5-.4-1.8-1-.2-.4-.3-1-.3-1.7v-1a3 3 0 00-.3-1.5c-.3-.5-.7-1-1.4-1v-.1h.3c1.3 0 2.1.4 2.6 1 .2.5.4 1.2.4 2v1.2c0 .7.1 1.1.3 1.4.3.3.8.5 1.5.6l.2.1h-.2a5.5 5.5 0 00-1.1.5c-.2 0-.4.2-.5.4l-.2.6V14c0 1-.2 1.6-.4 2-.5.7-1.4 1.1-2.6 1.2h-.3v-.1z\\\" fill=\\\"#e2001a\\\" fill-rule=\\\"nonzero\\\"/>\\n</svg>\",\n            \"title\": \"$:/plugins/telmiger/rpn/icon\",\n            \"tags\": \"\",\n            \"modified\": \"20200524185736871\"\n        },\n        \"$:/plugins/telmiger/rpn/readme\": {\n            \"created\": \"20170714205116352\",\n            \"creator\": \"Thomas Elmiger\",\n            \"text\": \"!! Simple calculations\\n\\n{{$:/plugins/telmiger/rpn/about}}\\n\\n* the macro takes two operands (//a// and //b//) as input – this may be macros or transclusions\\n** operands are sent through a simplified [[wikify|http://tiddlywiki.com/#WikifyWidget]] function before calculation starts\\n** use //pi// to get π (Math.PI)\\n* standard operations: +, -, /, * \\n** advanced operations: modulus (%) and rounding (optional: Math.floor or Math.ceil)\\n* output formatting\\n** limit digits after comma (//decimals//), force //precision// display with //precision:\\\"p\\\"// (.toPrecision)\\n** //locale// formatting (.toLocaleString)\\n* string concatenation (&)\\n** the resulting string is sent through the internal [[wikify|http://tiddlywiki.com/#WikifyWidget]] function \\n* random numbers in a range from a to b with //precision:\\\"r\\\"// (including both a and b)\\n\\n!!! New: Wikitext Macros\\n* calculate using filters and tiddler fields, see //fields// tab (since version 0.7.1)\\n\\n!!! Installation\\nThe plugin available on https://tid.li/tw5/plugins.html includes the documentation.<br>\\nIf you want the functionality only, you can drag this tiddler to your wiki: $:/plugins/telmiger/rpn/rpn.js – then save and reload. \\n\\n!!! Alternatives\\n* [[TW mathematic filter operators (see tiddlywiki.com)|https://tiddlywiki.com/#Mathematics%20Operators]]\\n* https://evanbalster.com/tiddlywiki/formulas.html – process numbers and other data just like popular spreadsheet software, with the additional flexibility of functional programming for those who need it\\n* http://mathcell.tiddlyspot.com/ – tries to replace spreadsheet applications and uses some identical operators as rpn\\n* http://tobibeer.github.io/tb5/#calc – does calculations based on tiddler fields\\n* eval – calc combined with ''math.js'' – a heavy math library\\n** http://mklauber.github.io/tiddly-mathjs/ \\n** http://tobibeer.github.io/tw5-plugins/#math.js\",\n            \"title\": \"$:/plugins/telmiger/rpn/readme\",\n            \"tags\": \"[[ToDo Addons]]\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20200524154810042\"\n        },\n        \"$:/plugins/telmiger/rpn/rpn.js\": {\n            \"text\": \"/*\\\\\\ntitle: $:/plugins/telmiger/lib/rpn.js\\ntype: application/javascript\\nmodule-type: macro\\n\\nMacro to execute simple calculations in reverse Polish notation\\nDocumentation see https://tid.li/tw5/plugins.html\\nVersion 0.6.2\\n\\\\*/\\n(function(){\\n\\n/*jslint node: true, browser: true */\\n/*global $tw: false */\\n\\\"use strict\\\";\\n\\n/*\\nInformation about this macro\\n*/\\n\\nexports.name = \\\"rpn\\\";\\n\\nexports.params = [\\n\\t{name: \\\"a\\\"},\\n\\t{name: \\\"b\\\"},\\n        {name: \\\"operation\\\", default: \\\"+\\\"},\\n        {name: \\\"decimals\\\", default: \\\"\\\"},\\n        {name: \\\"precision\\\", default: \\\"\\\"},\\n        {name: \\\"locale\\\", default: \\\"false\\\"},\\n        {name: \\\"sd\\\", default: \\\".\\\"},\\n        {name: \\\"st\\\", default: \\\"\\\"}\\n];\\n\\n/*\\nWikify\\n*/\\nfunction wikifyText(t) {\\n\\tvar Parser = $tw.wiki.parseText(\\\"text/vnd.tiddlywiki\\\",t,{\\n\\t\\t\\tparseAsInline: true\\n\\t\\t});\\n\\tvar WidgetNode = $tw.wiki.makeWidget(Parser,{\\n\\t\\t\\tdocument: $tw.fakeDocument\\n\\t\\t});\\n\\tvar Container = $tw.fakeDocument.createElement(\\\"div\\\");\\n\\tWidgetNode.render(Container,null);\\n\\treturn Container.textContent;\\n}\\n\\n/*\\nFormat decimals and (TODO!) thousands\\n*/\\nfunction formatNumber(value,sd,st) {\\n\\tlet string = value.toString();\\n\\t// string = string; // TODO separator for thousands\\n\\treturn string.replace(\\\".\\\",sd); // separator for decimals\\n}\\n\\n/*\\nFormatting with locale\\n*/\\nfunction formatLocale(value,decimals,precision,locale) { \\n\\tlet result = \\\"NaN\\\";\\n\\tif(decimals == \\\"\\\" || decimals >= 0) {\\n\\t\\tlet minFracDig = (precision == \\\"p\\\" ? decimals : \\\"\\\");\\n\\t\\tresult = value.toLocaleString(locale, { minimumFractionDigits: minFracDig });\\n\\t}\\n\\telse {\\n\\t\\tresult = \\\"invalid decimals\\\";\\n\\t}\\n\\treturn result;\\n}\\n\\n/*\\nPrecision for decimals\\n*/\\nfunction addPrecisionDecimals(result,decimals) { \\n    let di = parseInt(decimals);\\n    let rInteger = result.toString().split('.')[0].length;\\n    let p = rInteger + di;\\n    if(p > 0 && p < 101) {\\n\\tresult = result.toPrecision(p);\\n    }\\n    else {\\n        result = \\\"invalid decimals\\\";\\n    }\\n    return result;\\n}\\n\\n/*\\nRandom numbers including a and b\\n*/\\nfunction randomInteger(a,b) {\\n\\tlet min = Math.ceil(a);\\n\\tlet max = Math.floor(b + 1);\\n\\treturn Math.floor(Math.random() * (max - min)) + min; \\n}\\n\\n/*\\nMath\\n*/\\nfunction calculate(a,b,operation) {\\n    let result = \\\"NaN\\\";\\n    switch(operation) {\\n        case \\\"-\\\":\\n            result = a - b;\\n            break;\\n        case \\\"*\\\":\\n            result = a * b;\\n            break;\\n        case \\\"/\\\":\\n            result = a / b;\\n            break;\\n        case \\\"%\\\":\\n            result = a % b;\\n            break;\\n        default:\\n            result = a + b;\\n    }\\n    return result;\\n}\\n\\n/*\\nRun the macro\\n*/\\nexports.run = function(a,b,operation,decimals,precision,locale,sd,st) {\\n\\tlet aw = wikifyText(a);\\n\\tlet bw = wikifyText(b);\\n\\tlet result = \\\"\\\";\\n\\tif(operation == \\\"&\\\") {\\n\\t\\tresult = wikifyText(a + b);\\n\\t}\\n\\telse {\\n\\t\\t// prepare values\\n\\t\\tvar af = aw.replace(\\\",\\\",\\\".\\\");\\n\\t\\tvar bf = bw.replace(\\\",\\\",\\\".\\\");\\n\\t\\taf = (af == \\\"pi\\\" ? Math.PI : parseFloat(af));\\n\\t\\tbf = (bf == \\\"pi\\\" ? Math.PI : parseFloat(bf));\\n\\t\\t// do the math\\n\\t\\tresult = calculate(af,bf,operation);\\n\\t\\t// precision modes\\n\\t\\tif(precision == \\\"r\\\") {\\n\\t\\t\\tresult = randomInteger(af,bf); \\n\\t\\t}\\n\\t\\telse if(precision == \\\"p\\\" && locale == \\\"false\\\") {\\n\\t\\t\\tresult = addPrecisionDecimals(result,decimals);\\n\\t\\t}\\n\\t\\telse if(precision == \\\"c\\\") {\\n\\t\\t\\tresult = Math.ceil(result);\\n\\t\\t}\\n\\t\\telse if(precision == \\\"f\\\") {\\n\\t\\t\\tresult = Math.floor(result);\\n\\t\\t}\\n\\t\\telse if(precision != \\\"\\\" && locale == \\\"false\\\") {\\n\\t\\t// formatLocale ignores precision values other than p\\n\\t\\t\\tresult = \\\"invalid precision\\\";\\n\\t\\t}\\n\\t\\t// if precision is not defined, round based on (max.) decimals\\n\\t\\telse if(decimals != \\\"\\\") {\\n\\t\\t\\tvar di = parseInt(decimals);\\n\\t\\t\\tresult = Math.round(result * Math.pow(10, di)) / Math.pow(10, di);            \\n\\t\\t}\\n\\t\\t// format output\\n\\t\\tif(locale != \\\"false\\\") {\\n\\t\\t\\tresult = formatLocale(result,decimals,precision,locale);\\n\\t\\t}\\n\\t\\telse {\\n\\t\\t\\tresult = formatNumber(result,sd,st);\\n\\t\\t}\\n\\t}\\n\\treturn result;\\n};\\n\\n})();\\n\",\n            \"type\": \"application/javascript\",\n            \"title\": \"$:/plugins/telmiger/rpn/rpn.js\",\n            \"tags\": \"[[ToDo Addons]]\",\n            \"module-type\": \"macro\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20170814062342206\",\n            \"creator\": \"Thomas Elmiger\",\n            \"created\": \"20170626211546891\"\n        },\n        \"$:/plugins/telmiger/rpn/usage\": {\n            \"created\": \"20170715121502832\",\n            \"text\": \"!! Usage\\n\\n`<<rpn 5000 200 * 2 p en-GB>>` output: <<rpn 5000 200 * 2 p en-GB>>\\n\\nThe following operations can be used with two operands:\\n\\n|Operation |Description |h\\n|+ |Addition |\\n|- |Subtraction |\\n|* |Multiplication |\\n|/ |Division |\\n|% |Modulo (remains after division) |\\n|& |Concatenation of two strings^^1^^ |\\n| |[none] when generating random numbers, any value would be ignored |\\n\\n<small>1 – The list of operators found at Stephen Kimmel’s Mathcell project (see readme section) inspired me to implement this easter egg – it has nothing to do with math.</small>\\n\\n|Parameter |Description |h\\n|a |first operand |\\n|b |second operand |\\n|operation |see above |\\n|decimals |digits after comma (number) |\\n|precision |defaults to \\\"\\\"<br>\\\"p\\\" to show all digits after comma (precision)<br>\\\"f\\\" to round downwards to the next integer (Math.floor)<br>\\\"c\\\" to round upwards to the next integer (Math.ceil) <br>\\\"r\\\" to get a random integer in the range from a to b, a and b included (Math.random) |\\n|locale |Formatting according to language or country specific standards, e.g. \\\"en\\\", \\\"de-DE\\\" or \\\"de-CH\\\" – [[toLocaleString|https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#Browser_compatibility]] is used, including minimumFractionDigits option if decimals and precision \\\"p\\\" are provided. |\\n|sd |separator for decimals if //locale// is not used, defaults to \\\".\\\" |\\n|st |TODO separator for thousands if //locale// is not used, defaults to \\\"\\\" |\\n\\n!!! Known limitations\\n* //st// is not implemented yet\",\n            \"title\": \"$:/plugins/telmiger/rpn/usage\",\n            \"tags\": \"[[ToDo Addons]]\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20200524195900125\",\n            \"creator\": \"Thomas Elmiger\"\n        },\n        \"$:/plugins/telmiger/rpn/fields\": {\n            \"created\": \"20181111064908459\",\n            \"creator\": \"Thomas Elmiger\",\n            \"text\": \"!! Calculate with Field Values and RPN\\n\\nThe //rpnFields// macro takes the value of a defined field from filtered tiddlers, applies the same operation to all and saves the result in a given tiddler. It produces a button to start the calculation and calculates using [[RPN|$:/plugins/telmiger/rpn]].\\n\\n\\n!!! Attributes\\n\\n|!Attribute |!Description |!Default |\\n|filter |a filter to select tiddlers – the macro makes sure to use only the ones containinig the specified //field// |all tiddlers except system tiddlers |\\n|startvalue |a value to start with, e.g. the result of a preceding calculation |\\\"0\\\" |\\n|field |the name of the field to take the (numeric) value from |\\\"text\\\" |\\n|operation |operation to apply to all values |\\\"+\\\" |\\n|saveTo |the tiddler to store the result in |$:/temp/telmiger/rpn/result |\\n|saveField |the field to store the result in |\\\"text\\\" |\\n|label |the label for the button |\\\"Calculate\\\" |\\n\\n!!! Usage\\n\\n```\\n<<rpnFields \\\"[prefix[yourCODE]]\\\">>\\n\\n<<rpnFields filter:\\\"[prefix[ZEIT:]]\\\" field:\\\"time_used\\\" saveTo:\\\"\\\" saveField:\\\"time_total\\\" label:\\\"Add all\\\">>\\n\\n<<rpnFields filter:\\\"[prefix[ZEIT:]]\\\" startvalue:\\\"1000\\\" field:\\\"time_used\\\" operation:\\\"-\\\" label:\\\"Remaining from 1000\\\">>\\n```\\n\\n{{rpnDemo}}\\n\",\n            \"title\": \"$:/plugins/telmiger/rpn/fields\",\n            \"tags\": \"\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20181111194355026\"\n        },\n        \"$:/plugins/telmiger/rpn/rpnFields\": {\n            \"created\": \"20181111075024851\",\n            \"creator\": \"Thomas Elmiger\",\n            \"text\": \"\\\\define rpnFields(filter:\\\"[tags[]!is[system]]\\\",startvalue:\\\"0\\\",field:\\\"text\\\",operation:\\\"+\\\",\\n saveTo:\\\"$:/temp/telmiger/rpn/result\\\",saveField:\\\"text\\\",label:\\\"Calculate\\\")\\n<$button>\\n<$vars filter=\\\"\\\"\\\"$filter$\\\"\\\"\\\" startvalue=\\\"\\\"\\\"$startvalue$\\\"\\\"\\\" field=\\\"\\\"\\\"$field$\\\"\\\"\\\" operation=\\\"\\\"\\\"$operation$\\\"\\\"\\\" saveTo=\\\"\\\"\\\"$saveTo$\\\"\\\"\\\" saveField=\\\"\\\"\\\"$saveField$\\\"\\\"\\\">\\n<$wikify name=\\\"countfilter\\\" text=\\\"\\\"\\\"$filter$ +[has[<<field>>]] +[count[]]\\\"\\\"\\\">\\n<$set name=\\\"items\\\" filter=<<countfilter>> emptyValue=\\\"0\\\">\\n<$macrocall $name=\\\"calcAll\\\" startvalue=<<startvalue>> counter=<<items>>/>\\n\\\"\\\"\\\"$label$\\\"\\\"\\\"\\n</$set>\\n</$wikify>\\n</$vars>\\n</$button>\\n\\\\end\\n\\n\\\\define saveResult(a:\\\"0\\\")\\n<$action-setfield $tiddler=\\\"$(saveTo)$\\\" $field=\\\"$(saveField)$\\\" $value=\\\"\\\"\\\"$a$\\\"\\\"\\\"/>\\n\\\\end\\n\\n\\\\define calculate(a:\\\"0\\\",b:\\\"0\\\",counter)\\n<$wikify name=\\\"result\\\" text='<$macrocall $name=\\\"rpn\\\" a=$a$ b=$b$ operation=$(operation)$/>'>\\n<$macrocall $name=\\\"calcAll\\\" startvalue=<<result>> counter=$counter$/>\\n</$wikify>\\n\\\\end\\n\\n\\\\define calcAll(startvalue,counter)\\n<$wikify name=\\\"next\\\" text='<$macrocall $name=\\\"rpn\\\" a=$counter$ b=1 operation=\\\"-\\\"/>'>\\n<$wikify name=\\\"restfilter\\\" text=\\\"\\\"\\\"$(filter)$  +[has[$(field)$]] +[rest[<<next>>]limit[1]]\\\"\\\"\\\">\\n<$set name=\\\"proceed\\\" filter=\\\"[<next>prefix[-]]\\\" value=\\\"saveResult\\\" emptyValue=\\\"calculate\\\">\\n<$list filter=<<restfilter>> variable=\\\"tid\\\">\\n<$vars a=$startvalue$>\\n<$wikify name=\\\"b\\\" text='<$transclude tiddler=<<tid>> field=$(field)$/>'>\\n<$macrocall $name=<<proceed>> a=<<a>> b=<<b>> counter=<<next>>/>\\n</$wikify>\\n</$vars>\\n</$list>\\n</$set>\\n</$wikify>\\n</$wikify>\\n\\\\end\\n\",\n            \"title\": \"$:/plugins/telmiger/rpn/rpnFields\",\n            \"tags\": \"$:/tags/Macro\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20181111192120506\"\n        },\n        \"$:/plugins/telmiger/support\": {\n            \"created\": \"20200524081316557\",\n            \"text\": \"!! Support the Author\\n\\n''Hi!'' I’m Thomas, the author of [[tid.li/tw5/plugins.html|https://tid.li/tw5/plugins.html]]. Feedback is always welcome, as well as funding for maintenance, support and new projects :)\\n\\n---\\n\\n!!! One Time Support\\n\\nIf using my plugins just makes you happy, consider a one time payment via ~PayPal to reward the effort:\\n\\nhttps://www.paypal.me/telmiger\\n\\n---\\n\\n!!! Permanent Support\\n\\nIf my tools make you more productive or save you time in your job or your everyday life, you can support me as a Patron: \\n\\nhttps://www.patreon.com/telmiger\\n\\n---\\n\\n!!! Thank You\\n\\nSubstantial parts of my availabe time go to the deveopment of useful plugins for [[TiddlyWiki|https://tiddlywiki.com/]]. – Many others do the same and I would like to thank them all, especially [[Jeremy Ruston|https://tiddlywiki.com/#JeremyRuston]] and all the active members of the community!\\n\\n//Hereby I promise to share future revenues (if any) with other developers who’s works I use or who inspired me.//\\n\\nIf you like my work, I would be very happy to hear from you.\\n\\n''Thank you very much for your support!''<br>\\n//Thomas//\\n\\nhttps://thomas-elmiger.ch\",\n            \"title\": \"$:/plugins/telmiger/support\",\n            \"tags\": \"\",\n            \"modifier\": \"Thomas Elmiger\",\n            \"modified\": \"20200524081326998\",\n            \"creator\": \"Thomas Elmiger\"\n        },\n        \"$:/plugins/telmiger/rpn/support\": {\n            \"created\": \"20181111202222852\",\n            \"text\": \"{{$:/plugins/telmiger/support}}\",\n            \"title\": \"$:/plugins/telmiger/rpn/support\",\n            \"tags\": \"\",\n            \"modified\": \"20181111202349869\"\n        },\n        \"$:/plugins/telmiger/rpn/about\": {\n            \"created\": \"20200524154716663\",\n            \"modified\": \"20200524200003681\",\n            \"title\": \"$:/plugins/telmiger/rpn/about\",\n            \"text\": \"\\n//rpn// is a lightweight Javascript macro for basic math operations. It is inspired by formerly popular calculators using Reverse Polish Notation (see [[Wikipedia|https://en.wikipedia.org/wiki/Reverse_Polish_notation]] for more info). Usage example:\\n\\n`<<rpn 5000 200 * 2 p en-GB>>` output: <<rpn 5000 200 * 2 p en-GB>>\",\n            \"tags\": \"\"\n        }\n    }\n}",
            "type": "application/json",
            "author": "Thomas Elmiger",
            "core-version": ">=5.1.14",
            "created": "20170715124812734",
            "dependents": "",
            "description": "rpn – Basic Math in Reverse Polish Notation",
            "list": "readme usage examples fields support",
            "modified": "20200604183203914",
            "name": "rpn",
            "plugin-type": "plugin",
            "source": "https://tid.li/tw5/plugins.html",
            "title": "$:/plugins/telmiger/rpn",
            "version": "0.7.3"
        },
        "$:/plugins/telmiger/support": {
            "title": "$:/plugins/telmiger/support",
            "created": "20181103150753927",
            "creator": "Thomas Elmiger",
            "modified": "20200604183148066",
            "modifier": "Thomas Elmiger",
            "tags": "",
            "type": "text/vnd.tiddlywiki",
            "text": "!! Support the Author\n\n''Hi!'' I’m Thomas, the author of [[tid.li/tw5/plugins.html|https://tid.li/tw5/plugins.html]]. Feedback is always welcome, as well as funding for maintenance, support and new projects :)\n\n---\n\n!!! One Time Support\n\nIf using my plugins just makes you happy, consider a one time payment via ~PayPal to reward the effort:\n\nhttps://www.paypal.me/telmiger\n\n---\n\n!!! Permanent Support\n\nIf my tools make you more productive or save you time in your job or your everyday life, you can support me as a Patron: \n\nhttps://www.patreon.com/telmiger\n\n---\n\n!!! Thank You\n\nSubstantial parts of my availabe time go to the deveopment of useful plugins for [[TiddlyWiki|https://tiddlywiki.com/]]. – Many others do the same and I would like to thank them all, especially [[Jeremy Ruston|https://tiddlywiki.com/#JeremyRuston]] and all the active members of the community!\n\n//Hereby I promise to share future revenues (if any) with other developers who’s works I use or who inspired me.//\n\nIf you like my work, I would be very happy to hear from you.\n\n''Thank you very much for your support!''<br>\n//Thomas//\n\nhttps://thomas-elmiger.ch"
        }
    }
}