List Range: Produce Output in a Specified Range

This is a simple macro to generate output for a filter in a specified range! For example if your filter produces 100 output, you can call macro to display only output 10 to 20.

Use case: make a simple pagination macro!

Code and Demo

  1. Open https://tiddlywiki.com/prerelease/
  2. Create a new tiddler tagged it with $:/tags/Macro
  3. Put the below script as its text
\define list-range(filter, lower, upper)
<$list filter=<<__filter__>>  counter=n>
<$list filter="""
 [<n>compare:integer:gteq[$lower$]] 
 :intersection[<n>compare:integer:lteq[$upper$]]""" variable=null> 
<$text text={{{ [<n>pad[3]addsuffix[. ]] }}}/><$link/><br>
</$list>
</$list>
\end
  1. Save

Example

Display output 10-20 of tiddlers tagged with [tag[Filter Operators]] and sorted by title.

  1. Create a new tiddler
  2. Call list-range as below
<<list-range filter:"[tag[Filter Operators]sort[title]]" lower:10 upper:20>>

Produces

  1. append Operator
  2. asin Operator
  3. atan Operator
  4. atan2 Operator
  5. average Operator
  6. backlinks Operator
  7. before Operator
  8. bf Operator
  9. butfirst Operator
  10. butlast Operator
  11. ceil Operator

Improvement

  1. Propose other simple filters
  2. Produce the result using one $list widget
5 Likes

Instead of lb and rb, make the parameters (attributes) more meaningful.

Other than that, cool macro! :medal_sports:

The original post updated to address @CodaCoder comment.

lb → lower (bound)
rb → upper (bound)

1 Like