How does TW differentiate numbers from text? Also Mathematics operator syntax.

43 views
Skip to first unread message

Brad DeBruler

unread,
Mar 13, 2021, 11:43:17 AM3/13/21
to TiddlyWiki
Pretty basic question, I believe... I have been trying to get some plugin macros to work, and the output is NaN, which I am guessing means "not a number".

The plugin macros work if a number is put in the macro call, but when I try to transclude a field it gives NaN. The macro is supposed to output the raw score and a bonus based on the raw score. It's a Dungeons & Dragons thing if you aren't familiar.

<<dnd.ability 16>>           Gives correct output:          16 (+3)

<<dnd.ability {{!!dnd.creature.str}}>>          Gives:  NaN (−NaN)

{{!!dnd.creature.str}}        Correctly transcludes the field value:    16

Is there the something line an INT function that must be used to say this is an integer and not a string?


Also, I was simply pasting in some of the mathematics operator examples and they do not evaluate the expression. There is obviously something else I am missing:

[[23]add[19]]    gives      23]add[19

Thanks! 



Jeremy Ruston

unread,
Mar 13, 2021, 12:14:57 PM3/13/21
to TiddlyWiki Group
Hi Brad

Pretty basic question, I believe... I have been trying to get some plugin macros to work, and the output is NaN, which I am guessing means "not a number".

The plugin macros work if a number is put in the macro call, but when I try to transclude a field it gives NaN. The macro is supposed to output the raw score and a bonus based on the raw score. It's a Dungeons & Dragons thing if you aren't familiar.

<<dnd.ability 16>>           Gives correct output:          16 (+3)

<<dnd.ability {{!!dnd.creature.str}}>>          Gives:  NaN (−NaN)

{{!!dnd.creature.str}}        Correctly transcludes the field value:    16

Is there the something line an INT function that must be used to say this is an integer and not a string?

The macro call <<dnd.ability {{!!dnd.creature.str}}>> passes the literal string "{{!!dnd.creature.str}}” as the parameter to the macro, rather than evaluating it.

There’s a more flexible underlying syntax for calling macros where the parameters are evaluated before invocation:

<$macrocall $name="dnd.ability" paramName={{!!dnd.creature.str}}/>

Where “paramName” is the name of the parameter to your macro.

Also, I was simply pasting in some of the mathematics operator examples and they do not evaluate the expression. There is obviously something else I am missing:

[[23]add[19]]    gives      23]add[19

Pasting [[23]add[19]] is interpreted as a link to a tiddler titled “23]add[19” because filter expressions are only evaluated in certain contexts, notably triple curly braces. Try:

{{{ [[23]add[19]] }}}

Best wishes

Jeremy


Thanks! 




--
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 tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5329b09b-2498-450f-b980-a31a8d7403a7n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages