Injecting the result or a macro into another macro. (At least I think that's what i'm trying to do)

107 views
Skip to first unread message

Stephen Wilson

unread,
Jun 13, 2017, 9:53:08 AM6/13/17
to TiddlyWiki
Ok.

I'm using the mathcell plugin/ macro to generate a random number between 1 and 10

<$macrocall $name="eval1" datatiddler="Data" cell="Random"/>

The cell contains the following javascript 
=Math.floor((Math.random() * 10) + 1);

I need the result of this to be called into the following:

\define mylatex(a,b)
<$latex text="{$a$}+{$b$}" displayMode="true"></$latex>
\end
<$macrocall $name="mylatex" a={{!!Random}} b={{!!Random}}

Do I need to set a and b as macrocall eval1 in the define section or is there a way to place the output of eval1 into the space currently occupied by {{!!Random}} and is there a beter way to get a random number?

Cheers

Stephen

Mark S.

unread,
Jun 13, 2017, 12:04:11 PM6/13/17
to TiddlyWiki
I'm not familiar with the latex plugin, so I don't know if your mylatex macro is set up correctly. Assuming that it is, then I think you need to invoke it like:

<$macrocall $name="mylatex" a=<<eval1 datatiddler:"Data" cell:"Random">>  b=<<eval1 datatiddler:"Data" cell:"Random">>  >

Good luck!
Mark
Message has been deleted

Stephen Wilson

unread,
Jun 14, 2017, 5:20:12 AM6/14/17
to TiddlyWiki
Hi Mark,
Thanks for the help.
Unfortunately that returns 

<$latex text="{7}+{1}" displayMode="true"></$latex>

in the view pane.  Transcluding from another tiddler yields similar results and putting the eval in a field and transcluding from there, the same.

I had already tried your solution but assumed the fault was mine, so it's nice to know it wasn't just me :)

Back to the drawing board,

Stephen

Mark S.

unread,
Jun 14, 2017, 10:14:38 AM6/14/17
to TiddlyWiki
You're going to need a recent version of TW5. Then define your macro like this:

\define mylatex(a,b)
<$wikify name="doit" text="""
<$latex text="
{$a$}+{$b$}" displayMode="true"></$latex>""" >
<<doit>>
</$wikify>
\end


Worked on my set-up.

Good luck!
Mark

Stephen Wilson

unread,
Jun 14, 2017, 10:20:49 AM6/14/17
to TiddlyWiki
Wow...
Right...now to have a tinker and find the next road block.

Thank you.

Stephen
Reply all
Reply to author
Forward
0 new messages