Hi all,

I whipped up a filter that returns a progressive count up to the number 
specified. No actual Tiddlers returned, just numbers.

This allows an iterative loop of anything within a list, a set number of 
times. For instance:

<$list filter="[numberOfItems[5]]">
  <$button>Button #<<currentTiddler>>
    <$action-dosomething ... />
  </$button>
</$list>

would give you 5 buttons [1] [2] [3] [4] [5] with their associated actions.

<$list filter="[numberOfItems[3]]">
  <$action-sendmessage $message="tm-new-tiddler" title=<<currentTiddler>>/>
</$list>

would create 3 new Tiddlers, "1", "2", and "3".

There's minimal error checking right now. If you say numberOfItems[0] it 
will return nothing, rather than 1 result called "0". It counts properly 
from 1 rather than from 0. That's about it!!

I'd be happy to have someone expand on this. If someone's already done it, 
I'd love to see - I've missed it.

Code:

exports.numberOfItems = function(source,operator,options) {
    var results = [];
    //source(function(tiddler,title) {
      if (operator.operand != "" && operator.operand !="0") { 
        var operandCount;
        for (operandCount = 0; operandCount < parseInt(operator.operand); 
operandCount++) { 
          results.push(String(operandCount+1));
        } 
      }      
    //});
    return results;
};


JSON Tiddler attached.

Cheers,
David.


-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" 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/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/14696a6d-bfd3-4754-af92-cd9d6193d1bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: filter-numberOfItems.json
Description: application/json

Reply via email to