/* comments */
in the C/JavaScript style.join
function, which is simpler than textjoin
.transclude_index
function.Announcing the second generation of my formula plugin for TiddlyWiki.See the Formula wiki for the latest documentation: http://evanbalster.com/tiddlywiki/formulas.html
You also should consider, to switch those plugins, that you want to be part of the TiddlyWiki core, to be "BSD 3 clause"
I'm wondering if you'd be okay if I started another thread about developing examples of usage? Not necessarily for you to answer on but also other folk who are developing grasp of what it can do?
It would be very useful for all potential plugin authors present and future to please include an up to date license for your works. It really helps and it is super important I believe. This probably deserves its own thread. Apologies.
Don't know if your aware, or if it's useful, but Matt did some graph work last year.
Just wondering, has IFERROR been implemented yet?
match
is present on the tiddler, text is instead expected to render to the same result as rendering match
.FormulaTest/Regression/<Test Name>
FormulaTest/Functions/<Function Name>/<Test Name>
FormulaTest/Feature/<Feature Name>/<Test Name>
FormulaTest/Compiler/<Feature Name>/<Test Name>
FormulaTest/Misc/<Test Name>
\define updateActions(newVal)
<$action-setfield $field="t1" $value="0"/>
<$action-setfield $field="t2" $value=$newVal$/>
<$action-setfield $field="t3" $value=(=3+1=)/>
<$action-setfield $field="t4" $value=(={{!!t3}}+20=)/>
\end
<$button actions=<<updateActions 10>> >
Do it!
</$button>
<$button >
<$formula-vars val1="2+3" val2="<<val1>>+6" val3="{{!!t2}}+12">
<$action-setfield $field="t1" $value=<<val1>>/>
<$action-setfield $field="t2" $value=<<val2>>/>
<$action-setfield $field="t3" $value=<<val3>>/>
</$formula-vars>
Do it!
</$button>
<$setvars
_attr1=<<currentTiddler>>
_attr2={{!!title}}
_attr3="1 2 3"
_attr4="[all[current]tagging[]]"
var1="attr1 \ = literal = \ attr2"
var2="attr3[n] \ \ [attr4[1,2][when-empty]] \ \ [attr3[][][ - ]]"
var3="if(attr1 ? [attr4]) || attr3 attr2"
var4="if(attr1 == attr2 ? attr3[1]) || [attr3[2]]">
* <<var1>>
* <<var2>>
* <<var3>>
* <<var4>>
</$setvars>
<$button >
<$formula-vars val1="2+3">
<$action-setfield $field="t1" $value=<<val1>>/>
<$formula-vars val2="<<val1>> + 10">
<$action-setfield $field="t2" $value=<<val2>>/>
<$formula-vars val3="<<val2>> + 100">
<$action-setfield $field="t3" $value=<<val3>>/>
</$formula-vars>
</$formula-vars>
</$formula-vars>
Do it!
</$button>
<$formula-vars $dict="""
dict(
t1 = 0,
t2 = <<newVal>>,
t3 = 3+1,
t4 = t3+20)
""">
...
</$formula-vars>
That would look something like this:
<$formula-vars $dict="""
dict(
t1 = 0,
t2 = <<newVal>>,
t3 = 3+1,
t4 = t3+20)
""">
...
</$formula-vars>
At which point the primitive objects usable in formulas start to look a lot like JavaScript's! Hashmaps (aka "objects" aka "dictionaries") are useful for lots of things...
<$formula-vars $thing="""
json {
t1: 0,
t2: <<newVal>>,
t3: 3+1,
t4: t3+20}
""">
...
</$formula-vars>
json({{MyJsonTiddler}})
{1, 2, 3; 4, 5, 6; 7, 8, "fish"}
\define daystoday(datefield) (= days( now(), date( {{!!$datefield$}} ) ) =) \end
In short it seems to no longer tolerate empty fields
Nor handle dates the same way,
Any suggestions from your intimate knowledge?
Thanks
Tony
/* block comments */
. // line comments
also work./regex/g
\define daystoday(datefield)
(= days( now(), date( {{!!$datefield$}} ) ) =)
\end
Other examples, It is fine for these to return nothing
(= if(tw_date({{!!$datefield$}})=now(),"Today","Not Today") =)
\define showtodayrange(datefield1,datefield2)
<progress value=<<formula "days( date( {{!!$datefield1$}} ) , now() )">> max=<<formula "days( date( {{!!$datefield1$}} ) , date( {{!!$datefield2$}} ))">>/>
\end
<$if value=(={{!!$datefield$}}=)>
Has value (=date({{!!$datefield$}})=)
<$set name=indate value= (=date({{!!$datefield$}})=)>
</$if>
<$else>
No Value (={{!!$datefield$}}=)
<$set name=indate value=(=now()=)>
</$else>
The above also seems broken, using The Condition plugin for TiddlyWiki, version 0.1.0 (disabled or not)
So I suppose I am asking, "can the treatment of empty or blank date fields be restored?", or could you "tell me a way to treat such fields to avoid the errors?"
Thanks in advance,
Tony
BurningTree — that's a nice looking spreadsheet UI. Consider your experimentation encouraged!
len(trim(x))==0
{1, 2, 3, "fork"}
.array
constructor function (added in 0.2.2 but undocumented)$
absolute references (does not affect formula behavior)(= divide( {{!! total_presencas}} , {{!! total_integrantes}} ) =)
(= [tag{!!grupo}tagging[]has[Presenças]count[]] / [tag{!!grupo}tagging[]count[]] =)
Announcing the second generation of my formula plugin for TiddlyWiki.See the Formula wiki for the latest documentation: http://evanbalster.com/tiddlywiki/formulas.htmlReport issues and view source GitHub: https://github.com/EvanBalster/TiddlyWikiFormulaFormula lets you do computation in TiddlyWiki in the style of popular spreadsheet apps Excel and Google Sheets, with the addition of TiddlyWiki's own filter, transclude and variable systems. Tiddlers can behave like individual rows in a spreadsheet. A large collection of built-in functions is included, for use with text, numbers, dates, arrays and regular expressions.Formula is implemented as a widget, with a special (= "mushroom bracket" =) syntax for inclusion in WikiText, and can also be used in widget/HTML attributes. Formulas included via transclusion, filters and variables are computed and refreshed like any other part of your wiki.(= ( sum([tag[Profits]get[value]]) - sum(tag[Expenses]get[value]]) ) * {{Tax!!rate}} =)The second generation of formula adds support for local variables, comments, lambda functions and element-wise operations on arrays (such as filter results), allowing more advanced computations to be expressed inside TiddlyWiki. Search the wiki for "demo" to see some of the things I've built.The plugin is a work in progress and may have bugs. Please report these on GitHub or in this thread.
I've just discovered Formulas and I'm enjoying its straightforward crunching. Thank you so much for making this awesome plugin! I'd like to make a tiddler that shows the overall "feeling score" of a food logging database by counting the number of results for each mood (bad, decent, good). Then, I'd find the average of their weighted values: (bad * -1 + decent * 1 + good * 2) / totalEntries.
Choose a month:<$select field="month"> <$list filter="January February March April May June July August September October November December" variable="month"> <option><<month>></option> </$list></$select>
<$vars bad={{{ [tag[FoodLog]tag{!!month}tag[bad]count[]multiply[-1]] }}} decent={{{ [tag[FoodLog]tag{!!month}tag[decent]count[]multiply[1]] }}} good={{{ [tag[FoodLog]tag{!!month}tag[good]count[]multiply[2]] }}} entries={{{ [tag[FoodLog]tag{!!month}count[]] }}}>
There are <<entries>> items in {{!!month}},with an overall feeling score =<$text text={{{ [<bad>add<decent>add<good>divide<entries>multiply[1000]trunc[]divide[1000]] }}}/>
Good:<br><$list filter="[tag[FoodLog]tag{!!month}tag[good]sort[]]" ><li><<currentTiddler>></li></$list>Decent:<br><$list filter="[tag[FoodLog]tag{!!month}tag[decent]sort[]]"><li><<currentTiddler>></li></$list>Bad:<br><$list filter="[tag[FoodLog]tag{!!month}tag[bad]sort[]]" ><li><<currentTiddler>></li></$list>
"Hotdogs" tags="FoodLog, July, good"
"Ice Cream" tags="FoodLog, July, good"
"Jello" tags="FoodLog, July, decent
"Potato Salad" tags="FoodLog, July, bad"
"Watermelon" tags="FoodLog, July, good"
Choose a month:
There are 5 items in July, with an overall feeling score = 1.2
Good:Decent:
- Hotdogs
- Ice Cream
- Watermelon
Bad:
- Jello
- Potato Salad