[TW5] Feature request: Use variables in Range Operator

35 views
Skip to first unread message

Thomas Elmiger

unread,
Dec 15, 2018, 4:29:06 AM12/15/18
to TiddlyWiki
Would it be possible to modify the range operator so it also accepts variables as <begin>, <end> or <step> parameters?

I tried to do the following and had to learn that the range filter does not accept variables as number parameter, neither <variable> nor <<variable>>:

<$wikify name="max" text="{{{ [list[$:/StoryList]tag[Figures]count[]] }}}">
<$set name="range" filter="[range[1,
<max>]]">

...

</$set>
</$wikify>


Every variant I tried resulted in an error message like: range: bad number "<max>"

So I had to resort to a workaround wikifying a whole filter:

<$wikify name="all" text="[range[1,{{{ [list[$:/StoryList]tag[Figures]count[]] }}}]]">
<$set name="range" filter=<
<all>>>

...

</$set>
</$wikify>

Many thanks for the great new range operator anyway!
Thomas

BurningTreeC

unread,
Dec 15, 2018, 4:38:24 AM12/15/18
to TiddlyWiki

Hi Thomas, I'd also come to this point recently, but there's a workaround taking the text-substitution road:


\define wikify-range()
<$wikify name="all" text="[range[1,$(rangeValue)$]]">

<$set name="range" filter=<<all>>>

...

<
/$set>
</
$wikify>Code hier eingeben...
\end
<$set name="rangeValue" value=
{{{ [list[$:/StoryList]tag[Figures]count[]] }}}>
<<wikify-range>>
</
$set>

The range operator is awesome :)
Reply all
Reply to author
Forward
0 new messages