Skip to content
Tcl Source Code Artifact [9fb397ae2f]
Login

Artifact [9fb397ae2f]

Artifact 9fb397ae2f3ab0d359101864af26eaa51fa0d08c:

Ticket change [9fb397ae2f] - New ticket [2164282fffffffff|2164282fff] <i>Variety of bugs in tutorial code examples</i>. by tallniel on 2008-10-13 18:51:28.
D 2008-10-13T18:51:28
J assignee davidw
J cmimetype text/plain
J comment Thanks\sto\sJohn\sW.\sHamill\sfor\sreporting\sthese\sbugs:\n\n\nI\sfound\san\serror\sthat\sI\sthough\syou\smight\slike\sto\sknow\sabout.\n\non\sURL\s\nhttp://www.tcl.tk/man/tcl8.5/tutorial/Tcl20.html\n\nAt\sthe\sbottom\sis\sthis\sexample.\n---\nset\ssample\s"Where\sthere\sis\sa\swill,\sThere\sis\sa\sway."\n\n#\n#\sMatch\sthe\sfirst\ssubstring\swith\slowercase\sletters\sonly\n#\nset\sresult\s[regexp\s{[a-z]+}\s$sample\smatch]\nputs\s"Result:\s$result\smatch:\s$match"\n\n#\n#\sMatch\sthe\sfirst\stwo\swords,\sthe\sfirst\sone\sallows\suppercase\nset\sresult\s[regexp\s{([A-Za-z]+)\s+([a-z]+)}\s$sample\smatch\ssub1\ssub2\s]\nputs\s"Result:\s$result\sMatch:\s$match\s1:\s$sub1\s2:\s$sub2"\n\n#\n#\sReplace\sa\sword\n#\nregsub\s"way"\s$sample\s"lawsuit"\ssample2\nputs\s"New:\s$sample2"\n\n#\n#\sUse\sthe\s-all\soption\sto\scount\sthe\snumber\sof\s"words"\n#\nputs\s"Number\sof\swords:\s[regexp\s-all\s{[^\s]}\s$sample]"\n---\n\nThe\slast\sline\sshould\sbe:\n\nputs\s"Number\sof\schars\snot\sequal\sto\sspace:\s[regexp\s-all\s{[^\s]}\n$sample]"\n\nsince\sit\scounts\show\smany\snone\sspace\scharacters.\s(30\sinstead\sof\s9.)\nIf\sit\swas\ssuppose\sto\scount\swords\sthen\sit\sneeds\sto\sbe\sfixed.\n\n----------------\nhttp://www.tcl.tk/man/tcl8.5/tutorial/Tcl18.html\n\naround\sthe\s6th\sparagraph.\n\nstring\swordstart\sstring\sindex\s\nReturns\sthe\sindex\sof\sthe\scharacter\s>>>>>>>>just\sbefore<<<<<<<<<<<\sthe\sfirst\none\sin\sthe\sword\swhich\scontains\sthe\sindex'th\scharacter\sof\sstring.\sA\sword\sis\nany\scontiguous\sset\sof\sletters,\snumbers\sor\sunderscore\scharacters,\sor\sa\ssingle\nother\scharacter.\s\n\nshould\sbe:\n\nstring\swordstart\sstring\sindex\s\nReturns\sthe\sindex\sof\sthe\scharacter\s>>>>>>>>at<<<<<<<<<<<<<<<<<<<<\sthe\sfirst\none\sin\sthe\sword\swhich\scontains\sthe\sindex'th\scharacter\sof\sstring.\sA\sword\sis\nany\scontiguous\sset\sof\sletters,\snumbers\sor\sunderscore\scharacters,\sor\sa\ssingle\nother\scharacter.\s\n\nor\sit\scould\sbe\sworded\sbetter\sthen\swhat\sI\sdid.\n----------------\nhttp://www.tcl.tk/man/tcl8.5/tutorial/Tcl10.html\n\nExample\sat\sthe\send:\n\n...\nputs\s"Start"\nset\si\s0\nwhile\s{$i\s<\s10}\s{\n\s\s\s\sputs\s"I\sinside\sfirst\sloop:\s$i"\s\s\s\s\s\s\s\s\s\s\s\s\s\s<<<<<<<<<<<<<<<<<<\n\s\s\s\sincr\si\n\s\s\s\sputs\s"I\safter\sincr:\s$i"\n}\n...\nShould\sbe:\n\n...\nputs\s"Start"\nset\si\s0\nwhile\s{$i\s<\s10}\s{\n\s\s\s\sputs\s"I\sinside\sthird\sloop:\s$i"\s\s\s\s\s\s\s\s\s\s\s\s\s<<<<<<<<<<<<<<<<<<<\n\s\s\s\sincr\si\n\s\s\s\sputs\s"I\safter\sincr:\s$i"\n}\n...\n\n----------------\nhttp://www.tcl.tk/man/tcl8.5/tutorial/Tcl22.html\n\nThe\sexample\sat\sthe\sbottom\nrefers\sto\sarrays\sa(0)\s...\sa(4)\nbut\sthey\sare\snever\screate\sbefore\sbeing\sreferenced.\n\nMaybe\ssome\sof\sthe\scode\sin\nhttp://www.tcl.tk/man/tcl8.5/tutorial/Tcl6.html\nshould\sbe\sadded\sto\sTcl22.html\nto\sdefine\sthese\sarrays.\nTcl16.html\sdoesn't\shave\sa(1)\nMaybe\sa(0)\sneeds\sto\sbe\sa(1).\n\n----------------\nC:\\__jh\\ftp\\tkTcl\\www_tcl_tk\\tutorial\\29Information\sabout\sFiles\s-\sfile,\nglob.mht\n\nThe\sexample\sat\sthe\send\n\n...\nset\sdirs\s[glob\s-nocomplain\s-type\sd\s*]\nif\s{\s$dirs\s!=\s{}\s}\s{\n\s\s\s\sputs\s"Directories:\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s<<<<<\sMissing\send\squote\s"\n...\nset\sfiles\s[glob\s-nocomplain\s-type\sf\s*]\nif\s{\s$files\s!=\s{}\s}\s{\n\s\s\s\sputs\s"Files:\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s<<<<<\sMissing\send\squote\s"\n...\n----------------\nC:\\__jh\\ftp\\tkTcl\\www_tcl_tk\\tutorial\\31State\sof\sthe\sinterpreter\s-\sinfo.mht\n\nIn\sthe\sExample\sat\sthe\sbottom\sof\sthe\spage\n\n...\nproc\sfactorial\s{val}\s{\n\s\s\s\sputs\s"Current\slevel:\s[info\slevel]\s-\sval:\s$val"\n\s\s\s\sset\slvl\s[info\slevel]\n\s\s\s\sif\s{$lvl\s==\s$val}\s{\n\s\s\s\s\s\s\s\sreturn\s$val\n\s\s\s\s}\n\s\s\s\sreturn\s[expr\s{($val-$lvl)\s*\s[factorial\s$val]]}]\s\s<<<<<<<\sToo\smany\s"]"\nsquare\sbrackets\n}\n...\n#\n#\sUse\s[info\sscript]\sto\sdetermine\swhere\sthe\sother\sfiles\sof\sinterest\n#\sreside\n#\nset\ssysdir\s[file\sroot\s[info\sscript]]\s\s\s\s\s\s\s\s\s\s\s\s<<<<<<<<<<<<<<<\sroot\sdidn't\nwork.\sIt\sgame\sme\sthe\sfirst\spart\sof\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sof\smy\n"my.tcl"\sprogram\sname\s"my"\nsource\s[file\sjoin\s$sysdir\s"utils.tcl"]\n\nshould\sbe:\n\n...\n\s\s\s\sreturn\s[expr\s{($val-$lvl)\s*\s[factorial\s$val]}]\n...\nset\ssysdir\s[file\sdirname\s[info\sscript]]\s\s\s\s\s\s\s\s\s<<<<<<<<<<<<<<\sI\sneeded\sto\nuse\sdirname\sto\smake\sthis\swork\n...\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sIt\sgives\sme\n"."\sfor\scurrent\sdirectory.\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sNow\sthe\sjoin\nstatement\screate\s./utils.tcl\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sand\sI\screated\nthis\sprogram\sand\sit\sruns
J foundin obsolete:\s8.6a3
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter tallniel
J subsystem 75.\sTutorial
J title Variety\sof\sbugs\sin\stutorial\scode\sexamples
J type Bug
K 2164282fffffffffffffffffffffffffffffffff
U tallniel
Z b4135ebf107df7bb843dfccc4b78d203