DataTiddlers. Delete properties depending its value

75 views
Skip to first unread message

Luis Gonzalez

unread,
Sep 17, 2019, 5:18:42 AM9/17/19
to TiddlyWiki
I have a wiki to manage a warehouse and a datatiddler with all the things:

mouse: 2
keyboard: 5
monitor: 8
flopy: 0
LPT-printer: 0
etc
etc
etc
...


I want to clean this datatiddler deleting all properties with a value of 0. They are obsolete things.


I can show this 0-properties with this code:

<$list filter="[[$:/Luis/warehouse]indexes[]]">
<$set name="val" filter="[[$:/Luis/
warehouse]getindex<currentTiddler>]">
<$list filter="[<val>match[0]]" variable="otra">
<<currentTiddler>>: <<val>><br/>
</$list>
</$set>
</$list>


But, how can I loop over all zero-properties to delete them from the warehouse data-tiddler?

TonyM

unread,
Sep 17, 2019, 5:59:07 AM9/17/19
to TiddlyWiki
Your last sentence contradicts the second sentence.

I believe you need to use action setfield with no value. Untested by me.

Regards
Tony

Mohammad

unread,
Sep 17, 2019, 9:21:46 AM9/17/19
to TiddlyWiki
Hi Luis,

This is one solution!

\define deleteIdx()
<$button class="tc-btn-invisible tc-tiddlylink">&#10005;
<$action-setfield $tiddler="$:/Luis/warehouse" $index=<<currentTiddler>> />
</$button>
\end

<$list filter="[[$:/Luis/warehouse]indexes[]]">
<$set name="val" filter="[[$:/Luis/warehouse]getindex<currentTiddler>]">
<$list filter="[<val>match[0]]" variable="otra">
<<currentTiddler>>: <<val>> <<deleteIdx>><br/>
</$list>
</$set>
</$list>



--Mohammad

Luis Gonzalez

unread,
Sep 17, 2019, 10:13:38 AM9/17/19
to TiddlyWiki

ok. This is a good solution but I need a new macro than automatically loop over all properties and delete them if they are 0

Mohammad Rahmani

unread,
Sep 17, 2019, 10:32:13 AM9/17/19
to tiddl...@googlegroups.com
Simply put the button before list widget
With setactionfielf where you display index value

On Tue, Sep 17, 2019, 6:43 PM Luis Gonzalez <kew...@gmail.com> wrote:

ok. This is a good solution but I need a new macro than automatically loop over all properties and delete them if they are 0

--
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 tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/bfd3210d-fb0a-4b36-b2f1-03e65e93c071%40googlegroups.com.

Mohammad

unread,
Sep 17, 2019, 4:18:42 PM9/17/19
to TiddlyWiki
Hi Luis,
 This is a complete solution as a set of macro!

\define deleteIdx()
<$button class="tc-btn-invisible tc-tiddlylink">&#10005;
<$action-setfield $tiddler=<<__dataTiddler__>> $index=<<idx>> />
</
$button>
\end

\define deleteAllzeros()
<$button>Delete all &#10005;
<$list filter="[<__dataTiddler__>indexes[]]" variable=idx>
<$list filter="[<__dataTiddler__>getindex<idx>match[0]]" variable="zidx">
<$action-setfield $tiddler=<<__dataTiddler__>> $index=<<idx>> />
</
$list>
</$list>
</
$button>
\end

\define show-idx-val(dataTiddler)
<<deleteAllzeros>><br>
<$list filter="[<__dataTiddler__>indexes[]]" variable=idx>
<$list filter="[<__dataTiddler__>getindex<idx>match[0]]" variable="zidx">
<<idx>>: 0 <<deleteIdx>><br/>
</$list>
</
$list>
\end


<<show-idx-val "$:/Luis/warehouse">>



Luis Gonzalez

unread,
Sep 18, 2019, 2:38:15 AM9/18/19
to TiddlyWiki
I couldn't imagine that you can put an action widget inside a list widget. I thought that a list widget is only for show a list of tiddlers.

Thanks!!.

My goal is to be as good with tiddlywiki as you.


Reply all
Reply to author
Forward
0 new messages