On Sunday, March 18, 2018 at 11:01:58 PM UTC+1, Joe Armstrong wrote:
>
> So, what is the equivalent tiddler code to perform the following
> operations in a conventional programming languages?
>
> 1) Set a variable to a simple value and use the value
>

a) In TW "variables" are scoped. 
b) The scope boundary is the widget, that defines the variable

c) For historic reasons there are 2 dedicated widgets that set variables 
only. 
d) <$set - widget and
e) <$vars - widget

<$set existed first ... Since defining several variables can be cumbersome 
using nested set-widgets, 
<$vars was created in TW version 5.1.9

See: https://tiddlywiki.com/#VarsWidget  ... It also explains the 
differences between setWidget <https://tiddlywiki.com/#SetWidget> and 
varsWidget

-------------------

simple example: 

<$set name="local-scope" value="known in $set boundary only">

<<local-scope>>

</$set>



2) Set a variable to a complex value  and use the complex value
>

If we create a macro at the beginning of the tiddler like in the following 
code, we can define a 
tiddler-local  or tiddler-global scope:

\define tiddler-scope() known within a tiddler

<$set name="local-scope" value="known in $set boundary only">

<<tiddler-scope>>

<<local-scope>>

</$set>

---

<<tiddler-scope>>

<<local-scope>> ... is silently ignored. 


Internally the \define macro() section is converted to a <$set widget ... 
as I wrote in an other post 
<https://groups.google.com/d/msg/tiddlywiki/i1winZZTGEg/HJvB8N6KCQAJ>: 

------------------

To create "system-wide" global scope you'll need to create a tiddler 
named eg: myMacros    and 
tag it: $:/tags/Macro

see: https://tiddlywiki.com/#Macros

Internally: At the beginning of every tiddler a <$importvariables .. widget 
is called, which "imports" every tiddler tagged $:/tags/Macro available 
within a tidder scope. 

see: https://tiddlywiki.com/#ImportVariablesWidget   section: Global Macros

This code is defined in $:/core/ui/PageTemplate ... as described in the 
link above. 

have fun!
mario


-- 
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/c082b751-807d-4935-b971-3a3f0a07a047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to