\define buttonmacro(countUp)
<$button style="background-color:White; width:100%; height:100%" >"""
Button Caption $countUp$
"""</$button>
\end
<$macrocall $name=repeatmacroxv3 targetMacro=buttonmacro x=3 />/*\
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;
};
})();\define buttonmacro(countUp caption1 caption2)
<$button style="background-color:White; width:100%; height:100%" >"""
Button $caption1$ $caption2$ $countUp$
"""</$button>
\end
\define buttonmacro2(countUp caption1 caption2)
<$button style="background-color:White; width:100%; height:100%" >"""
Button $caption1$ $caption2$ $countUp$
"""</$button>
\end
\define interimmacro(countUp caption1 caption2)
<$macrocall $name=repeatmacroxv4 targetMacro=buttonmacro2 x=$countUp$ parameterPassing="$caption1$ $caption2$"/>
\end
<$macrocall $name=repeatmacroxv4 targetMacro=buttonmacro2 x=3 parameterPassing="Buttons Words"/>
<<interimmacro 4 Dog Cat>>/*\
title: $:/_my/macros/repeatmacroxv4.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 = "repeatmacroxv4";
exports.params = [
{name: "targetMacro"},
{name: "x"},
{name: "parameterPassing"}
];
/*
Run the macro
*/
exports.run = function(targetMacro,x,parameterPassing) {
var i;
var result;
for (i = 0; i < x; i++) {
if (i == 0) {
result = "<<" + targetMacro + " " + String(i + 1) + " " + parameterPassing + ">>";
} else {
result += "<<" + targetMacro + " " + String(i + 1) + " " + parameterPassing + ">>";
}
}
return result;
};
})();\define buttonmacro3(countUp param1 param2)
<$button style="background-color:White; width:100%; height:100%" >"""
$param1$ $param2$ $countUp$
"""</$button>
\end
\define interimmacro2(countUp caption1 caption2)
<$macrocall $name=repeatmacroxv5 targetMacro=buttonmacro3 x=$countUp$ parameterPassing="param1=$caption1$ param2=$caption2$"/>
\end
<$macrocall $name=repeatmacroxv5 targetMacro=buttonmacro3 x=3 parameterPassing="param1=Buttons param2=Words"/>
<<interimmacro2 4 Dog Cat>>
<<interimmacro2 2 Moose Squirrel>>/*\
title: $:/_my/macros/repeatmacroxv5.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 = "repeatmacroxv5";
exports.params = [
{name: "targetMacro"},
{name: "x"},
{name: "parameterPassing"}
];
/*
Run the macro
*/
exports.run = function(targetMacro,x,parameterPassing) {
var i;
var result;
for (i = 0; i < x; i++) {
if (i == 0) {
result = "<$macrocall $name=" + targetMacro + " countUp=" + String(i + 1) + " " + parameterPassing + " />";
} else {
result += "<$macrocall $name=" + targetMacro + " countUp=" + String(i + 1) + " " + parameterPassing + " />";
}
}
return result;
};
})();My favorite repeater is the list widget:
\define buttonmacro(countUp, caption)
<$button style="background-color:White; width:100%; height:100%" >
"""
Button $caption$ $countUp$
"""</$button>
\end
<$list filter="[enlist[1 2 3]]" variable="nr">
<$macrocall $name="buttonmacro" countUp=<<nr>> caption="c" />
</$list>
Does that work for you?
Cheers,
Thomas
We now have the range operator as well.
List is to me the key to tiddlywiki because through it and filters its all about sets, sets of tiddlers, tags, fields or any other list.
It is for all or for each we use list to repeat anything macro or otherwise.
Regards
Tony