Neil,
I finally figured out what I was doing wrong and, though I suspect the
majority of folks here already know about this, I'll share what I've found.
Perhaps it will help someone avoid my aggravation. Perhaps someone will
correct me if I’m misinterpreting what is happening.
I'm working with javascripts that involve several input parameters.
Tiddlywiki has two ways to invoke a macro or javascript with parameters;
the $macrocall widget and the form: <<mysamplemacro "Mickey Mouse" "Mouse
House">>. Unlike the sample in the documentation, I was trying to pass the
numerical contents of a field in the tiddler to the javascript macro. I had
a line that looked something like this:
> <<sweat {{!!startweight}} {{!!finishweight}}>>
>
To test that the javascript routine "sweat" was actually getting my
parameters, I set the output line to:
> return “sweight = “+sweight+” : fweight = “+fweight;
>
In my case the calling tiddler showed what returned as:
> sweight = 180 : fweight = 175
>
Those numbers are correct. However attempting to perform any type of
mathematic operation would fail and
> a = sweight * 1.0;
>
> return “sweight = “ + a;
>
would return
> sweight = NaN.
>
That was what was irritating me until I finally figured out what was going
on. What Tiddlywiki was sending to the javascript routine wasn’t the
transcluded field but the transclusion command. The javascript routine
wasn’t seeing 180. It was seeing {{!!startweight}}. What was coming back
from the javascript routine, before Tiddlywiki translated it for the
screen, was:
> sweight = {{!!startweight}} : fweight = {{!!finishweight}}
>
Then Tiddlywiki transcluded the fields and showed them on the screen. Since
the Javascript routine had the strings which it couldn’t convert to
numbers, the result of any math operation was NaN, Not a Number.
This command
<$macrocall $name=”sweat” sweight={{!!startweight}}
> fweight={{!!finishweight}}>
>
on the other does work as anticipated. Though it seems a bit clunky, I’m
working exclusively $macrocall when sending fields to javascript routines.
--
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 http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.