Parsing the list of tags of the current tiddler to apply a regex on it

56 views
Skip to first unread message

vpl

unread,
Dec 20, 2018, 10:19:30 AM12/20/18
to TiddlyWiki
Hi,

I would like to assign a tiddler field a sub set of tags of the current tiddler
Ex:
My current tiddler has 3 tags: done, current, started
I want to assign to the field state one of these 3 tags (using a regexp)

For that I've first tried to assign the list of current tiddler tags to a variable with the hope to be able to apply a regex on this variable ....

<$set name="myVariable"  value={{!!tags}}>
<$text text=<<myVariable>>/>
</$set>

Works fine, but how to apply now a regex on this myVariable such as I can set the result to my target field ?

Thanks for your lights !

Regards

Vpl

Mark S.

unread,
Dec 20, 2018, 11:35:30 AM12/20/18
to TiddlyWiki
It is often more useful to explain what you want to do, rather than look for a narrow technical solution. TW macros and tools don't work the way you might expect, coming from some other programming language background. For instance, why would you apply a reg exp to a variable holding a list of tags? I'm guessing that you want to apply one of 3 tags based on some other condition within the tiddler (perhaps other tags, fields, or title). If we understood your intentions better, it would be easier to help.

In an event, in all cases where you want to make physical changes to one or more tiddlers, you will need a message-handling widget such as the ButtonWidget, SelectWidget, RadioButton, etc. And inside of the <$button> or other widget you will need an "actions" attribute that uses a set of ActionSendMessage, or ActionSetField or similar action widgets.

Good luck!
-- Mark

TonyM

unread,
Dec 20, 2018, 7:45:59 PM12/20/18
to TiddlyWiki
Vpl,

I want to second what Mark is asking. I suspect you are a long way down a solution path, yet the problem is most likely a conceptual one at a higher level. 

Personally I no longer set status flags/tags or fields because when they change you have to remove previous values. Instead I prefer to determine the status at any point in time using other information on a tiddler.

For example I have item-started item-completed and item-cancelled on each task tiddler. Each of these fields can be date/time stamped when started completed or cancelled 
  • It is new if item-started exists without a value (and not completed/cancelled)
  • It is work in progress if it item-started is date stamped (and not completed/cancelled)
    [all[current]has[item-started]!has[item-completed]!has[item-cancelled]]
  • It is inactive it date stamped completed/cancelled
I have now taken this much further such as allowing item-started at a future date to schedule its start later and a lot more.

PS The "has[fieldname]" operator asks if a field is present and has a value, and the "has:field[fieldname]" asks if a field is present (can be empty)

Regards
Tony
Reply all
Reply to author
Forward
0 new messages