Folks, I will add to Jeremys post that the value of foo is changed as you expect, when displayed as I have below. In a way you are reusing the variable name, giving it a new value.
<$set name="foo" value="John"> <<foo>> <$set name="foo" value="Paul"> <<foo>> <$set name="foo" value="George"> <<foo>> <$set name="foo" value="Ringo"> <$text text=<<foo>>/> </$set> </$set> </$set> </$set> However lets use this \define mymacro() <$set name="foo" value="Tony"> In macro: <<foo>><br> </$set> \end <$set name="foo" value="John"> Before Macro: <<foo>><br> <<mymacro>> After Macro: <<foo>><br> </$set> The result will be *Before Macro: John In macro: Tony After Macro: John* - Basically foo is set to john between the first <$set and </$set> - Then when you call the macro foo is set between <$set and </$set> in the macro - Because the value for foo does not continue outside the macro given its </$set> - When we return to the calling wiki text the value of foo that is returned is the value set previously. The following has the same results, for the same reason, your are "nesting the set widgets" <$set name="foo" value="John"> Before nested set: <<foo>><br> <$set name="foo" value="Tony"> In nested set: <<foo>><br> </$set> After nested set: <<foo>><br> </$set> The result will be *Before nested set: JohnIn nested set: TonyAfter nested set::John* So Jeremy's example is also nesting set widgets, it is just clearer now. *Using a macro call forces the nesting because if the macro does not close its <$set widgets an error occurs.* This illustrates the way variable names can be reused, or overidden, some would imagine this is like css, others would think of this as a stack, last in first out. Understanding this is of particular value when considering list widgets that change the current tiddler, they are changing the current tiddler inside the list but the current tiddler outside the list retains its original value. Lists within lists do this as well. However each list filter will determine if it takes account of its current context, or generates a totally new one. Regards Tony On Thursday, February 7, 2019 at 11:35:22 PM UTC+11, Mohammad wrote: > > WOW, > This is amazing Jeremy! > > As mush as I go deeper in Tiddlywiki, I found more amazing things. > This gives us a lot of flexibility. I gonna to make some examples in > TW-Scripts for this. > > By now I understood > > * I can have macro overloading in TW > * I can send a macro name like a pointer from scope 1 to another macro. > * I can define variables and constants > * I can have decision making > * I can loop over items > * .... > > This is amazing! > > --Mohammad > > > > On Thursday, February 7, 2019 at 3:58:34 PM UTC+3:30, Jeremy Ruston wrote: >> >> You said, the *toc-caption* here will override the one in the core! Can >> I conclude that: >> >> If a macro is called in a scope of a tiddler and it calls a macro >>> internally say maymac, then if the maymac is existed in the scope of >>> calling tiddler, it will override the core or other scope macros! Is this >>> kind of overloading? >> >> >> >> Yes, exactly that. >> >> It’s the same mechanism by which the following example renders “Ringo”: >> >> <$set name="foo" value="John"> >> <$set name="foo" value="Paul"> >> <$set name="foo" value="George"> >> <$set name="foo" value="Ringo"> >> <$text text=<<foo>>/> >> </$set> >> </$set> >> </$set> >> </$set> >> >> >> Best wishes >> >> Jeremy >> >> >> >> --Mohammad >> >> On Thursday, February 7, 2019 at 2:59:01 PM UTC+3:30, Jeremy Ruston wrote: >>> >>> I’m not sure if it will let you do exactly what you want in this >>> situation, but the reason that the toc-caption macro is separated out is so >>> that it can be redefined for a particular instantiation of the TOC. For >>> example, here we have a tabbed internal navigation TOC where the >>> toc-caption macro has been modified to put a percentage sign before each >>> caption. The toc-caption macro defined in this tiddler will override the >>> one in the core. >>> >>> \define toc-caption() >>> <$set name="tv-wikilinks" value="no"> >>> % <$transclude field="caption"> >>> <$view field="title"/> >>> </$transclude> >>> </$set> >>> \end >>> >>> <$macrocall >>> $name="toc-tabbed-internal-nav" >>> tag="TableOfContents" >>> selectedTiddler="$:/temp/toc/selectedTiddler" >>> unselectedText="<p>Select a topic in the table of contents. Click the >>> arrow to expand a topic.</p>" >>> missingText="<p>Missing tiddler.</p>" >>> /> >>> >>> >>> Best wishes >>> >>> Jeremy. >>> >>> >>> On 7 Feb 2019, at 04:32, S. S. <[email protected]> wrote: >>> >>> >>> David, >>> >>> Open the shadow tiddler: *$:/core/macros/toc* >>> Find this line : *\define toc-tabbed-external-nav* >>> Yes, this is the correct line for modifying the >>> *toc-tabbed-internal-nav* - as that macro calls it. >>> >>> Find this line: >>> <h1><<toc-caption>></h1> >>> >>> Change it to this : >>> <h1><$view field="title"/></h1> >>> >>> Should work! >>> Regards >>> >>> >>> On Thursday, February 7, 2019 at 6:43:02 AM UTC+7, David Gifford wrote: >>>> >>>> Hi all >>>> >>>> How would I tweak $:/core/macros/toc (or something else) so that each >>>> tab in the toc would show the caption field of the tiddler, but the title >>>> within the tab contents would show the longer title field of the tiddler? >>>> >>> >>> -- >>> 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/e3fc8dd3-8791-4db0-9860-3ca129fcf26d%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/tiddlywiki/e3fc8dd3-8791-4db0-9860-3ca129fcf26d%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >>> >>> >> -- >> 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/c19bf7dd-d88c-4160-8ce6-1a16b6fffba0%40googlegroups.com >> >> <https://groups.google.com/d/msgid/tiddlywiki/c19bf7dd-d88c-4160-8ce6-1a16b6fffba0%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- 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/a11b0cd4-1249-4670-96da-3b0f641b5ad8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

