Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/TCL+for+beginners?V=35
QUERY_STRINGV=35
CONTENT_TYPE
DOCUMENT_URI/revision/TCL+for+beginners
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.59.157
REMOTE_PORT55506
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.136.19.141
HTTP_CF_RAY88c8d29c0e7a1150-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP3.136.19.141
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {TCL for beginners} originally\ by\ \[slebetman\]\n\n**\ The\ Zen\ of\ the\ Tcl\ **\n\nTcl\ is\ probably\ not\ like\ any\ other\ programming\ language\ you\ are\ likely\ to\nencounter.\ The\ best\ way\ to\ approach\ Tcl\ is\ to\ think\ of\ the\ command\ line,\ be\ it\nDOS\ or\ bash\ or\ tcsh\ or\ Cisco's\ telnet\ shell.\n\nAll\ statements\ in\ Tcl\ work\ just\ like\ running\ a\ program\ from\ the\ command\ line.\nThat\ is,\ the\ first\ word\ is\ a\ ''command''\ and\ the\ following\ words\ are\n''parameters''\ to\ that\ command.\ For\ example,\ in\ DOS\ to\ list\ the\ contents\ of\ a\ndirectory\ you\ would\ type:\n\n======none\ndir\ c:\\path\\to\\folder\n======\n\nin\ Tcl\ you\ would\ write:\n\n======\nglob\ /path/to/folder/*\n======\n\nJust\ like\ in\ DOS,\ the\ first\ word\ of\ a\ Tcl\ statement\ is\ always\ a\ command.\ Simple\nisn't\ it?\n\nThe\ ''glob''\ command\ is\ just\ one\ of\ the\ commands\ available\ in\ Tcl.\ Another\nuseful\ command\ is\ the\ ''puts''\ command.\ It\ simply\ prints\ things\ out\ on\ the\nscreen.\ Try\ it:\n\n======\nputs\ \"Hello\ World!\"\n======\n\nYou\ may\ think\ of\ it\ as\ '''put'''\ '''s'''tring\ but\ I\ usually\ think\ of\ it\ as\ the\nplural\ of\ put\ (since\ it\ can\ output\ more\ than\ one\ character).\n\nNotice\ that\ ''puts''\ is\ similar\ to\ the\ ''echo''\ command\ in\ DOS\ and\ Unix\ shells.\nAgain,\ this\ shows\ how\ simple\ Tcl\ is.\n\n**\ Any\ Comments?..\ **\n\nIn\ Tcl\ any\ command\ (first\ word\ in\ a\ statement)\ that\ begins\ with\ the\ '''#'''\ncharacter\ is\ ignored.\ This\ is\ how\ one\ inserts\ comments.\ Comments\ are\ nice\ since\nthey\ allow\ you\ do\ document\ things\ which\ may\ not\ be\ obvious\ in\ your\ code.\n\n======\n#This\ is\ a\ comment\n#\ the\ Tcl\ interpreter\ will\ ignore\ comments\ so\ you\ can\ say\ whatever\ you\ like\ \;-)\n======\n\n**\ Variables\ and\ Values\ **\n\nIn\ all\ programming\ languages,\ you\ use\ variables\ to\ store\ values.\ Some\ languages\nprevent\ you\ from\ storing\ different\ kinds\ of\ values\ into\ different\ kinds\ of\nvariables.\ But\ we'll\ have\ none\ of\ that\ here.\ In\ Tcl\ a\ variable\ can\ hold\nanything\ (even\ complete\ programs\ if\ you\ want\ to).\ Variables\ will\ even\ hold\ your\nhand:\n\n======\nset\ my_variable\ \"your\ hand\"\n======\n\nwell..\ maybe\ not\ '''your'''\ hand,\ but\ the\ code\ above\ stores\ the\ string\ \"your\nhand\"\ into\ a\ variable\ called\ my_variable.\ The\ ''set''\ command\ is\ used\ to\ assign\nvalues\ to\ variables.\ It\ can\ also\ be\ used\ to\ get\ the\ value\ contained\ by\ the\nvariable:\n\n======\n#assign\ value:\nset\ new_var\ 100\n======\n\n======\n#get\ value\ and\ print\ it\ on\ screen\nputs\ \[set\ new_var\]\n======\n\nProgrammers\ usually\ don't\ like\ typing\ too\ much.\ So\ Tcl\ provides\ a\ kind\ of\nshortcut\ to\ get\ the\ value\ of\ variables\ without\ using\ the\ ''set''\ command.\nSimply\ add\ a\ '''\$'''\ sign\ in\ front\ of\ the\ variable\ to\ get\ its\ value:\n\n======\n#another\ way\ to\ get\ value\ of\ variables\nputs\ \$new_var\n\n#you\ can\ even\ assign\ values\ of\ other\ variables\ to\ a\ varaible:\nset\ my_variable\ \$new_var\n======\n\nNotice\ that\ when\ one\ uses\ the\ ''set''\ command\ on\ a\ variable,\ one\ uses\ the\nvariable\ without\ the\ '''\$'''\ sign.\ This\ is\ because\ the\ '''\$'''\ sign\ is\ not\ used\nto\ signify\ a\ variable\ like\ in\ Perl\ but\ is\ merely\ a\ shortcut\ for\ getting\ its\nvalue.\n\nJust\ for\ fun,\ what\ do\ you\ think\ happens\ in\ the\ following\ code?\n\n======\nset\ foo\ \"this\ is\ cool\"\nset\ bar\ foo\nputs\ \[set\ \$bar\]\n======\n\nIn\ the\ first\ statement,\ the\ variable\ ''foo''\ is\ set\ to\ hold\ the\ string\ ''\"this\nis\ cool\"''.\ The\ variable\ ''bar''\ is\ then\ set\ to\ the\ word\ ''\"foo\"''.\ Notice\ that\nthere\ is\ no\ '''\$'''\ sign\ in\ front\ of\ ''foo''.\ This\ means\ that\ ''bar''\ is\ not\nassigned\ the\ '''value'''\ of\ ''foo''\ but\ just\ simply\ the\ word\ ''foo''.\n\nThe\ interesting\ part\ is\ the\ third\ statement.\ The\ ''set''\ command\ is\ used\ to\ get\nthe\ value\ of\ ''\$bar''.\ Since\ ''bar''\ itself\ contains\ the\ word\ ''foo'',\ what\nhappens\ is\ we\ get\ the\ value\ contained\ in\ the\ value\ of\ ''bar''.\ Confused?\n\nLet's\ examine\ the\ third\ line\ step\ by\ step.\ The\ '''\$'''\ sign\ is\ a\ shortcut\ to\nget\ the\ value\ of\ a\ variable.\ So\ ''\$bar''\ returns\ the\ word\ ''foo''.\ The\ ''set''\ncommand\ then\ gets\ the\ value\ of\ ''foo''\ and\ returns\ the\ string\ ''\"this\ is\ncool\"''.\ The\ third\ line\ can\ also\ be\ written\ as:\n\n======\nputs\ \[set\ \[set\ bar\]\]\n======\n\nbut\ writing\ ''\$\$bar''\ does\ not\ work.\ This\ is\ because\ '''\$\$'''\ is\ not\ something\nTcl\ understands.\n\n**\ Groupings\ **\n\nThere\ are\ several\ things\ I\ did\ not\ explain\ in\ the\ examples\ above.\ One\ of\ which\nis\ the\ use\ of\ the\ double\ quotes\ (\").\ I\ know\ what\ you're\ thinking:\ I\ know\ that,\nit's\ a\ string.\ Correct...,\ but\ not\ quite.\ You\ see,\ in\ Tcl,\ everything\ is\ a\nstring\ until\ it\ needs\ to\ be\ something\ else.\ Even\ 200\ is\ a\ string\ until\ you\ try\nto\ add\ 1\ to\ it.\ What\ the\ quotes\ represent\ in\ Tcl\ is\ grouping\ -\ a\ far\ simpler\nand\ powerful\ concept.\n\nLet's\ take\ a\ look\ at\ the\ ''set''\ command.\ It\ accepts\ either\ one\ or\ two\nparameters.\ If\ there\ are\ two\ parameters\ then\ the\ second\ parameter\ is\ a\ value\ to\nbe\ assigned\ to\ the\ first\ parameter\ (which\ is\ a\ variable\ name).\ What\ if\ our\nstring\ consists\ of\ more\ than\ one\ word?\ Trying\ to\ do:\n\n======\n#warning,\ bad\ code\ ahead!\nset\ foo\ this\ is\ cool\n======\n\nwill\ result\ in\n\n======none\nerror:\ wrong\ #\ args:\ should\ be\ \"set\ varName\ ?newValue?\"\n======\n\nwhy?\ because\ we\ are\ given\ '''set'''\ four\ parameters,\ instead\ of\ two.\ we\ should\nwrite:\ \n\n======\nset\ foo\ \"this\ is\ cool\"\n======\n\nSo\ Tcl\ provides\ mechanisms\ to\ group\ words\ together.\ In\ the\ earlier\ example,\ foo\nis\ the\ first\ parameter\ and\ \"this\ is\ cool\"\ is\ the\ second,\ grouped\ by\ the\ quotes.\n\nTcl\ provides\ two\ ways\ to\ group\ things:\ the\ double\ quotes\ \"\ and\ curly\ braces\ \{\}.\nThe\ above\ example\ would\ also\ work\ with:\n\n======\nset\ foo\ \{this\ is\ cool\}\n======\n\nWhat's\ the\ difference?\ Why\ two\ kinds\ of\ groupings?\ Well,\ things\ grouped\ with\nthe\ double\ quotes\ will\ go\ through\ ''substitution''.\ Things\ grouped\ with\ braces\nwill\ be\ left\ alone.\ You're\ saying\ what??..\ Lets\ see\ an\ example:\n\n======\nset\ foo\ 100\nputs\ \{example1\ \$foo\}\nputs\ \"example2\ \$foo\"\n======\n\nThe\ above\ code\ will\ print\ out:\n\n======\nexample1\ \$foo\nexample2\ 100\n======\n\nthat's\ because\ the\ first\ ''puts''\ statement\ is\ left\ alone\ while\ the\ second\ one\nis\ substituted.\n\n**\ Substitution\ **\n\nWe\ have\ seen\ one\ kind\ of\ substitution\ already.\ That\ is\ the\ '''\$'''\ shortcut.\nThis\ is\ called\ ''variable\ substitution''\ because\ it\ replaces\ the\ variable\ with\nits\ value.\ Substitutions\ are\ what\ makes\ Tcl\ tick.\ It\ is\ a\ powerful,\ flexible\nand\ simple\ concept.\ There\ are\ three\ kinds\ of\ substitutions\ in\ Tcl:\ variable\nsubstitutions,\ command\ substitutions\ and\ backslash\ substitutions.\n\nWe\ have\ already\ seen\ variable\ substitution\ and\ it\ is\ explained\ above.\ It\ simply\nsubstitutes\ the\ value\ of\ the\ variable\ in\ place\ of\ the\ variable\ itself\ when\ a\n'''\$'''\ sign\ is\ added\ in\ front\ of\ the\ variable.\n\nCommand\ substitution\ is\ similar\ in\ that\ it\ substitutes\ the\ result\ of\ a\ command\nin\ place\ of\ the\ command.\ We\ have\ in\ fact\ already\ seen\ this\ above,\ but\ I\ did\ not\nexplain\ it.\ Basically\ a\ statement\ between\ square\ brackets\ '''\[\[\ \]\]'''\ is\ntreated\ as\ a\ command\ and\ is\ evaluated.\ The\ result\ is\ then\ substituted\ in\ its\nplace.\ For\ example:\n\n======\nset\ bat\ \"a\ list\ of\ files\ in\ the\ current\ directory:\ \[glob\ *\]\"\n======\n\nThe\ glob\ command\ is\ evaluated,\ and\ its\ result\ is\ inserted\ into\ the\ string\ which\nis\ then\ assigned\ to\ the\ variable\ ''bat''.\ We\ have\ seen\ similar\ syntax\ in\ the\nvarious\ ''set''\ and\ ''puts''\ examples\ above.\n\nBackslash\ substitution\ is\ very\ similar\ to\ C/C++.\ The\ following\ are\ backslash\nsubstitutions\ understood\ by\ Tcl:\n\n\ \ \ *\ \\a\ Audible\ alert\ (bell)\ (0x7).\ \n\ \ \ *\ \\b\ Backspace\ (0x8).\ \n\ \ \ *\ \\f\ Form\ feed\ (0xc).\ \n\ \ \ *\ \\n\ Newline,\ LF\ (0xa).\ \n\ \ \ *\ \\r\ Carriage-return,\ CR\ (0xd).\ \n\ \ \ *\ \\t\ Tab\ (0x9).\ \n\ \ \ *\ \\v\ Vertical\ tab\ (0xb).\ \n\nAlso,\ if\ a\ '''\\'''\ is\ followed\ by\ up\ to\ 3\ digits\ of\ numbers,\ than\ it\ is\ treated\nas\ an\ octal\ value\ for\ a\ character\ and\ the\ actual\ character\ is\ then\ substituted\nin\ its\ place.\n\nAny\ other\ character\ following\ a\ '''\\'''\ is\ replace\ with\ itself.\ This\ is\ an\n'escape'\ mechanism\ that\ enables\ you\ to\ include\ special\ characters:\n\n======\nputs\ \"This\ is\ how\ you\ print\ the\ double\ quote\ (\\\")\"\n======\n\nIn\ addition,\ if\ a\ backslash\ '''\\'''\ appears\ at\ the\ end\ of\ a\ line,\ then\ that\nline\ continues\ on\ to\ the\ next\ line:\n\n======\nputs\ \\\n\ \ \"Continued\ from\ the\ line\ above\"\n======\n\nThis\ is\ to\ allow\ a\ long\ line\ of\ code\ to\ be\ split\ into\ multiple\ lines\ if\ you\ run\nout\ of\ space\ in\ your\ text\ editor.\n\nSee\ also:\ http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm\n\n----\n\n**\ What\ is\ a\ list?\ **\nabout\ \[list%|%lists\],\ except\ that\ some\ command\ might\ interpret\ words\ passed\ to\ them\ as\nIn\ Tcl,\ everything\ is\ a\ string.\ But\ what\ is\ a\ list?\ It\ is\ basically,\ a\ string\nin\ which\ elements\ are\ separated\ by\ spaces.\nset\ a\ \"A\ B\ C\"\nlindex\ \$a\ 0\n======\n\nThe\ above\ commands\ return\ :\n\n======none\nA\ B\ C\nA\n======\n\nHowever,\ not\ every\ string\ that\ can\ be\ interpreted\ as\ a\ command\ is\ a\ list.\n\n\[lindex\]\ returns\ a\ list\ element,\ located\ at\ a\ given\ index.\ Indices\ start\ at\ 0.\nset\ command\ \{list\ \{*\}\{one\ two\ three\}\}\nlindex\ \$command\ 0\ \;#\ ->\ error:\ list\ element\ in\ braces\ followed\ by\ \"\{one\"\ instead\ of\ space\n======\n\nresult:\n\nreturns\ \"B\".\nB\n--\ \[Sarnold\]\ 2005/11/27\n\n\[DKF\]:\ But\ it's\ not\ just\ that,\ since\ you\ can\ put\ lists\ inside\ lists,\ like\ this:\n======\nlindex\ \$a\ 1\n======\n\nresult:\nreturning:\n\nB\ C\n======\n\nRemember\ that\ not\ all\ strings\ are\ lists.\n\nBecause\ of\ this\ sort\ of\ thing,\ you\ need\ to\ remember\ that\ not\ all\ strings\ are\nlists.\ Instead,\ use\ the\ \[split\]\ command\ to\ convert\ a\ string\ into\ a\ list\ of\nwords.\nthat\ doesn't\ mean\ that\ any\ value\ given\ to\ `\[split\]`\ is\ a\ well-formed\n----\n\n\[JM\]:\ \ slebetman,\ I\ would\ like\ to\ participate\ in\ this\ page,\ I\ can\ suggest\ an\nidea\ that\ I\ think\ fits,\ then\ if\ you\ agree\ I\ can\ insert\ the\ text\ where\ I\ think\nit\ belongs,\ so\ I\ don't\ mess\ original\ idea\ of\ this\ page.\n**\ DO\ **\nexample:\n\nfor\ the\ \"any\ comments?\"\ section,\ we\ can\ include\ that,\ a\ common,\ alternative\ way\nto\ insert\ comments\ in\ tcl\ (and\ I\ think\ not\ just\ in\ tcl)\ is\ by\ means\ of:\n\n======\nif\ \{0\}\ \ \{\n\ \ \ \ these\ are\ the\ comments\n\}\n======\n\nwhich\ is\ really\ code\ that\ is\ never\ executed.\n\n\[slebetman\]:\ \ I'd\ wait\ until\ we\ introduce\ the\ 'if'\ command.\ I\ know\ '''if'''\ is\nobvious\ to\ anyone\ who\ is\ used\ to\ programming\ in\ any\ language.\ But\ I\ want\ to\nimpress\ the\ ''essence\ of\ Tcl''\ to\ newbies.\ Mixing\ syntax\ and\ command\ is\ not\ngood\ in\ my\ view.\n\nBut\ thanks\ for\ your\ support.\ Please\ edit\ away\ any\ mistakes\ that\ you\ find\ here.\nBut\ please\ refrain\ from\ commenting\ ''in-line''.\ Comment\ at\ the\ bottom.\ In-line\ncomments\ in\ the\ text\ itself\ is\ to\ be\ considered\ transient\ and\ may\ be\ edited\naway\ once\ corrections\ are\ made.\n\nAlso,\ if\ you\ find\ ways\ to\ re-phrase\ sentences\ and\ paragraphs\ in\ a\ more\n'friendly'\ manner,\ please\ do\ so\ (in-line\ comments\ may\ be\ appropriate\ in\ this\ncase\ if\ there\ is\ no\ consensus\ yet).\ I\ want\ to\ keep\ the\ tone\ of\ this\nintroduction\ fun,\ friendly\ and\ informal,\ sort\ of\ like\ for-dummies,\ maybe\ even\nmore\ fun.\ Humor\ is\ very\ much\ encouraged\ but\ not\ at\ the\ expense\ clarity:\ fun,\nnot\ flippant.\n\nAnyway,\ I\ think\ the\ syntax\ rules\ are\ covered.\ Feel\ free\ to\ start\ describing\ncommands\ like\ '''if''',\ '''proc'''\ etc.\ Don't\ worry\ about\ which\ comes\nbefore/after\ which.\ We\ can\ always\ edit\ and\ re-arrange\ chapters\ later.\n\n\[Lars\ H\]\ 2005-11-28:\ \ Well,\ there's\ no\ mention\ of\ \\x\ and\ \\u\ substitution.\ \ I\nfind\ \\u\ interesting\ to\ mention,\ since\ it\ points\ to\ the\ fact\ that\ Tcl\ is\ not\nrestricted\ to\ 8-bit\ characters,\ which\ however\ many\ other\ languages\ are.\n\n\[slebetman\]:\ \ Good\ catch.\ Missed\ that.\ I'll\ be\ adding\ it\ later\ when\ I\ have\ntime.\ \ Or\ you\ are\ free\ to\ do\ it\ yourself.\n\n\[escargo\]\ 2004-11-28:\ \ I\ don't\ like\ spoiling\ the\ fun,\ but\ I\ think\ it's\nworthwhile\ mentioning\ some\ of\ the\ \"gotchas\"\ of\ Tcl.\ \ For\ example,\ that\ comments\nrequire\ balanced\ delimiters,\ that\ commands\ that\ take\ ''similar''\ parameters\ndon't\ necessarily\ take\ ''identical''\ parameters\ (that\ is,\ some\ things\ can\ be\nmore\ irregular\ than\ other\ languages\ because\ there\ isn't\ an\ overarching\ grammar\nthat\ enforces\ regularity).\n\n\[AET\]\ 2005-11-29:\ \ I\ agree,\ but\ there\ are\ many\ places\ where\ such\ information\ninterrupts\ the\ learning\ flow.\ \ A\ simple\ '''DO'''\ and\ '''DONT'''\ list\ is\ less\nconfusing\ for\ a\ \[beginner\].\ \ And\ please,\ PLEASE\ resist\ the\ temptation\ (that\ so\nmany\ have\ fallen\ to)\ to\ describe\ a\ new\ subject\ in\ terms\ of\ ''Here's\ some\ code\nthat\ doesn't\ work,\ and\ here's\ why\ \ .\ .\ ''.\ \ A\ beginner\ needs\ to\ see\ and\ absorb\nsimple,\ clear\ and\ above\ all\ CORRECT\ code.\ \ Please\ also\ keep\ debate\ of\ finer\npoints\ of\ style,\ completeness,\ unusual\ exceptions\ etc.\ to\ other\ pages.\n\n\[slebetman\]:\ \ I\ agree\ with\ \[AET\].\ I\ intend\ to\ give\ new\ users\ the\ 'feel'\ of\ Tcl\nwhich\ I\ and\ a\ lot\ of\ others\ found\ lacking\ in\ \[TCL\ programs\ for\ beginners\ 1-10\].\nThis\ is\ meant\ as\ an\ introduction,\ not\ a\ complete\ description.\ By\ the\ way,\ I\nalways\ wondered\ why\ the\ matching\ bracket\ thing\ is\ not\ documented\ in\ the\ 11\nrules\ of\ Tcl:\ http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm\n\nAlso,\ with\ regards\ to\ wiki\ rules\ about\ editing\ other's\ post.\ If\ the\ changes\ in\nthe\ comments\ are\ implemented,\ can\ I\ delete\ the\ comment?\ Also,\ I\ hope\ others\nwon't\ mind\ if\ I\ later\ re-arrange\ parts\ of\ this\ page\ to\ make\ it\ more\ coherent\noverall.\n\n\[Lars\ H\]:\ \ The\ \"no\ unmatched\ braces\ in\ comments\"\ restriction\ is\ only\ relevant\ in\nbodies\ (of\ \[proc\],\ \[foreach\],\ \[while\],\ etc.),\ so\ it\ is\ natural\ to\ bring\ up\ in\nthat\ context,\ but\ this\ is\ too\ early\ --\ there\ hasn't\ yet\ been\ any\ example\ where\na\ comment\ with\ an\ unmatched\ brace\ would\ spoil\ anything!\n\n----\n\n\ \ \ *\ Do\ write\ lots\ of\ comments\ in\ your\ code\ about\ what\ your\ code\ does,\ what\ you\ tried\ that\ didn't\ work\ (and\ why,\ if\ known).\n\ \ \ *\ Do\ study\ the\ documentation\ and\ others'\ code\ to\ understand\ 'upvar',\ 'uplevel'.\n\n\ \ \ *\ Learn\ how\ to\ use\ `\[exec\]`\ so\ that\ you\ can\ start\ using\ Tcl\ to\ drive\ external\ programs\n\n----\n**\ DON'T\ **\n\ \ \ *\ Don't\ have\ unescaped\ unmatched\ brackets\ ANYWHERE,\ including\ comments.\ \ Use\ a\ text\ editor\ that\ helps\ you\ by\ showing\ bracket\ matching.\ \ \n\n\ \ \ *\ Don't\ have\ unmatched\ brackets\ ANYWHERE,\ including\ comments.\ \ Use\ a\ text\ editor\ that\ helps\ you\ by\ showing\ bracket\ matching.\ \ \n\ \ \ *\ Don't\ expect\ to\ use\ an\ array\ in\ a\ proc\ till\ you\ understand\ 'upvar'.\ \ (\[CL\]\ strongly\ disagrees.)\n\ \ \ *\ Don't\ expect\ to\ drive\ external\ programs\ easily\ till\ you\ get\ the\ hang\ of\ 'exec'.\n**\ Getting\ Stuff\ Done\ \ **\n----\n\n**\ Especially\ Useful\ Tcl\ Features\ **\n\n\ \ \ *\ \[foreach\]\ is\ wonderful.\ \ Simple\ and\ powerful.\n\n----\n\n**\ Code\ reusing\ and\ packaging\ **\n\n\ \ \ *\ If\ you\ need\ speed,\ be\ aware\ that\ Tcl\ can\ be\ extended\ easily\ (using\ \[C\],\[C++\]...).\ Avoid\ writing\ your\ own\ extensions\ if\ existing\ ones\ can\ do\ the\ job.\n\ \ \ *\ Do\ split\ your\ code\ into\ different\ \[namespace\]s\ (and\ files)\ when\ it\ overcomes\ ca.\ a\ thousand\ lines.\n\n\n----\n<<categories>>\ Tutorial\n**\ Regarding\ Variables\ and\ Values\ example\ **\n======\nset\ foo\ \"this\ is\ cool\"\nset\ bar\ foo\nputs\ \[set\ \$bar\]\nputs\ \[set\ \[set\ bar\]\]\n======\n\n\nyet\ another\ line\ to\ add\ to\ example\ code:\n\n======\nputs\ \[expr\ \$\$bar\]\n======\n\[wjk\]\ --\ Totally\ agree\ with\ comment\ below\ by\ \[Lars\ H\]\n\n\[Lars\ H\]:\ I\ don't\ think\ that\ would\ be\ a\ good\ idea,\ because\ \[\[expr\ \$\$bar\]\]\ncombines\ two\ bad\ habits\ for\ a\ Tcl\ programmer:\ not\ bracing\ \[expr\]essions\ and\ \$\nsigns\ that\ fail\ to\ substitute.\ It\ can\ at\ best\ be\ a\ specimen\ for\ illuminating\nsome\ of\ the\ odd\ quirks\ of\ the\ language,\ but\ it\ is\ definitely\ not\ something\nbeginners\ should\ be\ exposed\ to.\n\n----\n\n**\ See\ Also\ **\n\n\ \ \ *\ \[An\ Introduction\ to\ Tcl\ Scripting\]\n\ \ \ *\ \[Beginning\ Tcl\]\n\ \ \ *\ \"\[Expect\]\ exceeds\ expectations\"\ mildly\ argues\ \[http://www-128.ibm.com/developerworks/library/l-sc1/?n-l-4112\]\ for\ Tcl-based\ Expect\ as\ the\ one\ language\ you\ most\ need\ to\ learn\n\ \ \ *\ \"Five\ Surprises\ from\ Tcl\"\ \[http://www.devsource.com/article2/0,1759,1778148,00.asp\]\ is\ probably\ best\ for\ programmers\ who\ don't\ work\ with\ the\ language\ but\ think\ they\ already\ knows\ its\ capabilities\ and\ limits\n\ \ \ *\ \"Tcl\ The\ Misunderstood\"\ \[http://antirez.com/articoli/tclmisunderstood.html\],\ a\ marvelously-written\ piece\ by\ \[antirez\]\n\ \ \ *\ All\ \[Tcl\]-related\ tutorials\ \[http://wiki.tcl.tk/2?tutorial\]\n regexp2} CALL {my render {TCL for beginners} originally\ by\ \[slebetman\]\n\n**\ The\ Zen\ of\ the\ Tcl\ **\n\nTcl\ is\ probably\ not\ like\ any\ other\ programming\ language\ you\ are\ likely\ to\nencounter.\ The\ best\ way\ to\ approach\ Tcl\ is\ to\ think\ of\ the\ command\ line,\ be\ it\nDOS\ or\ bash\ or\ tcsh\ or\ Cisco's\ telnet\ shell.\n\nAll\ statements\ in\ Tcl\ work\ just\ like\ running\ a\ program\ from\ the\ command\ line.\nThat\ is,\ the\ first\ word\ is\ a\ ''command''\ and\ the\ following\ words\ are\n''parameters''\ to\ that\ command.\ For\ example,\ in\ DOS\ to\ list\ the\ contents\ of\ a\ndirectory\ you\ would\ type:\n\n======none\ndir\ c:\\path\\to\\folder\n======\n\nin\ Tcl\ you\ would\ write:\n\n======\nglob\ /path/to/folder/*\n======\n\nJust\ like\ in\ DOS,\ the\ first\ word\ of\ a\ Tcl\ statement\ is\ always\ a\ command.\ Simple\nisn't\ it?\n\nThe\ ''glob''\ command\ is\ just\ one\ of\ the\ commands\ available\ in\ Tcl.\ Another\nuseful\ command\ is\ the\ ''puts''\ command.\ It\ simply\ prints\ things\ out\ on\ the\nscreen.\ Try\ it:\n\n======\nputs\ \"Hello\ World!\"\n======\n\nYou\ may\ think\ of\ it\ as\ '''put'''\ '''s'''tring\ but\ I\ usually\ think\ of\ it\ as\ the\nplural\ of\ put\ (since\ it\ can\ output\ more\ than\ one\ character).\n\nNotice\ that\ ''puts''\ is\ similar\ to\ the\ ''echo''\ command\ in\ DOS\ and\ Unix\ shells.\nAgain,\ this\ shows\ how\ simple\ Tcl\ is.\n\n**\ Any\ Comments?..\ **\n\nIn\ Tcl\ any\ command\ (first\ word\ in\ a\ statement)\ that\ begins\ with\ the\ '''#'''\ncharacter\ is\ ignored.\ This\ is\ how\ one\ inserts\ comments.\ Comments\ are\ nice\ since\nthey\ allow\ you\ do\ document\ things\ which\ may\ not\ be\ obvious\ in\ your\ code.\n\n======\n#This\ is\ a\ comment\n#\ the\ Tcl\ interpreter\ will\ ignore\ comments\ so\ you\ can\ say\ whatever\ you\ like\ \;-)\n======\n\n**\ Variables\ and\ Values\ **\n\nIn\ all\ programming\ languages,\ you\ use\ variables\ to\ store\ values.\ Some\ languages\nprevent\ you\ from\ storing\ different\ kinds\ of\ values\ into\ different\ kinds\ of\nvariables.\ But\ we'll\ have\ none\ of\ that\ here.\ In\ Tcl\ a\ variable\ can\ hold\nanything\ (even\ complete\ programs\ if\ you\ want\ to).\ Variables\ will\ even\ hold\ your\nhand:\n\n======\nset\ my_variable\ \"your\ hand\"\n======\n\nwell..\ maybe\ not\ '''your'''\ hand,\ but\ the\ code\ above\ stores\ the\ string\ \"your\nhand\"\ into\ a\ variable\ called\ my_variable.\ The\ ''set''\ command\ is\ used\ to\ assign\nvalues\ to\ variables.\ It\ can\ also\ be\ used\ to\ get\ the\ value\ contained\ by\ the\nvariable:\n\n======\n#assign\ value:\nset\ new_var\ 100\n======\n\n======\n#get\ value\ and\ print\ it\ on\ screen\nputs\ \[set\ new_var\]\n======\n\nProgrammers\ usually\ don't\ like\ typing\ too\ much.\ So\ Tcl\ provides\ a\ kind\ of\nshortcut\ to\ get\ the\ value\ of\ variables\ without\ using\ the\ ''set''\ command.\nSimply\ add\ a\ '''\$'''\ sign\ in\ front\ of\ the\ variable\ to\ get\ its\ value:\n\n======\n#another\ way\ to\ get\ value\ of\ variables\nputs\ \$new_var\n\n#you\ can\ even\ assign\ values\ of\ other\ variables\ to\ a\ varaible:\nset\ my_variable\ \$new_var\n======\n\nNotice\ that\ when\ one\ uses\ the\ ''set''\ command\ on\ a\ variable,\ one\ uses\ the\nvariable\ without\ the\ '''\$'''\ sign.\ This\ is\ because\ the\ '''\$'''\ sign\ is\ not\ used\nto\ signify\ a\ variable\ like\ in\ Perl\ but\ is\ merely\ a\ shortcut\ for\ getting\ its\nvalue.\n\nJust\ for\ fun,\ what\ do\ you\ think\ happens\ in\ the\ following\ code?\n\n======\nset\ foo\ \"this\ is\ cool\"\nset\ bar\ foo\nputs\ \[set\ \$bar\]\n======\n\nIn\ the\ first\ statement,\ the\ variable\ ''foo''\ is\ set\ to\ hold\ the\ string\ ''\"this\nis\ cool\"''.\ The\ variable\ ''bar''\ is\ then\ set\ to\ the\ word\ ''\"foo\"''.\ Notice\ that\nthere\ is\ no\ '''\$'''\ sign\ in\ front\ of\ ''foo''.\ This\ means\ that\ ''bar''\ is\ not\nassigned\ the\ '''value'''\ of\ ''foo''\ but\ just\ simply\ the\ word\ ''foo''.\n\nThe\ interesting\ part\ is\ the\ third\ statement.\ The\ ''set''\ command\ is\ used\ to\ get\nthe\ value\ of\ ''\$bar''.\ Since\ ''bar''\ itself\ contains\ the\ word\ ''foo'',\ what\nhappens\ is\ we\ get\ the\ value\ contained\ in\ the\ value\ of\ ''bar''.\ Confused?\n\nLet's\ examine\ the\ third\ line\ step\ by\ step.\ The\ '''\$'''\ sign\ is\ a\ shortcut\ to\nget\ the\ value\ of\ a\ variable.\ So\ ''\$bar''\ returns\ the\ word\ ''foo''.\ The\ ''set''\ncommand\ then\ gets\ the\ value\ of\ ''foo''\ and\ returns\ the\ string\ ''\"this\ is\ncool\"''.\ The\ third\ line\ can\ also\ be\ written\ as:\n\n======\nputs\ \[set\ \[set\ bar\]\]\n======\n\nbut\ writing\ ''\$\$bar''\ does\ not\ work.\ This\ is\ because\ '''\$\$'''\ is\ not\ something\nTcl\ understands.\n\n**\ Groupings\ **\n\nThere\ are\ several\ things\ I\ did\ not\ explain\ in\ the\ examples\ above.\ One\ of\ which\nis\ the\ use\ of\ the\ double\ quotes\ (\").\ I\ know\ what\ you're\ thinking:\ I\ know\ that,\nit's\ a\ string.\ Correct...,\ but\ not\ quite.\ You\ see,\ in\ Tcl,\ everything\ is\ a\nstring\ until\ it\ needs\ to\ be\ something\ else.\ Even\ 200\ is\ a\ string\ until\ you\ try\nto\ add\ 1\ to\ it.\ What\ the\ quotes\ represent\ in\ Tcl\ is\ grouping\ -\ a\ far\ simpler\nand\ powerful\ concept.\n\nLet's\ take\ a\ look\ at\ the\ ''set''\ command.\ It\ accepts\ either\ one\ or\ two\nparameters.\ If\ there\ are\ two\ parameters\ then\ the\ second\ parameter\ is\ a\ value\ to\nbe\ assigned\ to\ the\ first\ parameter\ (which\ is\ a\ variable\ name).\ What\ if\ our\nstring\ consists\ of\ more\ than\ one\ word?\ Trying\ to\ do:\n\n======\n#warning,\ bad\ code\ ahead!\nset\ foo\ this\ is\ cool\n======\n\nwill\ result\ in\n\n======none\nerror:\ wrong\ #\ args:\ should\ be\ \"set\ varName\ ?newValue?\"\n======\n\nwhy?\ because\ we\ are\ given\ '''set'''\ four\ parameters,\ instead\ of\ two.\ we\ should\nwrite:\ \n\n======\nset\ foo\ \"this\ is\ cool\"\n======\n\nSo\ Tcl\ provides\ mechanisms\ to\ group\ words\ together.\ In\ the\ earlier\ example,\ foo\nis\ the\ first\ parameter\ and\ \"this\ is\ cool\"\ is\ the\ second,\ grouped\ by\ the\ quotes.\n\nTcl\ provides\ two\ ways\ to\ group\ things:\ the\ double\ quotes\ \"\ and\ curly\ braces\ \{\}.\nThe\ above\ example\ would\ also\ work\ with:\n\n======\nset\ foo\ \{this\ is\ cool\}\n======\n\nWhat's\ the\ difference?\ Why\ two\ kinds\ of\ groupings?\ Well,\ things\ grouped\ with\nthe\ double\ quotes\ will\ go\ through\ ''substitution''.\ Things\ grouped\ with\ braces\nwill\ be\ left\ alone.\ You're\ saying\ what??..\ Lets\ see\ an\ example:\n\n======\nset\ foo\ 100\nputs\ \{example1\ \$foo\}\nputs\ \"example2\ \$foo\"\n======\n\nThe\ above\ code\ will\ print\ out:\n\n======\nexample1\ \$foo\nexample2\ 100\n======\n\nthat's\ because\ the\ first\ ''puts''\ statement\ is\ left\ alone\ while\ the\ second\ one\nis\ substituted.\n\n**\ Substitution\ **\n\nWe\ have\ seen\ one\ kind\ of\ substitution\ already.\ That\ is\ the\ '''\$'''\ shortcut.\nThis\ is\ called\ ''variable\ substitution''\ because\ it\ replaces\ the\ variable\ with\nits\ value.\ Substitutions\ are\ what\ makes\ Tcl\ tick.\ It\ is\ a\ powerful,\ flexible\nand\ simple\ concept.\ There\ are\ three\ kinds\ of\ substitutions\ in\ Tcl:\ variable\nsubstitutions,\ command\ substitutions\ and\ backslash\ substitutions.\n\nWe\ have\ already\ seen\ variable\ substitution\ and\ it\ is\ explained\ above.\ It\ simply\nsubstitutes\ the\ value\ of\ the\ variable\ in\ place\ of\ the\ variable\ itself\ when\ a\n'''\$'''\ sign\ is\ added\ in\ front\ of\ the\ variable.\n\nCommand\ substitution\ is\ similar\ in\ that\ it\ substitutes\ the\ result\ of\ a\ command\nin\ place\ of\ the\ command.\ We\ have\ in\ fact\ already\ seen\ this\ above,\ but\ I\ did\ not\nexplain\ it.\ Basically\ a\ statement\ between\ square\ brackets\ '''\[\[\ \]\]'''\ is\ntreated\ as\ a\ command\ and\ is\ evaluated.\ The\ result\ is\ then\ substituted\ in\ its\nplace.\ For\ example:\n\n======\nset\ bat\ \"a\ list\ of\ files\ in\ the\ current\ directory:\ \[glob\ *\]\"\n======\n\nThe\ glob\ command\ is\ evaluated,\ and\ its\ result\ is\ inserted\ into\ the\ string\ which\nis\ then\ assigned\ to\ the\ variable\ ''bat''.\ We\ have\ seen\ similar\ syntax\ in\ the\nvarious\ ''set''\ and\ ''puts''\ examples\ above.\n\nBackslash\ substitution\ is\ very\ similar\ to\ C/C++.\ The\ following\ are\ backslash\nsubstitutions\ understood\ by\ Tcl:\n\n\ \ \ *\ \\a\ Audible\ alert\ (bell)\ (0x7).\ \n\ \ \ *\ \\b\ Backspace\ (0x8).\ \n\ \ \ *\ \\f\ Form\ feed\ (0xc).\ \n\ \ \ *\ \\n\ Newline,\ LF\ (0xa).\ \n\ \ \ *\ \\r\ Carriage-return,\ CR\ (0xd).\ \n\ \ \ *\ \\t\ Tab\ (0x9).\ \n\ \ \ *\ \\v\ Vertical\ tab\ (0xb).\ \n\nAlso,\ if\ a\ '''\\'''\ is\ followed\ by\ up\ to\ 3\ digits\ of\ numbers,\ than\ it\ is\ treated\nas\ an\ octal\ value\ for\ a\ character\ and\ the\ actual\ character\ is\ then\ substituted\nin\ its\ place.\n\nAny\ other\ character\ following\ a\ '''\\'''\ is\ replace\ with\ itself.\ This\ is\ an\n'escape'\ mechanism\ that\ enables\ you\ to\ include\ special\ characters:\n\n======\nputs\ \"This\ is\ how\ you\ print\ the\ double\ quote\ (\\\")\"\n======\n\nIn\ addition,\ if\ a\ backslash\ '''\\'''\ appears\ at\ the\ end\ of\ a\ line,\ then\ that\nline\ continues\ on\ to\ the\ next\ line:\n\n======\nputs\ \\\n\ \ \"Continued\ from\ the\ line\ above\"\n======\n\nThis\ is\ to\ allow\ a\ long\ line\ of\ code\ to\ be\ split\ into\ multiple\ lines\ if\ you\ run\nout\ of\ space\ in\ your\ text\ editor.\n\nSee\ also:\ http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm\n\n----\n\n**\ What\ is\ a\ list?\ **\nabout\ \[list%|%lists\],\ except\ that\ some\ command\ might\ interpret\ words\ passed\ to\ them\ as\nIn\ Tcl,\ everything\ is\ a\ string.\ But\ what\ is\ a\ list?\ It\ is\ basically,\ a\ string\nin\ which\ elements\ are\ separated\ by\ spaces.\nset\ a\ \"A\ B\ C\"\nlindex\ \$a\ 0\n======\n\nThe\ above\ commands\ return\ :\n\n======none\nA\ B\ C\nA\n======\n\nHowever,\ not\ every\ string\ that\ can\ be\ interpreted\ as\ a\ command\ is\ a\ list.\n\n\[lindex\]\ returns\ a\ list\ element,\ located\ at\ a\ given\ index.\ Indices\ start\ at\ 0.\nset\ command\ \{list\ \{*\}\{one\ two\ three\}\}\nlindex\ \$command\ 0\ \;#\ ->\ error:\ list\ element\ in\ braces\ followed\ by\ \"\{one\"\ instead\ of\ space\n======\n\nresult:\n\nreturns\ \"B\".\nB\n--\ \[Sarnold\]\ 2005/11/27\n\n\[DKF\]:\ But\ it's\ not\ just\ that,\ since\ you\ can\ put\ lists\ inside\ lists,\ like\ this:\n======\nlindex\ \$a\ 1\n======\n\nresult:\nreturning:\n\nB\ C\n======\n\nRemember\ that\ not\ all\ strings\ are\ lists.\n\nBecause\ of\ this\ sort\ of\ thing,\ you\ need\ to\ remember\ that\ not\ all\ strings\ are\nlists.\ Instead,\ use\ the\ \[split\]\ command\ to\ convert\ a\ string\ into\ a\ list\ of\nwords.\nthat\ doesn't\ mean\ that\ any\ value\ given\ to\ `\[split\]`\ is\ a\ well-formed\n----\n\n\[JM\]:\ \ slebetman,\ I\ would\ like\ to\ participate\ in\ this\ page,\ I\ can\ suggest\ an\nidea\ that\ I\ think\ fits,\ then\ if\ you\ agree\ I\ can\ insert\ the\ text\ where\ I\ think\nit\ belongs,\ so\ I\ don't\ mess\ original\ idea\ of\ this\ page.\n**\ DO\ **\nexample:\n\nfor\ the\ \"any\ comments?\"\ section,\ we\ can\ include\ that,\ a\ common,\ alternative\ way\nto\ insert\ comments\ in\ tcl\ (and\ I\ think\ not\ just\ in\ tcl)\ is\ by\ means\ of:\n\n======\nif\ \{0\}\ \ \{\n\ \ \ \ these\ are\ the\ comments\n\}\n======\n\nwhich\ is\ really\ code\ that\ is\ never\ executed.\n\n\[slebetman\]:\ \ I'd\ wait\ until\ we\ introduce\ the\ 'if'\ command.\ I\ know\ '''if'''\ is\nobvious\ to\ anyone\ who\ is\ used\ to\ programming\ in\ any\ language.\ But\ I\ want\ to\nimpress\ the\ ''essence\ of\ Tcl''\ to\ newbies.\ Mixing\ syntax\ and\ command\ is\ not\ngood\ in\ my\ view.\n\nBut\ thanks\ for\ your\ support.\ Please\ edit\ away\ any\ mistakes\ that\ you\ find\ here.\nBut\ please\ refrain\ from\ commenting\ ''in-line''.\ Comment\ at\ the\ bottom.\ In-line\ncomments\ in\ the\ text\ itself\ is\ to\ be\ considered\ transient\ and\ may\ be\ edited\naway\ once\ corrections\ are\ made.\n\nAlso,\ if\ you\ find\ ways\ to\ re-phrase\ sentences\ and\ paragraphs\ in\ a\ more\n'friendly'\ manner,\ please\ do\ so\ (in-line\ comments\ may\ be\ appropriate\ in\ this\ncase\ if\ there\ is\ no\ consensus\ yet).\ I\ want\ to\ keep\ the\ tone\ of\ this\nintroduction\ fun,\ friendly\ and\ informal,\ sort\ of\ like\ for-dummies,\ maybe\ even\nmore\ fun.\ Humor\ is\ very\ much\ encouraged\ but\ not\ at\ the\ expense\ clarity:\ fun,\nnot\ flippant.\n\nAnyway,\ I\ think\ the\ syntax\ rules\ are\ covered.\ Feel\ free\ to\ start\ describing\ncommands\ like\ '''if''',\ '''proc'''\ etc.\ Don't\ worry\ about\ which\ comes\nbefore/after\ which.\ We\ can\ always\ edit\ and\ re-arrange\ chapters\ later.\n\n\[Lars\ H\]\ 2005-11-28:\ \ Well,\ there's\ no\ mention\ of\ \\x\ and\ \\u\ substitution.\ \ I\nfind\ \\u\ interesting\ to\ mention,\ since\ it\ points\ to\ the\ fact\ that\ Tcl\ is\ not\nrestricted\ to\ 8-bit\ characters,\ which\ however\ many\ other\ languages\ are.\n\n\[slebetman\]:\ \ Good\ catch.\ Missed\ that.\ I'll\ be\ adding\ it\ later\ when\ I\ have\ntime.\ \ Or\ you\ are\ free\ to\ do\ it\ yourself.\n\n\[escargo\]\ 2004-11-28:\ \ I\ don't\ like\ spoiling\ the\ fun,\ but\ I\ think\ it's\nworthwhile\ mentioning\ some\ of\ the\ \"gotchas\"\ of\ Tcl.\ \ For\ example,\ that\ comments\nrequire\ balanced\ delimiters,\ that\ commands\ that\ take\ ''similar''\ parameters\ndon't\ necessarily\ take\ ''identical''\ parameters\ (that\ is,\ some\ things\ can\ be\nmore\ irregular\ than\ other\ languages\ because\ there\ isn't\ an\ overarching\ grammar\nthat\ enforces\ regularity).\n\n\[AET\]\ 2005-11-29:\ \ I\ agree,\ but\ there\ are\ many\ places\ where\ such\ information\ninterrupts\ the\ learning\ flow.\ \ A\ simple\ '''DO'''\ and\ '''DONT'''\ list\ is\ less\nconfusing\ for\ a\ \[beginner\].\ \ And\ please,\ PLEASE\ resist\ the\ temptation\ (that\ so\nmany\ have\ fallen\ to)\ to\ describe\ a\ new\ subject\ in\ terms\ of\ ''Here's\ some\ code\nthat\ doesn't\ work,\ and\ here's\ why\ \ .\ .\ ''.\ \ A\ beginner\ needs\ to\ see\ and\ absorb\nsimple,\ clear\ and\ above\ all\ CORRECT\ code.\ \ Please\ also\ keep\ debate\ of\ finer\npoints\ of\ style,\ completeness,\ unusual\ exceptions\ etc.\ to\ other\ pages.\n\n\[slebetman\]:\ \ I\ agree\ with\ \[AET\].\ I\ intend\ to\ give\ new\ users\ the\ 'feel'\ of\ Tcl\nwhich\ I\ and\ a\ lot\ of\ others\ found\ lacking\ in\ \[TCL\ programs\ for\ beginners\ 1-10\].\nThis\ is\ meant\ as\ an\ introduction,\ not\ a\ complete\ description.\ By\ the\ way,\ I\nalways\ wondered\ why\ the\ matching\ bracket\ thing\ is\ not\ documented\ in\ the\ 11\nrules\ of\ Tcl:\ http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm\n\nAlso,\ with\ regards\ to\ wiki\ rules\ about\ editing\ other's\ post.\ If\ the\ changes\ in\nthe\ comments\ are\ implemented,\ can\ I\ delete\ the\ comment?\ Also,\ I\ hope\ others\nwon't\ mind\ if\ I\ later\ re-arrange\ parts\ of\ this\ page\ to\ make\ it\ more\ coherent\noverall.\n\n\[Lars\ H\]:\ \ The\ \"no\ unmatched\ braces\ in\ comments\"\ restriction\ is\ only\ relevant\ in\nbodies\ (of\ \[proc\],\ \[foreach\],\ \[while\],\ etc.),\ so\ it\ is\ natural\ to\ bring\ up\ in\nthat\ context,\ but\ this\ is\ too\ early\ --\ there\ hasn't\ yet\ been\ any\ example\ where\na\ comment\ with\ an\ unmatched\ brace\ would\ spoil\ anything!\n\n----\n\n\ \ \ *\ Do\ write\ lots\ of\ comments\ in\ your\ code\ about\ what\ your\ code\ does,\ what\ you\ tried\ that\ didn't\ work\ (and\ why,\ if\ known).\n\ \ \ *\ Do\ study\ the\ documentation\ and\ others'\ code\ to\ understand\ 'upvar',\ 'uplevel'.\n\n\ \ \ *\ Learn\ how\ to\ use\ `\[exec\]`\ so\ that\ you\ can\ start\ using\ Tcl\ to\ drive\ external\ programs\n\n----\n**\ DON'T\ **\n\ \ \ *\ Don't\ have\ unescaped\ unmatched\ brackets\ ANYWHERE,\ including\ comments.\ \ Use\ a\ text\ editor\ that\ helps\ you\ by\ showing\ bracket\ matching.\ \ \n\n\ \ \ *\ Don't\ have\ unmatched\ brackets\ ANYWHERE,\ including\ comments.\ \ Use\ a\ text\ editor\ that\ helps\ you\ by\ showing\ bracket\ matching.\ \ \n\ \ \ *\ Don't\ expect\ to\ use\ an\ array\ in\ a\ proc\ till\ you\ understand\ 'upvar'.\ \ (\[CL\]\ strongly\ disagrees.)\n\ \ \ *\ Don't\ expect\ to\ drive\ external\ programs\ easily\ till\ you\ get\ the\ hang\ of\ 'exec'.\n**\ Getting\ Stuff\ Done\ \ **\n----\n\n**\ Especially\ Useful\ Tcl\ Features\ **\n\n\ \ \ *\ \[foreach\]\ is\ wonderful.\ \ Simple\ and\ powerful.\n\n----\n\n**\ Code\ reusing\ and\ packaging\ **\n\n\ \ \ *\ If\ you\ need\ speed,\ be\ aware\ that\ Tcl\ can\ be\ extended\ easily\ (using\ \[C\],\[C++\]...).\ Avoid\ writing\ your\ own\ extensions\ if\ existing\ ones\ can\ do\ the\ job.\n\ \ \ *\ Do\ split\ your\ code\ into\ different\ \[namespace\]s\ (and\ files)\ when\ it\ overcomes\ ca.\ a\ thousand\ lines.\n\n\n----\n<<categories>>\ Tutorial\n**\ Regarding\ Variables\ and\ Values\ example\ **\n======\nset\ foo\ \"this\ is\ cool\"\nset\ bar\ foo\nputs\ \[set\ \$bar\]\nputs\ \[set\ \[set\ bar\]\]\n======\n\n\nyet\ another\ line\ to\ add\ to\ example\ code:\n\n======\nputs\ \[expr\ \$\$bar\]\n======\n\[wjk\]\ --\ Totally\ agree\ with\ comment\ below\ by\ \[Lars\ H\]\n\n\[Lars\ H\]:\ I\ don't\ think\ that\ would\ be\ a\ good\ idea,\ because\ \[\[expr\ \$\$bar\]\]\ncombines\ two\ bad\ habits\ for\ a\ Tcl\ programmer:\ not\ bracing\ \[expr\]essions\ and\ \$\nsigns\ that\ fail\ to\ substitute.\ It\ can\ at\ best\ be\ a\ specimen\ for\ illuminating\nsome\ of\ the\ odd\ quirks\ of\ the\ language,\ but\ it\ is\ definitely\ not\ something\nbeginners\ should\ be\ exposed\ to.\n\n----\n\n**\ See\ Also\ **\n\n\ \ \ *\ \[An\ Introduction\ to\ Tcl\ Scripting\]\n\ \ \ *\ \[Beginning\ Tcl\]\n\ \ \ *\ \"\[Expect\]\ exceeds\ expectations\"\ mildly\ argues\ \[http://www-128.ibm.com/developerworks/library/l-sc1/?n-l-4112\]\ for\ Tcl-based\ Expect\ as\ the\ one\ language\ you\ most\ need\ to\ learn\n\ \ \ *\ \"Five\ Surprises\ from\ Tcl\"\ \[http://www.devsource.com/article2/0,1759,1778148,00.asp\]\ is\ probably\ best\ for\ programmers\ who\ don't\ work\ with\ the\ language\ but\ think\ they\ already\ knows\ its\ capabilities\ and\ limits\n\ \ \ *\ \"Tcl\ The\ Misunderstood\"\ \[http://antirez.com/articoli/tclmisunderstood.html\],\ a\ marvelously-written\ piece\ by\ \[antirez\]\n\ \ \ *\ All\ \[Tcl\]-related\ tutorials\ \[http://wiki.tcl.tk/2?tutorial\]\n} CALL {my revision {TCL for beginners}} CALL {::oo::Obj8359571 process revision/TCL+for+beginners} CALL {::oo::Obj8359569 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4