Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/TCL+for+beginners?V=39
QUERY_STRINGV=39
CONTENT_TYPE
DOCUMENT_URI/revision/TCL+for+beginners
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.179.109
REMOTE_PORT40666
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.147.43.190
HTTP_CF_RAY88699de23a26633c-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.147.43.190
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} '''Tcl\ for\ Beginners''',\ originally\ by\ \[slebetman\],\ rewritten\ by\ others,\ is\nanother\ \[Learning\ Tcl%|%introduction\]\ to\ \[Tcl\]\n\n\n\n**\ See\ Also\ **\n\n\ \ \ \[Dodekalogue\]:\ \ \ \n\n\ \ \ \[\[`\[foreach\]`\]:\ \ \ \ A\ simple\ and\ powerful\ command\ that\ is\ used\ extremely\ often\ \n\n\ \ \ \[gotcha\]:\ \ \ \n\n\ \ \ \[Why\ can\ I\ not\ place\ unmatched\ braces\ in\ Tcl\ comments\]:\ \ \ \n\n\n\n**\ It's\ All\ about\ Commands\ **\n\nThe\ best\ way\ to\ approach\ Tcl\ is\ to\ think\ of\ the\ command\ line,\ be\ it\n\[MS-DOS%|%DOS\]\ or\ \[bash\]\ or\ tcsh\ or\ Cisco's\ telnet\ shell.\ \ Just\ like\ in\ DOS,\nthe\ first\ word\ of\ a\ Tcl\ statement\ is\ always\ a\ command.\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.\n\n\[\[`\[glob\]`\]\ is\ one\ of\ the\ \[Tcl\ Commands%|%commands\]\ available\ in\ Tcl.\ Another\nuseful\ command\ is\ \[\[`\[puts\]`\],\ which,\ like\ the\ ''echo''\ command\ in\ DOS,\ prints\nthings\ out\ on\ the\ screen:\n\n======\nputs\ Hello\n======\n\nOne\ mnemonic\ device\ for\ \[\[`\[puts\]`\]\ is\ '''put'''\ '''s'''tring.\n\nIn\ the\ command\ above,\ there\ are\ no\ quotes\ around\ `Hello`.\ \ No\ quotes\ are\ needed\nin\ Tcl\ because\ words\ are\ already\ just\ that:\ \ '''words'''.\ \ In\ Tcl,\ everything\n\[everything\ is\ a\ string%|%is\ just\ a\ word\].\ \ Of\ course\ there\ are\ commands\ that\ninterpret\ words\ as\ numbers\ so\ that\ we\ can\ get\ some\ math\ done,\ but\ it's\ up\ to\neach\ individual\ command\ to\ decide\ how\ it\ wants\ to\ treat\ any\ particular\ word.\nTcl\ makes\ no\ distinction.\n\n\[\[`\[set\]`\]\ only\ takes\ two\ arguments.\ \ The\ following\ code\ will\ therefore\ fail:\n\n======\nset\ foo\ this\ is\ not\ kosher\ \n======\n\nwill\ result\ in\n\n======none\nerror:\ wrong\ #\ args:\ should\ be\ \"set\ varName\ ?newValue?\"\n======\n\nBut\ what\ if\ we\ want\ to\ assign\ several\ words\ to\ `foo`?\ \ One\ answer\ it\ to\ use\nbraces...\n\n\n\n**\ Using\ Braces\ **\n\n\nSince\ everything\ is\ a\ word\ in\ Tcl,\ and\ words\ are\ separated\ by\ white\ space,\ one\nquestion\ that\ soon\ arises\ is\ how\ to\ get\ spaces\ into\ words\ if\ we\ need\ them\nthere.\ \ If,\ for\ example,\ we\ want\ \[\[`\[puts\]`\],\ to\ print\ an\ entire\ sentence\ to\nthe\ screen,\ white\ space\ and\ all,\ we\ can\ do\ it\ with\ braces:\ \n\n======\nputs\ \{Hello\ World!\}\n======\n\nWith\ the\ braces\ in\ place,\ Tcl\ now\ sees\ the\ entire\ sentence\ as\ a\ single\ word.\nThus\ we\ see\ that\ in\ contrast\ to\ what\ it\ means\ to\ humans,\ in\ Tcl,\ \"word\"\ is\ a\nstring\ which\ may\ contain\ white\ space.\n\nBraces\ only\ have\ this\ special\ meaning\ when\ they\ are\ at\ the\ beginning\ of\ a\ word.\nIn\ the\ middle\ of\ a\ word,\ they're\ just\ brraces.\n\nNot\ even\ newlines\ can\ stop\ braces:\n\n======\nputs\ \{This\ is\ a\ whole\n\ \ \ paragraph\ inside\ braces.\ \ Braces\ just\n\ \ \ don't\ quit\ until\ the\ matching\ closing\ brace\n\ \ \ is\ found.\ \ Backslashed\ \\\}\ braces\ don't\ close\ it\ Off.\ \ Neither\n\ \ \ do\ \"Quotes\".\ \ \{other\ matching\ braces\}\ are\ OK,\ too.\ \ But\ finally,\n\ \ \ we\ get\ to\ the\ closing\ brace.\n\}\n======\n\n\n\n**\ Using\ Variables\ **\n\nUse\ \[\[`\[set\]`\]\ to\ set\ the\ value\ of\ a\ variable:\n\n\n======\nset\ greeting\ Hello\n======\n\nTo\ get\ the\ value\ back\ out\ of\ a\ variable\ use\ a\ dollar\ sign.\ \ For\ example,\ to\nprint\ `Hello`:\n\n======\nputs\ \$greeting\n======\n\nThis\ works\ even\ if\ there\ is\ white\ space\ in\ the\ greeting:\n\n======\nset\ greeting\ \{Hello\ There\}\nputs\ \$greeting\n======\n\nThat's\ because\ Tcl\ substitutes\ the\ entire\ value\ of\ the\ variable\ into\ the\ the\nspot\ where\ `\$greeting`\ was.\n\n\n\n**\ Command\ Substitution\ **\n\nVariable\ substitution\ isn't\ the\ only\ substitution\ game\ in\ town.\ \ There's\ also\ncommand\ substitution.\ \ This\ is\ done\ with\ square\ brackets.\ \ To\ print\ `Hello`\ to\nthe\ screen\ using\ command\ substitution:\n\n======\nset\ greeting\ Hello\nputs\ \[set\ greeting\]\n======\n\nNotice\ that\ when\ it\ only\ gets\ one\ argument\ instead\ of\ two\ \[\[`\[set\]`\]\ returns\nwith\ the\ value\ of\ the\ variable\ instead\ of\ setting\ it.\n\nNotice\ also\ that\ we\ just\ used\ the\ name\ of\ the\ variable\ without\ prepending\ a\ndollar\ sign\ to\ it.\ \ If\ we\ had\ prepended\ the\ dollar\ sign,\ it\ would\ have\ been\nequivalent\ to\ typing\ `set\ Hello`,\ in\ which\ case\ \[\[`\[set\]`\]\ would\ have\ gone\ to\nfind\ the\ value\ of\ the\ variable\ named,\ \"Hello\",\ failed\ to\ find\ it,\ and\ returned\nan\ error.\n\nKnowing\ that,\ you\ should\ be\ able\ to\ make\ sense\ of\ the\ following\ code:\n\n======\nSet\ Hello\ Howdy\nset\ greeting\ Hello\nputs\ \[set\ \$greeting\]\n======\n\nWhat\ will\ be\ printed\ to\ the\ screen?\ \ That's\ right:\n\n======none\nHowdy\n======\n\n'''Extra\ Credit'''\ (not\ really\ a\ beginner\ thing):\n\n======\nputs\ \[expr\ \$\$greeting\]\n======\n\nWhat\ will\ be\ printed?\ \ Yes,\ once\ again,\ it's\n\n\n======none\nHowdy\n======\n\nWhy?\ \ Hint,\ what\ does\ `\[\[puts\ \$\$\]`\ do?\n\n\n\n**\ Commenting\ Code\ **\n\nSometimes,\ particularly\ when\ we\ think\ we're\ doing\ something\ really\ clever,\ we\nwant\ to\ add\ comments\ to\ our\ code\ so\ that\ other\ humans\ can\ make\ more\ sense\ of\nit.\ \ To\ do\ this\ in\ Tcl,\ we\ use\ the\ pound\ character,\ but\ only\ at\ the\ beginning\nof\ a\ command:\n\n\n======\n#puts\ \{This\ line\ won't\ ever\ happen,\ because\ it's\ commented\}\nputs\ Whew!\n======\n\n\n\n\n**\ Using\ Double\ Quotes\ **\ \n\nBraces\ inhibit\ variable\ substitution,\ command\ substitution,\ and\ most\ backslash\nsubstitution:\n\n======\nset\ name\ John\n\n#warning\ -\ This\ next\ line\ won't\ substitute\ in\ John.\ \ It\ just\ prints\ exactly\n#what\ is\ in\ the\ braces,\ including\ the\ \$.\nputs\ \{Hello\ \$name\}\n======\n\n\nWhen\ we\ want\ those\ substitutions,\ but\ we\ also\ need\ white\ space\ to\ just\ be\ white\nspace,\ we\ can\ use\ double\ quotes\ instead\ of\ braces.\ \ Double\ quotes\ have\ the\ same\npurpose\ as\ braces,\ but\ also\ allow\ all\ substitutions:\n\n======\nset\ name\ John\nset\ greeting\ \"Hello,\ \$name!\ \ Hello\ again,\ \[set\ name\]!\"\ \n======\n\n\nAs\ with\ braces,\ newlines\ inside\ quotes\ are\ just\ newlines:\n\n======\nputs\ \"In\ double\ quotes,\ newlines\n\ \ \ \ are\ \ just\ newlines.\ \ If\ you\ escape\ a\ newline,\ \\\n\ \ \ \ it\ disappears\ entirely.\ \ Braces\ are\ just\ \{braces\},\n\ \ \ \ and\ other\ \\\"double\ quotes\\\"\ can\ be\ escaped.\ \[\n\ \ \ \ \ \ \ \ set\ value\ \{Command\ Substitution\ ,\ which\ should\ really\ be\ called\n\ \ \ \ \ \ \ \ \"script\ substitution\"\}\n\ \ \ \ \ \ \ \ set\ value\n\ \ \ \ \],\ is\ also\ not\ a\ problem\ at\ all.\ \ Notice\ that\ there\ were\ multiple\ commands\n\ \ \ \ in\ that\ last\ command\ subsitution,\ and\ the\ value\ of\ the\ last\ command\ is\ what\n\ \ \ \ actually\ takes\ the\ place\ of\ the\ entire\ command\ substitusion.\ \ It\ doesn't\n\ \ \ \ hurt\ to\ escape\ \\\{braces\\\},\ but\ it\ isn't\ necessary,\ either.\ \ Escaping\ regular\ \\letters\n\ \ \ \ doen't\ do\ anything\ at\ all\ to\ them.\ \ An\ \\a\ is\ just\ an\ a.\ \ Finally,\ we\ get\n\ \ \ \ to\ the\ closing\ quote.\"\n\"\n======\n\n\n\n**\ Using\ Backslashes\ **\n\n\nIn\ addition\ to\ variable\ and\ command\ substitution,\ there\ is\ on\ other\ substituion\ndevice:\ \ Backslashes.\ \ They\ are\ used\ in\ Tcl\ in\ a\ manner\ very\ similar\ to\ that\ of\n\[C\]/\[C++\].\ The\ following\ are\ backslash\ substitutions\ 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\nThe\ additional\ backslash\ sequences,\ '''`\\x`'''\ and\ '''`\\u`''',\ are\ some\ndocumented\ in\ the\ \[Dodekalogue\].\ \ They\ point\ to\ the\ fact\ that\ Tcl\ is\ not\nrestricted\ to\ 8-bit\ characters,\ a\ limitation\ of\ some\ other\ languages.\n\nIf\ a\ `\\`\ is\ followed\ by\ up\ to\ 3\ digits\ of\ numbers,\ than\ it\ is\ treated\ as\ an\noctal\ value\ for\ a\ character\ and\ the\ actual\ character\ is\ then\ substituted\ in\ its\nplace.\n\nAny\ other\ character\ following\ a\ `\\`\ is\ replace\ with\ itself.\ This\ is\ an\ 'escape'\nmechanism\ that\ enables\ you\ to\ make\ character\ just\ be\ themselves\ in\ places\ where\nTcl\ would\ normally\ assign\ some\ special\ meaning\ to\ them:\n\n======\nputs\ \"what\ do\ we\ mean\ when\ we\ say,\ \\\"word\\\"?\"\n======\n\nIf\ a\ backslash\ '''\\'''\ appears\ at\ the\ end\ of\ a\ line,\ then\ that\ line\ continues\non\ 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\n\n\n\n`\[if\]`,\ a\ necessary\ construct\ in\ any\ language,\ in\ Tcl\ is\ just\ another\nThe\ few\ rules\ that\ have\ just\ been\ described\ constitute\ the\ entirety\ of\ the\ Tcl\nlanguage.\ \ Really!\ \ That's\ it.\ \ There's\ nothing\ more.\ \ There\ doesn't\ need\ to\ be\nanything\ more\ because\ believe\ it\ or\ not,\ those\ rules\ are\ entirely\ sufficient\ to\ncreate\ everything\ else\ that's\ needed\ in\ a\ fully-featured\ language.\ \ Witness\n\[\[`\[if\]`\]\ a\ necessary\ construct\ in\ any\ language,\ which\ in\ Tcl\ can\ be\nimplemented\ as\ just\ another\ command.\ \ It\ takes\ a\ word\ that\ serves\ as\ the\ncondition,\ and\ another\ word\ that\ serves\ as\ the\ script\ to\ run\ in\ the\ event\ that\nthe\ criteria\ is\ true:\ncommand.\ \ It\ takes\ a\ word\ that\ serves\ as\ the\ condition,\ and\ another\ word\ that\n======\n\ \ \ \ puts\ \"1\ is\ always\ true!\"\n\}\n======\n\nNotice\ that\ `1`\ is\ braced,\ even\ though\ it\ wasn't\ strictly\ necessary.\ \ Why?\ \ To\nadvocate\ \[Brace\ your\ expr-essions%|%good\ programming\ habits\].\ \ Until\ you\ learn\nNotice\ that\ we\ braced\ the\ 1\ even\ though\ it\ wasn't\ strictly\ necessary.\ \ Why?\ \ To\nadvocate\ \[Brace\ your\ expr-essions%|%good\ programming\ habits.\ \ Until\ you\ learn\n\n\nHere's\ another\ example:\n\n======\nif\ \{0\}\ \ \{\n\ \ \ \ Anything\ at\ all\ can\ go\ here,\n\ \ \ \ even\ syntactically-invalid\\\{\n\ \ \ \ stuff,\ because\ Tcl\ will\ not\ attempt\n\ \ \ \ to\ evaluate\ this\ word,\ as\ the\ condition\ is\ false.\n\}\n======\n\n\n\n**\ What\ is\ a\ \[list\]?\ **\n\n**\ What\ is\ a\ list?\ **\nabout\ \[list%|%lists\],\ except\ that\ some\ command\ might\ interpret\ words\ passed\ to\ them\ as\nvarious\ things,\ including\ possibly\ lists.\ \ It\ does\ specify,\ however,\ that\ a\nabout\ lists,\ except\ that\ some\ command\ might\ interpret\ words\ passed\ to\ them\ as\nbe\ strings.\ \ Commands,\ in\ turn,\ are\ composed\ of\ words.\ \ This\ strongly\ implies\nscript\ is\ a\ string,\ can\ be\ broken\ down\ into\ commands,\ which\ therefore\ must\ also\nbuilt-in\ `\[list\]`\ commands\ of\ Tcl\ accept\ a\ word\ as\ a\ list\ if\ and\ only\nthat\ the\ syntax\ of\ a\ command\ must\ be\ adequate\ to\ express\ a\ list.\ \ There\ are\nbuilt-in\ \[\[`\[list\]`\]\ commands\ of\ Tcl\ will\ accept\ a\ word\ as\ a\ list\ if\ and\ only\nif\ the\ word\ would\ be\ conforms\ could\ be\ parsed\ just\ as\ a\ command\ is\ parsed.\ \ In\n======\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\ the\ list\ element,\ located\ at\ the\ given\ index.\ Indices\nstart\ 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\n======\nB\n======\n\nIt's\ possible\ for\ a\ list\ to\ contain\ another\ list:\n\n\n======\nset\ a\ \"A\ \{B\ C\}\ D\"\nlindex\ \$a\ 1\n======\n\nresult:\n\n======none\nA\ \{B\ C\}\ D\nB\ C\n======\n\nRemember\ that\ not\ all\ strings\ are\ lists.\n\nRemember\ that\ not\ all\ strings\ are\nlists.\nthat\ doesn't\ mean\ that\ any\ value\ given\ to\ `\[split\]`\ is\ a\ well-formed\nAlthough\ \[\[`\[split\]`\]\ can\ be\ used\ to\ convert\ any\ string\ into\ a\ list\ of\ words,\nthat\ doesn't\ doesn't\ mean\ that\ any\ value\ given\ to\ \[\[`\[split\]`\]\ is\ a\ well-formed\n\n\n**\ DO\ **\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\ \ \ *\ Learn\ how\ to\ use\ \[\[`\[exec\]`\]\ so\ that\ you\ can\ start\ using\ Tcl\ to\ drive\ drive\ external\ programs\n**\ DON'T\ **\n\n\ \ \ *\ Don't\ have\ unescaped\ unmatched\ brackets\ ANYWHERE,\ including\ comments.\ \ Use\ a\ text\ editor\ that\ helps\ you\ by\ showing\ bracket\ matching.\ \ \n\n\n**\ Getting\ Stuff\ Done\ \ **\n\n\ \ \ *\ \[tcllib\]\ is\ full\ of\ useful\ code.\ Try\ to\ use\ it\ as\ much\ as\ possible,\ a\ wide\ use\ of\ \[tcllib\]\ really\ saves\ time,\ and\ it\ is\ frequently\ updated.\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\n\ \ \ *\ Do\ split\ your\ code\ into\ different\ \[namespace\]s\ (and\ files)\ when\ it\ overcomes\ ca.\ a\ thousand\ lines.\n\n\n\n<<categories>>\ Tutorial regexp2} CALL {my render {TCL for beginners} '''Tcl\ for\ Beginners''',\ originally\ by\ \[slebetman\],\ rewritten\ by\ others,\ is\nanother\ \[Learning\ Tcl%|%introduction\]\ to\ \[Tcl\]\n\n\n\n**\ See\ Also\ **\n\n\ \ \ \[Dodekalogue\]:\ \ \ \n\n\ \ \ \[\[`\[foreach\]`\]:\ \ \ \ A\ simple\ and\ powerful\ command\ that\ is\ used\ extremely\ often\ \n\n\ \ \ \[gotcha\]:\ \ \ \n\n\ \ \ \[Why\ can\ I\ not\ place\ unmatched\ braces\ in\ Tcl\ comments\]:\ \ \ \n\n\n\n**\ It's\ All\ about\ Commands\ **\n\nThe\ best\ way\ to\ approach\ Tcl\ is\ to\ think\ of\ the\ command\ line,\ be\ it\n\[MS-DOS%|%DOS\]\ or\ \[bash\]\ or\ tcsh\ or\ Cisco's\ telnet\ shell.\ \ Just\ like\ in\ DOS,\nthe\ first\ word\ of\ a\ Tcl\ statement\ is\ always\ a\ command.\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.\n\n\[\[`\[glob\]`\]\ is\ one\ of\ the\ \[Tcl\ Commands%|%commands\]\ available\ in\ Tcl.\ Another\nuseful\ command\ is\ \[\[`\[puts\]`\],\ which,\ like\ the\ ''echo''\ command\ in\ DOS,\ prints\nthings\ out\ on\ the\ screen:\n\n======\nputs\ Hello\n======\n\nOne\ mnemonic\ device\ for\ \[\[`\[puts\]`\]\ is\ '''put'''\ '''s'''tring.\n\nIn\ the\ command\ above,\ there\ are\ no\ quotes\ around\ `Hello`.\ \ No\ quotes\ are\ needed\nin\ Tcl\ because\ words\ are\ already\ just\ that:\ \ '''words'''.\ \ In\ Tcl,\ everything\n\[everything\ is\ a\ string%|%is\ just\ a\ word\].\ \ Of\ course\ there\ are\ commands\ that\ninterpret\ words\ as\ numbers\ so\ that\ we\ can\ get\ some\ math\ done,\ but\ it's\ up\ to\neach\ individual\ command\ to\ decide\ how\ it\ wants\ to\ treat\ any\ particular\ word.\nTcl\ makes\ no\ distinction.\n\n\[\[`\[set\]`\]\ only\ takes\ two\ arguments.\ \ The\ following\ code\ will\ therefore\ fail:\n\n======\nset\ foo\ this\ is\ not\ kosher\ \n======\n\nwill\ result\ in\n\n======none\nerror:\ wrong\ #\ args:\ should\ be\ \"set\ varName\ ?newValue?\"\n======\n\nBut\ what\ if\ we\ want\ to\ assign\ several\ words\ to\ `foo`?\ \ One\ answer\ it\ to\ use\nbraces...\n\n\n\n**\ Using\ Braces\ **\n\n\nSince\ everything\ is\ a\ word\ in\ Tcl,\ and\ words\ are\ separated\ by\ white\ space,\ one\nquestion\ that\ soon\ arises\ is\ how\ to\ get\ spaces\ into\ words\ if\ we\ need\ them\nthere.\ \ If,\ for\ example,\ we\ want\ \[\[`\[puts\]`\],\ to\ print\ an\ entire\ sentence\ to\nthe\ screen,\ white\ space\ and\ all,\ we\ can\ do\ it\ with\ braces:\ \n\n======\nputs\ \{Hello\ World!\}\n======\n\nWith\ the\ braces\ in\ place,\ Tcl\ now\ sees\ the\ entire\ sentence\ as\ a\ single\ word.\nThus\ we\ see\ that\ in\ contrast\ to\ what\ it\ means\ to\ humans,\ in\ Tcl,\ \"word\"\ is\ a\nstring\ which\ may\ contain\ white\ space.\n\nBraces\ only\ have\ this\ special\ meaning\ when\ they\ are\ at\ the\ beginning\ of\ a\ word.\nIn\ the\ middle\ of\ a\ word,\ they're\ just\ brraces.\n\nNot\ even\ newlines\ can\ stop\ braces:\n\n======\nputs\ \{This\ is\ a\ whole\n\ \ \ paragraph\ inside\ braces.\ \ Braces\ just\n\ \ \ don't\ quit\ until\ the\ matching\ closing\ brace\n\ \ \ is\ found.\ \ Backslashed\ \\\}\ braces\ don't\ close\ it\ Off.\ \ Neither\n\ \ \ do\ \"Quotes\".\ \ \{other\ matching\ braces\}\ are\ OK,\ too.\ \ But\ finally,\n\ \ \ we\ get\ to\ the\ closing\ brace.\n\}\n======\n\n\n\n**\ Using\ Variables\ **\n\nUse\ \[\[`\[set\]`\]\ to\ set\ the\ value\ of\ a\ variable:\n\n\n======\nset\ greeting\ Hello\n======\n\nTo\ get\ the\ value\ back\ out\ of\ a\ variable\ use\ a\ dollar\ sign.\ \ For\ example,\ to\nprint\ `Hello`:\n\n======\nputs\ \$greeting\n======\n\nThis\ works\ even\ if\ there\ is\ white\ space\ in\ the\ greeting:\n\n======\nset\ greeting\ \{Hello\ There\}\nputs\ \$greeting\n======\n\nThat's\ because\ Tcl\ substitutes\ the\ entire\ value\ of\ the\ variable\ into\ the\ the\nspot\ where\ `\$greeting`\ was.\n\n\n\n**\ Command\ Substitution\ **\n\nVariable\ substitution\ isn't\ the\ only\ substitution\ game\ in\ town.\ \ There's\ also\ncommand\ substitution.\ \ This\ is\ done\ with\ square\ brackets.\ \ To\ print\ `Hello`\ to\nthe\ screen\ using\ command\ substitution:\n\n======\nset\ greeting\ Hello\nputs\ \[set\ greeting\]\n======\n\nNotice\ that\ when\ it\ only\ gets\ one\ argument\ instead\ of\ two\ \[\[`\[set\]`\]\ returns\nwith\ the\ value\ of\ the\ variable\ instead\ of\ setting\ it.\n\nNotice\ also\ that\ we\ just\ used\ the\ name\ of\ the\ variable\ without\ prepending\ a\ndollar\ sign\ to\ it.\ \ If\ we\ had\ prepended\ the\ dollar\ sign,\ it\ would\ have\ been\nequivalent\ to\ typing\ `set\ Hello`,\ in\ which\ case\ \[\[`\[set\]`\]\ would\ have\ gone\ to\nfind\ the\ value\ of\ the\ variable\ named,\ \"Hello\",\ failed\ to\ find\ it,\ and\ returned\nan\ error.\n\nKnowing\ that,\ you\ should\ be\ able\ to\ make\ sense\ of\ the\ following\ code:\n\n======\nSet\ Hello\ Howdy\nset\ greeting\ Hello\nputs\ \[set\ \$greeting\]\n======\n\nWhat\ will\ be\ printed\ to\ the\ screen?\ \ That's\ right:\n\n======none\nHowdy\n======\n\n'''Extra\ Credit'''\ (not\ really\ a\ beginner\ thing):\n\n======\nputs\ \[expr\ \$\$greeting\]\n======\n\nWhat\ will\ be\ printed?\ \ Yes,\ once\ again,\ it's\n\n\n======none\nHowdy\n======\n\nWhy?\ \ Hint,\ what\ does\ `\[\[puts\ \$\$\]`\ do?\n\n\n\n**\ Commenting\ Code\ **\n\nSometimes,\ particularly\ when\ we\ think\ we're\ doing\ something\ really\ clever,\ we\nwant\ to\ add\ comments\ to\ our\ code\ so\ that\ other\ humans\ can\ make\ more\ sense\ of\nit.\ \ To\ do\ this\ in\ Tcl,\ we\ use\ the\ pound\ character,\ but\ only\ at\ the\ beginning\nof\ a\ command:\n\n\n======\n#puts\ \{This\ line\ won't\ ever\ happen,\ because\ it's\ commented\}\nputs\ Whew!\n======\n\n\n\n\n**\ Using\ Double\ Quotes\ **\ \n\nBraces\ inhibit\ variable\ substitution,\ command\ substitution,\ and\ most\ backslash\nsubstitution:\n\n======\nset\ name\ John\n\n#warning\ -\ This\ next\ line\ won't\ substitute\ in\ John.\ \ It\ just\ prints\ exactly\n#what\ is\ in\ the\ braces,\ including\ the\ \$.\nputs\ \{Hello\ \$name\}\n======\n\n\nWhen\ we\ want\ those\ substitutions,\ but\ we\ also\ need\ white\ space\ to\ just\ be\ white\nspace,\ we\ can\ use\ double\ quotes\ instead\ of\ braces.\ \ Double\ quotes\ have\ the\ same\npurpose\ as\ braces,\ but\ also\ allow\ all\ substitutions:\n\n======\nset\ name\ John\nset\ greeting\ \"Hello,\ \$name!\ \ Hello\ again,\ \[set\ name\]!\"\ \n======\n\n\nAs\ with\ braces,\ newlines\ inside\ quotes\ are\ just\ newlines:\n\n======\nputs\ \"In\ double\ quotes,\ newlines\n\ \ \ \ are\ \ just\ newlines.\ \ If\ you\ escape\ a\ newline,\ \\\n\ \ \ \ it\ disappears\ entirely.\ \ Braces\ are\ just\ \{braces\},\n\ \ \ \ and\ other\ \\\"double\ quotes\\\"\ can\ be\ escaped.\ \[\n\ \ \ \ \ \ \ \ set\ value\ \{Command\ Substitution\ ,\ which\ should\ really\ be\ called\n\ \ \ \ \ \ \ \ \"script\ substitution\"\}\n\ \ \ \ \ \ \ \ set\ value\n\ \ \ \ \],\ is\ also\ not\ a\ problem\ at\ all.\ \ Notice\ that\ there\ were\ multiple\ commands\n\ \ \ \ in\ that\ last\ command\ subsitution,\ and\ the\ value\ of\ the\ last\ command\ is\ what\n\ \ \ \ actually\ takes\ the\ place\ of\ the\ entire\ command\ substitusion.\ \ It\ doesn't\n\ \ \ \ hurt\ to\ escape\ \\\{braces\\\},\ but\ it\ isn't\ necessary,\ either.\ \ Escaping\ regular\ \\letters\n\ \ \ \ doen't\ do\ anything\ at\ all\ to\ them.\ \ An\ \\a\ is\ just\ an\ a.\ \ Finally,\ we\ get\n\ \ \ \ to\ the\ closing\ quote.\"\n\"\n======\n\n\n\n**\ Using\ Backslashes\ **\n\n\nIn\ addition\ to\ variable\ and\ command\ substitution,\ there\ is\ on\ other\ substituion\ndevice:\ \ Backslashes.\ \ They\ are\ used\ in\ Tcl\ in\ a\ manner\ very\ similar\ to\ that\ of\n\[C\]/\[C++\].\ The\ following\ are\ backslash\ substitutions\ 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\nThe\ additional\ backslash\ sequences,\ '''`\\x`'''\ and\ '''`\\u`''',\ are\ some\ndocumented\ in\ the\ \[Dodekalogue\].\ \ They\ point\ to\ the\ fact\ that\ Tcl\ is\ not\nrestricted\ to\ 8-bit\ characters,\ a\ limitation\ of\ some\ other\ languages.\n\nIf\ a\ `\\`\ is\ followed\ by\ up\ to\ 3\ digits\ of\ numbers,\ than\ it\ is\ treated\ as\ an\noctal\ value\ for\ a\ character\ and\ the\ actual\ character\ is\ then\ substituted\ in\ its\nplace.\n\nAny\ other\ character\ following\ a\ `\\`\ is\ replace\ with\ itself.\ This\ is\ an\ 'escape'\nmechanism\ that\ enables\ you\ to\ make\ character\ just\ be\ themselves\ in\ places\ where\nTcl\ would\ normally\ assign\ some\ special\ meaning\ to\ them:\n\n======\nputs\ \"what\ do\ we\ mean\ when\ we\ say,\ \\\"word\\\"?\"\n======\n\nIf\ a\ backslash\ '''\\'''\ appears\ at\ the\ end\ of\ a\ line,\ then\ that\ line\ continues\non\ 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\n\n\n\n`\[if\]`,\ a\ necessary\ construct\ in\ any\ language,\ in\ Tcl\ is\ just\ another\nThe\ few\ rules\ that\ have\ just\ been\ described\ constitute\ the\ entirety\ of\ the\ Tcl\nlanguage.\ \ Really!\ \ That's\ it.\ \ There's\ nothing\ more.\ \ There\ doesn't\ need\ to\ be\nanything\ more\ because\ believe\ it\ or\ not,\ those\ rules\ are\ entirely\ sufficient\ to\ncreate\ everything\ else\ that's\ needed\ in\ a\ fully-featured\ language.\ \ Witness\n\[\[`\[if\]`\]\ a\ necessary\ construct\ in\ any\ language,\ which\ in\ Tcl\ can\ be\nimplemented\ as\ just\ another\ command.\ \ It\ takes\ a\ word\ that\ serves\ as\ the\ncondition,\ and\ another\ word\ that\ serves\ as\ the\ script\ to\ run\ in\ the\ event\ that\nthe\ criteria\ is\ true:\ncommand.\ \ It\ takes\ a\ word\ that\ serves\ as\ the\ condition,\ and\ another\ word\ that\n======\n\ \ \ \ puts\ \"1\ is\ always\ true!\"\n\}\n======\n\nNotice\ that\ `1`\ is\ braced,\ even\ though\ it\ wasn't\ strictly\ necessary.\ \ Why?\ \ To\nadvocate\ \[Brace\ your\ expr-essions%|%good\ programming\ habits\].\ \ Until\ you\ learn\nNotice\ that\ we\ braced\ the\ 1\ even\ though\ it\ wasn't\ strictly\ necessary.\ \ Why?\ \ To\nadvocate\ \[Brace\ your\ expr-essions%|%good\ programming\ habits.\ \ Until\ you\ learn\n\n\nHere's\ another\ example:\n\n======\nif\ \{0\}\ \ \{\n\ \ \ \ Anything\ at\ all\ can\ go\ here,\n\ \ \ \ even\ syntactically-invalid\\\{\n\ \ \ \ stuff,\ because\ Tcl\ will\ not\ attempt\n\ \ \ \ to\ evaluate\ this\ word,\ as\ the\ condition\ is\ false.\n\}\n======\n\n\n\n**\ What\ is\ a\ \[list\]?\ **\n\n**\ What\ is\ a\ list?\ **\nabout\ \[list%|%lists\],\ except\ that\ some\ command\ might\ interpret\ words\ passed\ to\ them\ as\nvarious\ things,\ including\ possibly\ lists.\ \ It\ does\ specify,\ however,\ that\ a\nabout\ lists,\ except\ that\ some\ command\ might\ interpret\ words\ passed\ to\ them\ as\nbe\ strings.\ \ Commands,\ in\ turn,\ are\ composed\ of\ words.\ \ This\ strongly\ implies\nscript\ is\ a\ string,\ can\ be\ broken\ down\ into\ commands,\ which\ therefore\ must\ also\nbuilt-in\ `\[list\]`\ commands\ of\ Tcl\ accept\ a\ word\ as\ a\ list\ if\ and\ only\nthat\ the\ syntax\ of\ a\ command\ must\ be\ adequate\ to\ express\ a\ list.\ \ There\ are\nbuilt-in\ \[\[`\[list\]`\]\ commands\ of\ Tcl\ will\ accept\ a\ word\ as\ a\ list\ if\ and\ only\nif\ the\ word\ would\ be\ conforms\ could\ be\ parsed\ just\ as\ a\ command\ is\ parsed.\ \ In\n======\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\ the\ list\ element,\ located\ at\ the\ given\ index.\ Indices\nstart\ 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\n======\nB\n======\n\nIt's\ possible\ for\ a\ list\ to\ contain\ another\ list:\n\n\n======\nset\ a\ \"A\ \{B\ C\}\ D\"\nlindex\ \$a\ 1\n======\n\nresult:\n\n======none\nA\ \{B\ C\}\ D\nB\ C\n======\n\nRemember\ that\ not\ all\ strings\ are\ lists.\n\nRemember\ that\ not\ all\ strings\ are\nlists.\nthat\ doesn't\ mean\ that\ any\ value\ given\ to\ `\[split\]`\ is\ a\ well-formed\nAlthough\ \[\[`\[split\]`\]\ can\ be\ used\ to\ convert\ any\ string\ into\ a\ list\ of\ words,\nthat\ doesn't\ doesn't\ mean\ that\ any\ value\ given\ to\ \[\[`\[split\]`\]\ is\ a\ well-formed\n\n\n**\ DO\ **\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\ \ \ *\ Learn\ how\ to\ use\ \[\[`\[exec\]`\]\ so\ that\ you\ can\ start\ using\ Tcl\ to\ drive\ drive\ external\ programs\n**\ DON'T\ **\n\n\ \ \ *\ Don't\ have\ unescaped\ unmatched\ brackets\ ANYWHERE,\ including\ comments.\ \ Use\ a\ text\ editor\ that\ helps\ you\ by\ showing\ bracket\ matching.\ \ \n\n\n**\ Getting\ Stuff\ Done\ \ **\n\n\ \ \ *\ \[tcllib\]\ is\ full\ of\ useful\ code.\ Try\ to\ use\ it\ as\ much\ as\ possible,\ a\ wide\ use\ of\ \[tcllib\]\ really\ saves\ time,\ and\ it\ is\ frequently\ updated.\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\n\ \ \ *\ Do\ split\ your\ code\ into\ different\ \[namespace\]s\ (and\ files)\ when\ it\ overcomes\ ca.\ a\ thousand\ lines.\n\n\n\n<<categories>>\ Tutorial} CALL {my revision {TCL for beginners}} CALL {::oo::Obj85734 process revision/TCL+for+beginners} CALL {::oo::Obj85732 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