On Monday, May 1, 2017 at 6:26:53 AM UTC-7, Stephen Kimmel wrote:
>
> ...problem appears to be passing the parameter fieldName from FieldChoice
> to FieldThing...
> \define FieldChoice(name:"title")
> <$select field="field1" default='title'>
> <option value="">none</option>
> <$set name="currentTiddler" value="FieldsData">
> <$list filter="[all[current]indexes[]]" variable="fieldName">
> <option value=<<fieldName>>><<FieldThing $(fieldName)$>>
> </option>
> </$list>
> </$set>
> </$select>
> \end
>
> \define FieldThing(name:"current_address")
> {{FieldsData##$name$}}
> \end
>
> <<FieldChoice field1>>
>
> Can someone tell me what I've done wrong and how to do this correctly?
>
Within the macro syntax, $(varname)$ expands values that are defined in
variables **outside the macro definition** (i.e., using <$set> or <$vars>)
and $varname$ expands values that are **passed as arguments** to the macro
call. To reference a variable that has been **defined within the current
scope** (i.e., the "fieldName" variable defined by the <$list> widget) you
need to use the <<varName>> syntax.
However, because you are passing <<varName>> as a parameter to another
macro, you can't just use <<varName>> because the <<...>> syntax doesn't
"nest". Thus, the following macro syntax does NOT work:
<<FieldThing <<fieldName>>>>
Fortunately, there is an alternative *widget* syntax for making a macro
call, that does allow you to use the <<...>> syntax to specify parameters:
<$macrocall $name="FieldThing" name=<<fieldName>> />
That should do it.
Let me know how it goes.
enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/b4f2e919-898d-488b-a354-86421b53646d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.