Version 12 of Practical_Advice_on_Quotes_and_Brackets_in_TCL

Updated 2018-12-29 20:49:47 by gold

Practical_Advice_on_Quotes_and_Brackets_in_TCL

This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Its very hard to reply reasonably without some background of the correspondent on their Wiki bio page. Thanks,gold


Title: Practical_Advice_on_Quotes_and_Brackets_in_TCL

Preface

gold12Dec2018. Here are some practical rules on brackets and quotes in TCL. Per question of “ What is the difference between double quotes (" ") and Braces { } ? “ from Kh_Yogananda_Raj_Urs. More complete references etc are listed below.


Introduction


Here are some practical rules on brackets and quotes in TCL. Brackets are essential to speed up math expressions in expr. Quotes are mainly used for exact text strings with some variable substitution. For example, puts " result value is expr { 1+3} " and print out is <result value is 4>. If you are using the TCL console or easy eye calculator in the file system, paste in the TCL statement and this should show in big fonts on the console window. From the inside the double quotes the text is output exactly, whereas math expressions and $variables are evaluated inside the quotes. For practical use on the same line of code, quotes in TCL can printout exact text, text titles of variables, evaluated expressions, and $variables stored in programs.


Aside from expr, brackets are used with list command like set lister1 { dog cat lizard } to store separate items in a list. The statement <set lister2 {" dog cat lizard" }; would store the three items in a single string representing one item in the list. Paste these expressions into the console and evaluate them . Here is a little console program: set lister1 { dog cat lizard } ; puts $lister1; set lister2 {" dog cat lizard" };puts $lister2;set lister3 {" dog cat” lizard };puts $lister3;set lister4 " dog cat lizard" ;$lister4; The TCL interpreter will see <set lister1 { dog cat lizard}> as three text variables stored in a single list. Quotes can act as a basket, mold, or glue to store text phrases inside the interpreter (in list structure). The TCL interpreter will see <set lister3 {" dog cat” lizard }> as two text variables of " dog cat” and “lizard” in a list. The TCL interpreter will see <set lister3 {" dog cat lizard"}> as one text variable in a list. The TCL interpreter will see <set lister4 " dog cat lizard"> as one text variable in a single string of text characters. The gist is that quotes and brackets are used to tell the TCL interpreter how to evaluate the enclosed items either in parts or whole string, and much differently in some usage. Part of the confusion is that <dog cat lizard> can either be treated as either one item, two items, or three items in the interpreter, but the simple print out on the TCL console looks the same regardless. --- The key concept is how the items and information are stored and typed in the TCL interpreter either as a text string or list. The interpreter will usually try to type or tag the loaded data immediately. For an analogy in reading, the human brain loads the items above and tags them with associations, like fur for “dog cat”,scales for “lizard”, and teeth & claws for all. But the treatment of <dog cat lizard> in the mental processes generally depends on the use and association (symbols) for each individual item.


Conclusions

--- The key concept is how the items and information are stored and typed in the TCL interpreter either as a text string or list. The interpreter will usually try to type or tag the loaded data immediately. For an analogy in reading, the human brain loads the items above and tags them with associations, like fur for “dog cat”,scales for “lizard”, and teeth & claws for all. But the treatment of <dog cat lizard> in the mental processes generally depends on the use and association (symbols) for each individual item.


References:



Appendix Code

Trial Console Program

        # TCL source code follows
        # ASED autoindent applied
        # Trial Console Program  brackets and quotes.
        # written on Windows XP on TCL
        # working under TCL version 8.6
        # gold on TCL Club, 12Dec2018
        console show
        puts " result value is [expr { 1+3} ] ";
        puts [expr { 1+3} ];
        set lister1 { dog cat lizard } ;
        puts $lister1;
        set lister2 {" dog cat lizard" };
        puts $lister2;
        set lister3 {" dog cat”  lizard };
        puts $lister3;
        set lister4 " dog cat lizard" ;
        $lister4;
        # note outputs are similar
        # for $lister1 and $lister4
        # gold on TCL Club, 12Dec2018
           



gold12Dec2018. This page is copyrighted under the TCL/TK license terms, this license .

Disclaimers: This page, screenshots, and TCL source code is copyrighted under the TCL/TK license terms. Editorial rights and disclaimers retained under the TCL/TK license terms and will be defended as necessary in court.

Hidden Comments Section

Please place any comments here with your wiki MONIKER and date, Thanksgold12Dec2018