select list from dictionary tiddler

133 views
Skip to first unread message

Dave

unread,
Feb 26, 2017, 2:26:42 AM2/26/17
to TiddlyWiki
I'm trying to convert a macro that selects from a list that resides in a field:

\define sometest(testname,testfield)
<$set name=subtest value=$testfield$>
<$select tiddler="$testname$" field=<<subtest>>>
<$list filter="[[$testname$]get[plist]]">
<$list filter=<<currentTiddler>>>
<option value=<<currentTiddler>>><$text text=<<currentTiddler>>/></option>
</$list>
</
$list>
</$select>
</
$set>
\end

<<sometest LumbarKemps ips>>

 to a similar one that takes the list of possibilities from a dictionary tiddler:

\define sometest2(testname,testfield)
<$set name="tests" value="testDictionary">

<$set name="subtest" value=$testfield$>
<$select tiddler="$testname$" field=<<subtest>>>
<$list filter="[<tests>indexes[]sort[title]]">
<$list filter=<<currentTiddler>>>
<option value=<<currentTiddler>>><$text text=<<currentTiddler>>/></option>
</$list>
</
$list>
</$select>
</
$set>
\end

----

<<sometest2 LumbarKemps ips>>

but the problem is the select widget takes the name of the pair instead of the value of the pair

----
in the original, the fieldname is plist and its value is a list of the options shown in the select box (same as the value of the value pair below)

in the dictionary version, the pair is
LumbarKemps: neg [[thoracic pain]] [[lumbar pain]] [[sacroiliac pain]] [[gluteal pain]] [[ischial pain]] [[thigh pain]] [[knee pain]] [[leg pain]]



Does anyone know how to get the actual list into the select widget instead of the name of the pair?

Thanks,
Dave


Jed Carty

unread,
Feb 26, 2017, 3:21:45 AM2/26/17
to TiddlyWiki
I did this somewhere, now I need to remember how.

I think one of these should work, but I may be too lazy at the moment to test it.

Option 1:

\define sometest(testname,testfield)
<$set name=subtest value=$testfield$>
<$select tiddler="$testname$" field=<<subtest>>>
<$list filter="[[DICTIONARYTIDDLERNAME]getindex[$testname$]]">

<$list filter=<<currentTiddler>>>
<option value=<<currentTiddler>>><$text text=<<currentTiddler>>/></option>
</$list>
</
$list>
</$select>
</
$set>
\end

<<sometest LumbarKemps ips>>

where you replace DICTIONARYTIDDLERNAME with the name of the dictionary tiddler you use. That will let you make the fewest changes I think

The first way I thought of doing it was like this:

\define sometest(testname,testfield)
<$tiddler tiddler=DICTIONARYTIDDLERNAME>
<$select tiddler="$testname$" field=<<subtest>>>
<$list filter="[list[##$testname$]]">

<option value=<<currentTiddler>>><$text text=<<currentTiddler>>/></option>
</
$list>
</$select>
</
$tiddler>
\end

<<sometest LumbarKemps ips>>

the second one is a bit more concise, but I don't think there is any reason it is better.

Dave

unread,
Feb 26, 2017, 9:34:22 AM2/26/17
to TiddlyWiki
Thanks Jed, I'll try that :)

Dave

unread,
Feb 26, 2017, 7:35:34 PM2/26/17
to TiddlyWiki
That worked perfectly, thank you!

Just one more question (sure, always just one more ;)

Is there a way that you know of to get the index number of the thing that was picked?

For example, if I select "Lumber pain", that points to the possibility of, say, "facet sprain" as a diagnosis, whereas "Leg pain" points to the possibility of "facet syndrome" or "nerve root impingement" as possibilities.  I want to be able to add +1 to each of those fieldnames in a "Diagnosis" tiddler, and in order to figure out which ones to add to I would think it would be useful to see if the selection picked the 2nd or the 8th item in the list.

If not, I guess I could construct a big "if, then" macro to figure it out (but I'm not very familiar with javascript so I'd rather stick to native TW stuff)

Thanks again,
- Dave

Jed Carty

unread,
Feb 27, 2017, 1:25:48 AM2/27/17
to TiddlyWiki
For reasons that have nothing to do with what you are using it for, getting the index of an item on a list isn't easily possible. You can have it tell you that it is the 8h option, but using that to get the 8th (or 9th or whatever) option from another list isn't straight forward and I am not sure if it is currently possible without some plugin.

Dave

unread,
Feb 27, 2017, 1:33:04 AM2/27/17
to TiddlyWiki
Ok, thanks.  I'm trying to solve it another way using a second data tiddler and will post a question shortly.
Reply all
Reply to author
Forward
0 new messages