On 11/16/17, Cecil Westerhof <cldwester...@gmail.com> wrote:
>     puts $Tea, $Location

Everything in TCL is a function.  The syntax is "FUNCTIONNAME ARG1
ARG2 ARG3 ..." where the arguments are separated by white space.  The
"puts" function takes either one or two arguments.  The one-argument
form of "puts" outputs ARG1 to standard-output.  The two-argument form
of "puts" sends ARG2 to output stream specified by ARG1.

Your code above tries to invoke the two-argument form of "puts".
Equivalent javascript code would be:

     puts(Tea + ",", Location)

The error arises because there is no output channel named by the
result of Tea+",".  What you want is the one-argument form, equivalent
to this JS:

    puts(Tea + ", " + Location)

To get that using TCL syntax, you can use quoting to make the two
separate arguments into one:

    puts "$Tea, $Location"

The key point is that everything in TCL is of the format FUNCTION ARG1
ARG2 ....  The processing steps are like this:

(1) Identify arguments separated by whitespace.  Note that all text
within "..." and within nested {...} is a single argument.

(2) Resolve quotes.  This means remove the outermost {...} from
arguments quoted using {...}.  Remove the "..." around double-quoted
argments, and also resolve any $variable name within the double
quotes.  The $variable name resolution does not happen with {...}

(3) Invoke the function with its arguments.

Note that *everything* is a function.  Even "control" statements.  In
Tcl when you see:

     if {$i<10} {
        puts "yes"
     } else {
        puts "no"
     }

That really is invoking the "if" function with 4 arguments.   Since
everything is a function, everything follows exactly the same quoting
rules.  This is an important feature of Tcl that programmers whose
prior experience has been exclusively using Algol-derived languages
such as C, Java, Javascript, and Python may have difficulty getting
their heads around.  But once you do "get it", it starts to seem very
natural.


-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to