Folks,
This question may be from a place of ignorance, however can you tell me why it appears fields can only be set from inside a triggering process such as a button?
No need to go into DOM trees and All that, I understand that at a high level.
I was wondering if there is a reason I can NOT set a value in a tiddlers field using a macro, list, set or other method if only when a tiddler is rendered. without user intervention such as a checkbox, button etc...
Or have I missed something?
If it is as I suspect, could we not have a trigger that occurs as a tiddler is rendered, such that it may evaluate some conditions and assign a value to a field, before continuing to render the rest of the tiddler, now using the new field value?
It would seem a little like StartupActions for a tiddler. However I have not worked through the amenity and practicality of this.
I imagine one could cause multiple actions to occur on the opening of a given tiddler. Such that the opening a tiddler is a button that will launch some actions.
Perhaps another way to think of it is a pre-processing step. I could imagine a block of wikitext could be evaluate (eg; Some variables determined and actions executed) before the rest of the wiki text is evaluated in a given tiddler) as a result this pre-processing will never be rendered only the result of its actions prior to rendering. Of course a timeout may be needed, set globally, overridden locally.
Use cases?
- Evaluate various values or determine if other values match various conditions before rendering
- Allow tiddlers to respond to pre-conditions evaluated for them alone with simple flags
- eg; If tiddler expiration date has past set status field = expired
- Allow tiddlers to carry with them some logic and processing normally found in accompanying macros/plugins and user buttons. Increase share-ability.
- Allow the generation of a log entry on opening a tiddler (I have being here), update a last read date.
- Allow auto timing or start and end time logs (Would need a post process)
I was taught not to raise a problem without suggesting a solution!
Perhaps we could provide a way to specify a special kind of macro that is pre-processed without output (unless in error) eg:
\defineaction onopen()
<$list
set field to result
</$list
\endaction
In closing I suppose what I am suggesting is not only considering tiddlers as the atomic storage unit but also allow them to be the the process or function atomic unit.
Regards
Tony