Using text references in variables

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?

I am continuing to research this on my own but hope others can contribute.

Note:
I am trying to find additional ways to document and reference information found at critical “locations” throughout tiddlywiki.

Please consider;

  • Tiddlers open in story
  • currentUser $:/status/UserName!!text

It appears the only filter operator at present that accepts a text reference is the list operator

  • Note that the List operator also defaults to the list field, so we need not use !!list anyway.
  • Would it make sense to enable other operators to accept a location ie title/fieldname to get its value as does the list operator or is it sufficient to have easy access to the location and retrieve its value for use as a parameter eg
\function story.list() $:/StoryList!!list
...
parameter=`${ [get.location<story.list>] }$`
...
OR
...
parameter=`${ [get.location[$:/StoryList!!list]] }$`
...

Current effort;

I am now trying to make custom filter operators / procedures that accepts the various forms of location such as;

title, title!! - default text field

!!fieldname, - default current tiddler

title!!fieldname

So we can quickly;

  • Retrieve the value at that location
  • list/enlist values at that location
  • Set the value at that location to a new value (action)
  • Apply a list ops action to that location (action)
  • Construct a location given title/fieldname eg; title!!fieldname with knowledge of the defaults.

Speculations

One thought is what if we define, perhaps through functions a set of predefined locations for use in our “TiddlyWiki Script” eg story.tiddlers.location or do we go straight to story.tiddlers as in story.list above?

What are your thoughts? am I barking up the wrong tree?

Personally, I don’t really use text references except in field transclusion format — things like {{!!list}} or [enlist{!!list}sort[]]. So I’m not sure I’m grasping the advantage(s) of the system you’re proposing here over something like [[Title]get[fieldname]]*. Could you expand a little on what makes your text reference constructions more useful/convenient?


* This can itself be function-ized, of course. For instance, I often use variations on the following:

\function .get(field) [<currentTiddler>get<field>]

{{{ [.get[list]] }}}

Thanks for Responding.

Yes I suppose though [[Title]get[fieldname]] is a literal, programmatically it would be [<Title>get<fieldname>] however something like $:/StoryList!!list is a single logical entity and need not be divided into title and field.

Yes, but in this case my function (I am working on) can accept the different forms of text reference.

It seems in someway an idea only partially implemented in TiddlyWiki, as in the list[] operator (but no other operator)?

For example {{{ [list[$:/StoryList]] }}} works because the list operator defaults the list field, however if you are using other fields this works {{{ [list[action-flags!!flag-list]] }}} however other operators require a prior get and enlist, or title and field parameters.

  • I thought I would scour the core to find other relevant “textReferences” and expose them.
  • Also an ease of applying listops or values to the textReference. eg
    • [list[action-flags!!flag-list]] -[[ $:/ControlPanel]] using action-flags!!flag-list to update the location.