Tiddly Novice,

Thanks for sharing with the community. I am a Super User rather than a Java 
script writer. So it is not as meaningful to me as it would to others. 
However If a knew better what you wanted to do from the get go, I could 
more than likely do it in WikiText/Macros. 

If you want to post your desired solution, I would be happy to have a go to 
illustrate the possibilities, or even a way to simplify your javascript and 
make it more versatile.

Regards
Tony



On Saturday, 19 January 2019 08:06:53 UTC+11, Tiddly Novice wrote:
>
> Been having a lot of fun learning TiddlyWiki and relearning Java, but I've 
> hit another wall. I need a way to repeat macros a number of times. I don't 
> know ahead of time what those macros will be, how many times they'll need 
> to be repeated, how many parameters the repeated macro will have, and what 
> those parameters will be called. So far, I think I've managed to handle the 
> first two unknowns (which macro and how many repeats) but I'm stumped on 
> how to deal with the other two parts (how many parameters and what they're 
> called).
>
> Here's the code for the Tiddler I've written so far:
>
> \define buttonmacro(countUp)
> <$button style="background-color:White; width:100%; height:100%" >"""
> Button Caption $countUp$
> """</$button>
> \end
>
>
> <$macrocall $name=repeatmacroxv3 targetMacro=buttonmacro x=3 />
>
>
> And here's the javascript macro I've written so far:
>
> /*\
> title: $:/_my/macros/repeatmacroxv3.js
> type: application/javascript
> module-type: macro
>
> Macro to return a macro multiple times
> \*/
> (function(){
>
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> /*
> Information about this macro
> */
>
> exports.name = "repeatmacroxv3";
>
> exports.params = [
>  {name: "targetMacro"},
>  {name: "x"}
> ];
>
> /*
> Run the macro
> */
> exports.run = function(targetMacro,x) {
>  var i;
>  var result;
>  for (i = 0; i < x; i++) { 
>     if (i == 0) {
>       result = "<<" + targetMacro + " " + String(i + 1) + ">>";
>     } else {
>       result += "<<" + targetMacro + " " + String(i + 1) + ">>";
>     }
>  }
>  return result;
> };
>
> })();
>
>
> My instincts are telling me to try using lists somehow to pass the 
> parameters to the javascript and maybe seeing if the javascript can check 
> what the macro to be repeated wants for parameters. But I'm not sure that's 
> the best way. In fact, I feel like this is something that would have been 
> so commonly needed that someone would have already made a plug-in or macro 
> for this situation already. But I can't seem to find it, probably because I 
> haven't found the right search terms.
>
> So my questions are:
> 1. Has someone made a generalized macro repeater already, and if so, where 
> can I get it from?
> 2. If a generalized macro repeater doesn't already exist, how what is the 
> best way to create 
>

-- 
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/94581082-844c-4082-8eb0-9505e86a1536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to