[TW5] Using a variable to name a field to get its value

71 views
Skip to first unread message

TonyM

unread,
Jan 31, 2018, 6:46:50 AM1/31/18
to TiddlyWiki
Folks,

Perhaps a wizz can help me?

I am trying to Use a variable to name a field, from which to get its value.

In this example I set the variable menu-context and call the macro

I want it to return the value in the field {{Testmenu-filtercode!!menu-filter-viewheader}} if it exists NOT WORKING
Other wise the value in {{Testmenu-filtercode!!menu-filter}} if it exists  WORKING
Otherwise the value in {{$:/PSaT/MyMenus/menufilterdefault}} if it exists  WORKING

The key issues seems to be my syntax for the set widget value={{$menuname$!!menu-filter-<menu-context>}} 

Can anyone please assist?

I have the below code in a test tiddler Testmenu-filtercode

\define mymenufilter(menuname)
Context:<<menu-context>><br>
<$set name=menufilter value={{$menuname$!!menu-filter-<menu-context>}} emptyValue={{$menuname$!!menu-filter}}>
menu
-filter1 = <<menufilter>>,
<$set name=menufilter value={{$menuname$!!menu-filter}} emptyValue="{{$:/PSaT/MyMenus/menufilterdefault}}">
menu
-filter2 = <<menufilter>>
</$set>
</
$set>
\end


<$set name=menu-context value=viewheader>
Menu-context = <<menu-context>><br>
<<mymenufilter "Testmenu-filtercode">>
</$set>
...



Thanks in advance
Tony

Mark S.

unread,
Jan 31, 2018, 9:21:43 AM1/31/18
to tiddl...@googlegroups.com
This works:

{{$menuname$!!menu-filter-$(menu-context)$}}

As far as I am aware, the <variable> syntax only works inside filters.

Good luck
-- Mark

Edits: Confirmed function

TonyM

unread,
Jan 31, 2018, 3:28:13 PM1/31/18
to TiddlyWiki
Mark,

Thanks, of course you are correct, I should have gone to bed when I could not solve this.

Tony

Reply all
Reply to author
Forward
0 new messages