Hey, Tony —
I might have been a little terse in documenting the logical functions.
The IF function chooses between its second and third arguments based on the
first. For example,
if({{!!x}}<1, "x is less than 1", "x is more than 1")
The second and third argument can be whatever sort of date you like.
Instead of strings they could be transclusions, or other functions or
complicated bits of math.
IFS basically works like "if (arg1) {return arg2} else if (arg3) {return
arg4} else if (arg5) {return arg6} else return undefined". The
odd-numbered arguments should be booleans and the even-numbered arguments
can be whatever you like. So this would be fine:
ifs(and({{!!x}} > {{!!y}}, {{!!x}} > {{!!z}}), "x is biggest", ({{!!y}} >
{{!!z}}), "y is biggest", TRUE, "z is biggest");
Though it would be the same as:
if(and({{!!x}} > {{!!y}}, {{!!x}} > {{!!z}}), "x is biggest", if({{!!y}} >
{{!!z}}, "y is biggest", "z is biggest"));
Anyway, all the logic functions are designed to work like their
(better-documented) analogs in Excel and Google Sheets.
* (Notably, formula currently uses javascript rules when determining
whether to treat numbers and strings as "true" or "false". So zero and
empty strings are falsy, while non-zero numbers and non-empty strings are
truthy. I can't guarantee this behavior will continue to be the case, as
it might be different from how spreadsheet software does things.)
On Saturday, 16 December 2017 20:02:28 UTC-6, TonyM wrote:
>
> Evan,
>
> Please forgive my Ignorance; What can a and b be equal to in Formulas'
> logical functions, like IF and IFS?
>
> I am thinking if something evaluates to true how do I use this to
>
> - list
> - transclude
> - Use macro
> - Show some text etc...
> - Set a variable/field
>
>
> I imagine there is a way to write a list filter if a formula it true to
> show when true (or False) etc...
>
> I expect knowing this may help the less sophisticated users (still me at
> this point) make use of formula.
>
> Thanks in Advance
> Tony
>
> On Sunday, 17 December 2017 12:41:19 UTC+11, Evan Balster wrote:
>>
>> Hey, Tony —
>>
>> I'm not an impatient reader. :)
>>
>> I've added a Date type in my working copy, based on JavaScript's built-in
>> Date (which is reasonably feature-rich). TiddlyWiki has some functions for
>> date formatting in core, too. Libraries like moment.js offer a "kitchen
>> sink" of features but I'm not sure if that's necessary at the moment.
>>
>> Probably my next step will be to add a basic date parser and some utility
>> functions (convert timestamps, convert with string, construct and decompose
>> dates).
>>
>> *Is there value sharing what I find, or do you have it covered?*
>>>
>>
>> If you find something interesting, sure, share it. But given that
>> there's standardized support for basic date processing in JavaScript itself
>> I'm going to try to steer clear of libraries.
>>
>> *May I ask how you use the results TRUE and FALSE in wikitest once
>>> calculated?*
>>>
>>
>> Right now, the best use of these is in Formulas' logical functions, like
>> IF and IFS. In the future I might implement a $formula-if widget that
>> works a little like the reveal widget.
>>
>> Expect a new update tomorrow or so.
>>
>>
>>
>> On Saturday, 16 December 2017 19:17:24 UTC-6, TonyM wrote:
>>>
>>> Evan,
>>>
>>> Very exciting, date manipulation is timely for me, rather than wait I
>>> will look into some existing options. *Is there value sharing what I
>>> find, or do you have it covered?*
>>>
>>> On multidimensional, I am not so much looking for array manipulation.
>>> Tiddlywiki and your solution already meets my requirements. Imagin a large
>>> 2d spreadsheet with 3 columns containing unique keys (or missing keys) even
>>> including date/time. If you choose a key and sort on it before you
>>> manipulate a 2D array you are effectively looking at the data in another
>>> dimension. This is very easy for TiddlyWiki.
>>>
>>> *May I ask how you use the results TRUE and FALSE in wikitest once
>>> calculated?*
>>>
>>> Do you use it in filters etc?
>>>
>>> Regards
>>> Tony
>>>
>>> On Sunday, 17 December 2017 03:20:17 UTC+11, Evan Balster wrote:
>>>>
>>>> Question: do you have or are you planning any rounding or averaging
>>>>> functions?
>>>>
>>>>
>>>> There are rounding functions in there now. See "Functions" and
>>>> "FormulaWidget" in the doc wiki. No averaging yet, but that's a popular
>>>> function I'll replicate at some point soon. (My last round of functions
>>>> was ).
>>>>
>>>> I did find that the rounding functions fail when a second parameter is
>>>>> provided, so I submitted an issue on Github.
>>>>
>>>>
>>>> Ah, I'll fix those then. Good catch.
>>>>
>>>>
>>>> I am very interested in "Multidimensional" arrays.
>>>>
>>>>
>>>> From what I can tell Excel and Sheets can do 1D and 2D arrays, and
>>>> these may be internally represented as selection sets. Anyway, there's a
>>>> lot of flexibility in what "value" types could be added (especially with
>>>> extensions) but I'll probably imitate spreadsheet conventions and
>>>> functions
>>>> to begin with.
>>>>
>>>>
>>>> One question: Could this be made to work with date and time?
>>>>
>>>>
>>>> Yes, I'll be adding support for a date/time datatype. There's a long
>>>> history of date/time functionality in Excel/Sheets and there are some
>>>> standard TiddlyWiki/javascript functions that can be built upon.
>>>>
>>>>
>>>> Reverse polish notation https://tid.li/tw5/hacks.html
>>>>
>>>>
>>>> Useful reference. Before I was driven to implement this plugin I
>>>> experimented various macro-based solutions (including some homemade ones).
>>>>
>>>> I even have an accounting wiki built around a sum macro. It was my
>>>> conclusion that the $set/$vars/$macrocall boilerplate makes recursive JS
>>>> macros a bit too unwieldy compared to a dedicated formula syntax. A
>>>> widget
>>>> also has more potential for caching/optimization/efficiency in the long
>>>> term.
>>>>
>>>>
>>>>
>>>> On Saturday, 16 December 2017 04:29:18 UTC-6, [email protected] wrote:
>>>>>
>>>>> This looks very good, especially since it is incredibly easy to set up
>>>>> and use! One question: Could this be made to work with date and time?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Stef
>>>>>
>>>>> On Friday, December 15, 2017 at 5:37:26 AM UTC+1, Evan Balster wrote:
>>>>>>
>>>>>>
>>>>>> Introducing the *Formula plugin*:
>>>>>> http://evanbalster.com/tiddlywiki/formulas.html (version 0.1.0 at
>>>>>> time of posting)
>>>>>>
>>>>>>
>>>>>>
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/5ac2208e-27b3-4c98-aed6-0ea4c908e3b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.