Sing text references in variablesU

Folks,

You may know almost anything can be found in tiddlywiki using a text reference eg; tiddlertitle!!fieldname one example is the current story list $:/StoryList!!list.

In this example we use <<tv-story-list>> and can construct it from a function [<tv-story-list>addsuffix[!!list]join[]].

So I now have a function/variable containing the text reference <<story.location>>.

This all makes real sense when using tiddlywiki that such text references are in effect a minimal absolute reference. Although a simple title (default text field), a fieldname and a fieldname in the current tiddler !!fieldname are less absolute.

  • We may want a list of text references or text reference=value pairs

If we read text reference the only examples are where the coder/designer enters a static literal that references such “addresses”. In reality however these are practically built programmatically, as I have done with the above <<story.location>>.

This discussion

I want to seek ideas and code patterns for making use of such absolute text references when stored in a variable. It seem to me having to split them back into tiddler title and fieldname to make use of them is the loss of an opportunity to make use of this eternal and concise way to reference a tiddlywiki resource, even when arrived at programaticaly.

  • Keep in mind we have full support for text references using literals as documented at text reference
  • Further I believe that we will find gaps in functionality when it comes to leveraging text references stored in variables that would point to small but powerful enhancements to TiddlyWiki.
  • Keep in mind we want to get or set values at a given “text reference variable” including iterate and update lists at such a location.
    • It may just be to include a small set of operators that can be given a text reference variable, although I expect adding some wikitext support would be useful.
  • What if widgets and macros could be given a text reference directly rather than separate title=tiddler titleand field=fieldnameeven providing a value to a given text reference?

Perhaps the solution is a small set of custom operators a user can install to address the gaps I have highlighted above? Alternatively have I simply missed the code patterns available to do this? making it worthy of documentation!

Background

Here is a little code examples needing 5.4.0 works on TiddlyWiki.com

\function story.list() [list<tv-story-list>]
\function story.list2() [lookup<story.location>]
\function story.location() [<tv-story-list>addsuffix[!!list]]
\function get.reference(reference) [<reference>split[!!]first[]] =>title [<reference>split[!!]last[]] =>fieldname [<title>get<fieldname>]

* `((story.list))` ((story.list))
* `<<story.location>>` <<story.location>>
* `<<story.list2>>` <<story.list2>>
* `<$macrocall $name=get.reference reference=<<story.location>> />` <$macrocall $name=get.reference reference=<<story.location>> />
; `{{{ [get.reference<story.location>enlist-input[]] }}}`
{{{ [get.reference<story.location>enlist-input[]] }}}

Perhaps we should use the new Multi-value variables MVV’s?

Since you are using addsuffix[!!list], you don’t need the join[]

Alternatively, you could write

\function story.location() [<tv-story-list>] [[!!list]] +[join[]]

-e

An action widget or procedure designed to accept a text reference and value(s) is an essential service. So we can save such text references in a field/tiddler.

Perhaps even given a single list of multiple text reference(s) and or reference and value sets textref1!!field="value(s)", textref2!!field2="value(s)",

This would allow a useful string of changes to be applied to one or more tiddlers through a single text string. Something I have been looking for for a long time.

  • Imagine if the values given could be a filter that is first resolved?
    • This could make available the title and fieldname of the text reference.
  • With a trigger this could be applied to one or many existing tiddlers rather than replacing them, and could operate as a monkey patch.
    • Plugins that modify core tiddlers, rather than replace them, would be more compatible with others that do so as both change only what they need.

Perhaps we could also leverage text references to clear/empty and delete a field and or tiddler

[After note]
A list of text references and values can represent all the information needed to create OR modify a tiddler. The key if its new or modified is whether the tiddler already exists this is in part due to the fact that creating a field causes the tiddler in which it is to be created to come into existence.

  • Given this we can consider a text reference containing only !!fieldname="value", !!fieldname2="value" that will be applied to the current tiddler.

So the following may be used;

\function get.reference(reference) [<reference>split[!!]first[]else<currentTiddler>] =>title [<reference>split[!!]last[]else[unspecified]] =>fieldname [<title>get<fieldname>]

yet to be tested.

I note that title!!is most likely not valid, but perhaps it should?

yes, thanks

Perhaps, I was adding it to ensure if the title was full of space, but that is not needed.

Wait there is more,

we call these text references but they point to a location. perhaps we can talk about these actual values as “locations” rather than “text references”, thus we retrieve values from locations using text references?