Fossil

Check-in [30e9ccd5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added more info on quoting rules in Tcl/TH1 to the th1.md doc
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 30e9ccd59dda6c2f332ef254f2c908fdd9e4b727facf5d4340a45378a8dc9334
User & Date: wyoung 2018-09-04 12:10:18.151
Context
2018-09-05
15:16
Avoid column breaks inside a top-level bullet in the /sitemap. ... (check-in: dc5e06ff user: drh tags: trunk)
2018-09-04
12:10
Added more info on quoting rules in Tcl/TH1 to the th1.md doc ... (check-in: 30e9ccd5 user: wyoung tags: trunk)
11:59
Fixed some grammar and spelling in the th1.md doc. ... (check-in: 40787f50 user: wyoung tags: trunk)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to www/th1.md.
72
73
74
75
76
77
78
































79
80
81
82
83
84
85
as an expression, and if that expression is true, evaluates its
second argument (the third token) as a TH1 script.
If the expression is false and the third argument is `else`, then
the fourth argument is evaluated as a TH1 expression.

So, you see, even though the example above spans five lines, it is really
just a single command.

































Summary of Core TH1 Commands
----------------------------

The original Tcl language after when TH1 is modeled has a very rich
repertoire of commands.  TH1, as it is designed to be minimalist and
embedded has a greatly reduced command set.  The following bullets







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
as an expression, and if that expression is true, evaluates its
second argument (the third token) as a TH1 script.
If the expression is false and the third argument is `else`, then
the fourth argument is evaluated as a TH1 expression.

So, you see, even though the example above spans five lines, it is really
just a single command.

All of this also explains the emphasis on *unescaped* characters above:
the curly braces `{ }` are string quoting characters in Tcl/TH1, not
block delimiters as in C. This is how we can have a command that extends
over multiple lines. It is also why the `else` keyword must be cuddled
up with the closing brace for the `if` clause's scriptlet. The following
is invalid Tcl/TH1:

        if {$current eq "dev"} {
          puts "hello"
        }
        else {
          puts "world"
        }

If you try to run this under either Tcl or TH1, the interpreter will
tell you that there is no `else` command, because with the newline on
the third line, you terminated the `if` command.

Occasionally in Tcl/TH1 scripts, you may need to use a backslash at the
end of a line to allow a command to extend over multiple lines without
being considered two separate commands. Here's an example from one of
Fossil's test scripts:

        return [lindex [regexp -line -inline -nocase -- \
            {^uuid:\s+([0-9A-F]{40}) } [eval [getFossilCommand \
            $repository "" info trunk]]] end]

Those backslashes allow the command to wrap nicely within a standard
terminal width while telling the interpreter to consider those three
lines as a single command.


Summary of Core TH1 Commands
----------------------------

The original Tcl language after when TH1 is modeled has a very rich
repertoire of commands.  TH1, as it is designed to be minimalist and
embedded has a greatly reduced command set.  The following bullets