Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Ask%2C+and+it+shall+be+given+%23+8?V=289
QUERY_STRINGV=289
CONTENT_TYPE
DOCUMENT_URI/revision/Ask,+and+it+shall+be+given+#+8
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.59.209
REMOTE_PORT28386
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.17.140.13
HTTP_CF_RAY88d3f704cd2a5555-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_REFERERhttps://wiki.tcl.tk/revision/Ask%2C+and+it+shall+be+given+%23+8?V=289
HTTP_CF_CONNECTING_IP3.17.140.13
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 {Ask, and it shall be given # 8} ''This\ page\ has\ had\ numerous\ incidents\ of\ being\ deleted\ and\ corrupted.\ \ Please\ be\ very\ careful\ when\ editing\ it.\ \ If\ you\ inadvertently\ delete\ it,\ immediately\ revert\ your\ edit\ using\ the\ History\ link\ on\ the\ left\ side\ of\ this\ page.\ \ Do\ NOT\ attempt\ to\ restore\ it\ by\ copying'n'pasting\ the\ text\ from\ a\ previous\ revision,\ or\ all\ page\ formatting\ will\ be\ lost!''\n\n!!!!!!\n'''Please\ add\ hyperlinks\ leading\ to\ your\ question\ at\ the\ top\ of\ this\ page.'''\n<<br>>\nAlso\ consider\ putting\ a\ **section\ heading**\ on\ the\ top\ of\ each\ new\ question.\n<<br>>\nAnd\ of\ course,\ please\ put\ new\ questions\ at\ the\ '''TOP'''\ of\ the\ page,\ so\ that\ as\ the\ page\ grows\ longer,\ new\ questions\ are\ seen\ first.\n!!!!!!\n\nOnce\ you\ have\ received\ a\ satisfactory\ answer,\ ''please''\ put\ your\ question\ and\ answer\ directly\ on\ an\ appropriate\ page\ of\ the\ wiki\ (if\ you\ cannot\ find\ an\ existing\ page,\ create\ a\ new\ one).\ \n\nAnd\ of\ course,\ please\ put\ new\ questions\ at\ the\ TOP\ of\ the\ page,\ so\ that\ as\ the\ page\ grows\ longer,\ new\ questions\ are\ seen\ first.\n\nAfterwards,\ remove\ the\ original\ question\ and\ answer\ and\ leave\ a\ hyperlink\ here\ (as\ \[ARA\]\ has\ done\ on\ May\ 2\ 2009)\;\ this\ way\ everyone\ will\ know\ who\ needs\ help.\ This\ page\ could\ then\ act\ as\ a\ sort\ of\ reference\ page\ for\ questions\ asked\ by\ the\ Community\ -\ sort\ of\ ''Who\ has\ asked\ what\ and\ when''.\ Thanks\ for\ your\ help.\n\n\ \ \ \ *\ '''Started\ on:'''\ 2009\ May\ 02\n\ \ \ \ *\ '''Ended\ on:'''\ 2011\ February\ 5th\ (Saturday)\n\n----\n**\ linsert\ in\ recursive\ lists***\n\nHi\ all,\ \n\nI\ have\ written\ a\ code\ to\ get\ the\ index\ of\ recursive\ lists:\ \nset\ a\ \{a\ b\ \{c\ \{d\ e\}\}\}\ \n%proc\ List\{list_name\ \{prefix\ \{\}\}\}\ \{\ \n\ \ \ \ set\ end_point\ \[expr\ \[llength\ \$list_name\]\ -1\]\ \n\ \ \ \ for\ \{set\ start_point\ 0\}\ \{\$start_point\ <=\ \$end_point\}\ \{incr\ start_point\}\ \{\ \n\ \ \ \ if\ \{\[llength\ \[lindex\ \$list_name\ \$start_point\]\]\ ==\ 1\}\ \{\ \n\ \ \ \ puts\ \"Index\ for\ \[lindex\ \$list_name\ \$start_point\]\ is\ \$prefix\$start_point\"\ \n\ \ \ \ \ \}\ else\ \{\ \n\ \ \ \ append\ prefix\ \$start_point\ \n\ \ \ \ List\[lindex\ \$list_name\ \$start_point\]\ \$prefix\ \n\ \ \ \}\ \n\}\ \n\nNow\ in\ this\ i\ want\ insert\ some\ elements\ inside,\ how\ can\ i\ do\ that.\ \nEg:\ This\ is\ how\ the\ program\ should\ look\ like\ \nputs\ \"Enter\ element\"\ \ngets\ stdin\ el\ \{\ user\ enters\ as\ 4\ \}\ \nputs\ \"Enter\ insert\ posittion\"\ \ngets\ stdin\ ind\ \{\ user\ gives\ as\ 210\}\ \nSo\ if\ 210\ index\ is\ valid\ in\ the\ list\ the\ new\ element\ should\ be\ inserted\ and\ if\ the\ user\ gives\ ind\ as\ something\ like\ 530\ it\ should\ display\ \"error\ in\ index\ entered\"..\ \nHow\ can\ i\ do\ this?\ \nPlease\ help.\ \n\nThanks\ in\ advance\n\n\[gold\]16jun2011,\ \ Ask9\ has\ question\ on\ \ nested\ list\ input\ also.\nMaybe\ combine\ q&a?\ Found\ refs.\ \[list\ level\],\ discussion\ in\ \[linsert\]\ and\ \[lset\]\nSee\ section\ on\ list\ in\ http://en.wikibooks.org/wiki/Tcl_Programming/Introduction.\nReally\ asking\ for\ lset\ with\ multiple\ index.\n======\n\ console\ operation\n\ %\ set\ test\ \{\{a\ b\}\ \{c\ d\}\}\n\ \{a\ b\}\ \{c\ d\}\n\ %\ lset\ test\ 1\ 1\ x\n\ \{a\ b\}\ \{c\ x\}\n\ %\ lset\ test\ 1\ 1\ \{\ x\ gosh\}\n\ \{a\ b\}\ \{c\ \{\ x\ gosh\}\}\n\ \ if\ \{\ \[\ lset\ test\ 1\ 1\ 2\ 3\ 4\ x\ \]\ !=\ 1\ \}\ \{\n\ \ \ \ error\ \"\ index\ level\ not\ found\"\n\ \ \}\n\ console\ returns\ \"list\ index\ out\ of\ range\"\n\n======\n\n\[jbr\]\ -\ Here\ is\ a\ similar\ strange\ command\ I\ created\ just\ a\ little\ while\ ago.\ \ Maybe\ there\ should\ be\ a\ general\ discussion\ on\ commands\ that\ build\ data\ structures\ and\ need\ list\ variable\ semantics\ with\ multiple\ indices?\n\n\ proc\ dict-lappend\ \{\ dict\ args\ \}\ \{\n\ \ \ \ upvar\ \$dict\ D\n\n\ \ \ \ set\ keys\ \ \[lrange\ \$args\ 0\ end-1\]\n\ \ \ \ set\ value\ \[lindex\ \$args\ end\]\n\n\ \ \ \ if\ \{\ \[info\ exists\ D\]\ &&\ \[dict\ exists\ \$D\ \{*\}\$keys\]\ \}\ \{\n\ \ \ \ \ \ \ \ dict\ set\ D\ \{*\}\$keys\ \[list\ \{*\}\[dict\ get\ \$D\ \{*\}\$keys\]\ \$value\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ dict\ set\ D\ \{*\}\$keys\ \[list\ \$value\]\n\ \ \ \ \}\n\ \}\n\n\n\n======\n\n**\ Shutting\ down\ a\ virtual\ machine\ by\ ssh'ing\ into\ it\ via\ Tcl/Expect\ **\n\n\[sg332\]\ 2011-012-06\ I\ am\ trying\ to\ shutdown\ down\ a\ Virtual\ machine\ by\ ssh'ing\ into\ it\ via\ Tcl/Expect.\ At\ the\ point\ after\ I\ send\ \"yes\\r\"\ using\ the\ send\ command\ in\ response\ to\ a\ confirmation\ request\ of\ my\ earlier\ shutdown\ request,\ sometimes\ I\ find\ a\ print\ out\ of\ just\ \"y\"\ and\ expect\ times\ out\ while\ waiting\ for\ the\ follow-on\ shutdown\ confirmation.\ Can\ someone\ help\ with\ a\ solution/workaround\ asap?\ I\ assume,\ send\ was\ not\ able\ to\ flush\ out\ the\ remaining\ characters\ for\ some\ reason\ to\ the\ Linux\ box.\ The\ Tcl/Expect\ script\ is\ on\ a\ Linux\ machine.\n\n\[RLE\]\ (2011-02-06)\ Are\ you\ ssh'ing\ into\ another\ Linux\ based\ system?\ \ If\ so,\ any\ reason\ you\ can\ not\ just\ use\ \"shutdown\ -h\ now\"\ to\ shutdown\ immediately\ without\ asking\ any\ confirmation?\n\n\[sg332\]\ (2011-02-07)\ Thanks\ for\ replying.\ Good\ question.\ The\ reason\ is\ I\ want\ to\ gracefully\ shutdown\ the\ box,\ which\ means\ applications\ on\ that\ remote\ machine\ should\ shutdown\ gracefully\ before\ the\ OS\ starts\ shutting\ down.\ A\ OS\ platform\ command\ that\ I\ am\ using\ allows\ me\ to\ do\ so.\ But\ for\ that,\ I\ have\ to\ ssh\ into\ the\ platform\ using\ platform\ credentials.\n\n----\n**\ Finding\ a\ way\ to\ have\ the\ 'alt'\ (and\ 'default')\ \[Ttk\]\ themes\ ttk::checkbox\ display\ their\ indeterminate\ state\ when\ the\ widget\ variable\ is\ undefined**\n\n\[peterc\]\ 2011-01-25\ I'm\ trying\ to\ find\ a\ way\ to\ have\ the\ 'alt'\ (and\ 'default')\ \[Ttk\]\ themes\ ttk::checkbox\ display\ their\ indeterminate\ state\ when\ the\ widget\ variable\ is\ undefined.\ It\ works\ on\ Windows\ but\ not\ in\ these\ themes.\ It\ seems\ that\ the\ indeterminate\ state\ image\ has\ either\ never\ been\ set\ or\ has\ been\ set\ to\ the\ same\ image\ as\ \"off\".\n\nI'm\ hoping\ the\ fix\ is\ something\ I\ can\ put\ at\ the\ start\ of\ my\ own\ scripts\ (after\ package\ require\ Ttk),\ rather\ than\ being\ an\ edit\ in\ Ttk's\ source,\ so\ I\ don't\ have\ to\ update\ Ttk's\ source\ every\ time\ I\ update\ Ttk.\ I'm\ happy\ to\ run\ up\ my\ own\ indeterminate\ state\ images,\ assuming\ that's\ part\ of\ the\ solution.\n\n----\n**Difference\ in\ the\ types\ of\ objects\ returned\ with\ 'array\ get'\ when\ moving\ from\ 8.4\ to\ 8.5**\n\[JonC\]\ Jan-21-2011\ In\ moving\ from\ 8.4\ to\ 8.5\ we\ see\ a\ difference\ in\ the\ types\ of\ objects\ returned\ with\ 'array\ get.\ The\ otype\ command\ returns\ the\ typePtr->name\ from\ the\ object\ (based\ on\ the\ Islist\ c\ code\ from\ the\ wiki).\n\n======\narray\ set\ arr\ \[list\ a\ 1\ b\ 2\ c\ \[list\ 3\]\ d\ \[list\ 4\ 5\]\]\nputs\ \"from\ array\"\nforeach\ a\ \[array\ names\ arr\]\ \{\ puts\ \"\[otype\ \$arr(\$a)\]\ \$arr(\$a)\"\ \}\nputs\ \"from\ get\"\nforeach\ a\ \[array\ get\ arr\]\ \{\ puts\ \"\[otype\ \$a\]\ \$a\"\ \}\n======\n\nIn\ 8.4.9\ the\ values\ in\ the\ array\ retrieved\ with\ 'array\ get'\ are\ still\ lists.\n\n======\n%\ load\ otype.so\n%\ \ source\ check_array.tcl\nfrom\ array\nlist\ 4\ 5\nnone\ 1\nnone\ 2\nlist\ 3\nfrom\ get\nnone\ d\nlist\ 4\ 5\nnone\ a\nnone\ 1\nnone\ b\nnone\ 2\nnone\ c\nlist\ 3\n%\ \n======\n\nIn\ 8.5.1\ they\ turn\ into\ strings\ when\ using\ 'array\ get'.\n\n======\n%\ load\ otype.so\n%\ \ source\ check_array.tcl\nfrom\ array\nlist\ 4\ 5\nnone\ 1\nnone\ 2\nlist\ 3\nfrom\ get\nnone\ d\nnone\ 4\ 5\nnone\ a\nnone\ 1\nnone\ b\nnone\ 2\nnone\ c\nnone\ 3\n======\n\nWhy\ does\ this\ happen?\ \ In\ our\ actual\ application\ we\ have\ other\ object\ types\ some\ of\ which\ may\ be\ expensive\ to\ construct.\n\n--------------\nEDIT:\ It\ didn't\ timestamp\ my\ edit,\ so\ I'll\ add\ it\ below\ manually.\n\n----\n**\ Question\ regarding\ lappend's\ adding\ the\ bounding\ braces\ to\ each\ list\ element\ **\n\n2011-12-01\ LtDrebin\ I\ have\ a\ simple\ question\ regarding\ lappend.\ In\ the\ following\ script:\n\n======\nset\ c\ varia\[34\]ble\nset\ p\ \[list\]\nset\ pins\ \"YC\ YE\"\nforeach\ pin\ \$pins\ \{\n\ \ \ lappend\ p\ \$c/\$pin\n\}\n======\nan\ echo\ \$p\ will\ display\ the\ following:\ \{varia\[\[34\]ble/YC\}\ \{varia\[\[34\]ble/YE\}.\ \ Why\ is\ lappend\ adding\ the\ bounding\ braces\ to\ each\ list\ element?\ I\ want\ the\ output\ to\ be:\ varia\[\[34\]ble/YC\ varia\[\[34\]ble/YE\n\nThe\ variable\ c\ has\ brackets\ around\ the\ 34.\ It\ is\ being\ interpreted\ as\ an\ image\ link\ here.\n\nI\ have\ also\ tried\ setting\ each\ new\ element\ to\ variable\ p\ as\ a\ separate\ variable\ and\ then\ appending\ just\ that\ variable,\ but\ I\ get\ the\ same\ result.\n\nI\ have\ a\ workaround\ to\ this\ using\ concat,\ but\ I'm\ curious\ as\ to\ why\ lappend\ is\ behaving\ this\ way.\ It\ seems\ that\ the\ brackets\ in\ the\ variable\ c\ are\ causing\ this.\ If\ c\ only\ has\ a\ slash\ in\ it,\ for\ instance,\ it\ seems\ to\ work\ correctly.\n\nMy\ workaround,\ fyi:\n\n======\nset\ c\ varia\[34\]ble\nset\ p\ \[list\]\nset\ pins\ \"YC\ YE\"\nforeach\ pin\ \$pins\ \{\n\ \ \ set\ p\ \[concat\ p\ \$c/\$pin\]\n\}\n======\n\[MG\]\ Is\ that\ exactly\ the\ script\ you're\ using?\ For\ me\ that\ results\ in\ an\ 'invalid\ command\ name\ \"34\"'\ error\ in\ the\ 'set\ c\ ..'\ statement.\ But,\ ignoring\ that\ (and\ assuming\ you're\ actually\ escaping\ them\ there,\ with\n\n\ \ set\ c\ \{varia\[34\]ble\}\n\ \ set\ c\ varia\\\[34\\\]ble\n\nor\ something\ similar),\ lappend\ isn't\ really\ adding\ curly\ braces\ -\ they're\ simply\ displayed\ in\ the\ string\ representation\ of\ the\ list.\n\n======\n\ \ %\ set\ c\ \{varia\[34\]ble\}\n\ \ varia\[34\]ble\n\ \ %\ set\ p\ \[list\]\n\ \ %\ set\ pins\ \"YC\ YE\"\n\ \ YC\ YE\n\ \ %\ foreach\ pin\ \$pins\ \{\n\ \ \ \ lappend\ p\ \$c/\$pin\n\ \ \ \ \}\n\ \ %\ set\ p\n\ \ \{varia\[34\]ble/YC\}\ \{varia\[34\]ble/YE\}\n\ \ %\ lindex\ \$p\ 0\n\ \ varia\[34\]ble/YC\n\ \ %\ join\ \$p\ \"\ \"\n\ \ varia\[34\]ble/YC\ varia\[34\]ble/YE\n======\n\nUsing\ \[join\]\ creates\ a\ \"true\"\ string\ from\ the\ list,\ which\ doesn't\ include\ the\ curly\ braces\ (which\ are\ used\ only\ to\ denote/escape\ the\ individual\ list\ elements,\ as\ they\ contain\ special\ characters).\n\n\{gwm\}\ also\ \"lindex\ \$p\ 0\"\ and\ \"lindex\ \$p\ 1\"\ return\ the\ 'true'\ elements\ of\ the\ list\ without\ the\ \{\}\;\ any\ operation\ (such\ as\ foreach\ part\ \$p\ \{...\})\ which\ uses\ the\ list\ will\ then\ use\ the\ form\ you\ expected\ for\ each\ element\ of\ the\ list.\n\n\{LtDrebin\}\ I'm\ running\ these\ scripts\ inside\ of\ a\ microchip\ development\ tool.\ It\ uses\ tcl\ for\ user-level\ scripting.\ I\ have\ tried\ both\ escaping\ the\ brackets\ and\ not,\ and\ setting\ the\ varaible\ works\ just\ fine.\ I'm\ guessing\ that\ our\ tcl\ shell\ has\ some\ sort\ of\ protection\ for\ brackets,\ as\ many\ of\ the\ instances\ in\ a\ microchip\ have\ all\ sorts\ of\ symbols\ used\ in\ their\ names.\n\nIt's\ probably\ more\ efficient\ to\ use\ lappend,\ then?\ I\ might\ have\ to\ use\ the\ entire\ list\ p\ as\ an\ argument\ in\ a\ later\ function.\ In\ that\ case,\ it\ will\ still\ keep\ the\ bounding\ braces.\ \ The\ function\ can\ handle\ that\ (I\ think),\ but\ it's\ not\ what\ I\ intended\ and\ I'm\ a\ perfectionist,\ dammit!\n\nWhen\ I\ use\ the\ command\ set\ c\ varia\[34\]ble,\ the\ console\ of\ my\ tool\ gives\ the\ message:\ \[\]'s\ in\ strings\ are\ used\ to\ invoke\ sub-functions,\ escape\ \[\]'s\ or\ use\ \{\}'s\ to\ define\ the\ string.\ \ I\ understand\ that,\ but\ running\ echo\ \$c\ shows\ that\ c\ was\ set\ correctly.\n\nIn\ my\ script,\ c\ will\ be\ set\ by\ a\ foreach\ statement,\ where\ c\ is\ an\ individual\ element\ of\ a\ list\ of\ all\ sorts\ of\ c's.\ The\ only\ way\ I\ can\ see\ to\ \"properly\"\ set\ c\ using\ \{\}'s\ would\ be\ to\ scrap\ the\ foreach\ and\ just\ iterate\ through\ the\ list\ of\ c's.\n\n\{LtDrebin\}\ I'm\ running\ into\ more\ problems\ with\ lappend\ adding\ extra\ braces\ to\ list\ elements.\ My\ script\ has\ a\ lot\ of\ nested\ loops\ and\ so\ I'm\ a\ bit\ concerned\ about\ runtime.\ I\ read\ that\ using\ lappend\ is\ more\ efficient\ than\ using\ concat\ to\ append\ elements\ to\ a\ list.\ If\ I\ use\ concat\ via\ the\ workaround\ above,\ the\ list\ does\ not\ contain\ extra\ braces\ (well,\ so\ far...).\ \ So,\ I\ have\ a\ few\ options\ on\ how\ to\ remove\ these\ braces\ for\ future\ operations.\n\n1)\ Use\ the\ \\\[concat\\\]\ workaround.\n2)\ After\ lappending\ everthing,\ use\ \\\[join\ \$list\\\]\ to\ convert\ it\ to\ a\ string\ with\ spaces\ in\ between.\ This\ seems\ to\ remove\ the\ extra\ braces\ and\ retains\ the\ list\ elements.\n3)\ Whenever\ I\ need\ to\ call\ an\ element\ of\ the\ list,\ use\ \\\[lindex\\\]\ or\ \\\[lrange\\\]\ (haven't\ tested\ lrange\ yet).\n\nAs\ for\ the\ reason\ why\ lappend\ is\ adding\ the\ extra\ braces,\ I\ think\ it's\ because\ the\ tcl\ parser\ is\ using\ braces\ in\ strings\ with\ brackets\ to\ keep\ the\ parser\ from\ substituting\ results\ of\ the\ bracket\ phrase,\ which\ might\ be\ seen\ as\ a\ command.\n\n\[gwm\]\ You\ might\ also\ like\ to\ experiment\ with\ append\ -\ this\ is\ like\ lappend,\ it\ adds\ at\ the\ end\ of\ the\ string,\ but\ is\ pure\ string.\ To\ retain\ the\ 'list-like'\ behaviour\ you\ need\ to\ put\ 'append\ p\ \"\ new\\\[34\\\]bit\",\ like\ this:\n\n======\nforeach\ pin\ \$pins\ \{\n\ \ \ \ append\ p\ \"\ \$c/\$pin\"\n\}\nputs\ \$p\n======\n\n--------------\n**\ Major\ memory\ leak\ bug\ in\ TclOO\ **\n\n2011-02-01\ \[gwm\]\ memory\ leak\ bug\ in\ TclOO\ (cured\ by\ 12\ Feb\ 2011).\ I\ have\ created\ the\ following\ minimal\ demo\ of\ TclOO\ which\ creates\ one\ object,\ then\ uses\ its\ only\ method\ 6\ million\ times.\n\n========\n\n\ console\ show\ \;\ update\n\ #\ make\ it\ an\ O-O\ program\ using\ oo::\n\ package\ require\ TclOO\ \n\n\ oo::class\ create\ cell\ \{\n\ \ \ \ #\ a\ general\ cell.\n\ \ \ \ method\ setcp1\ \{vv\}\ \{my\ variable\ cp1\;set\ cp1\ \$vv\}\n\ \}\n\n\ set\ a\ \[cell\ new\]\ \;#\ create\ just\ one\ object!\n\n\ set\ i\ 0\;while\ \{\$i<6000000\}\ \{\n\ \ \ \ incr\ i\;\n\ \ \ \ if\ \{!(\$i%25000)\}\ \{puts\ \"Looped\ \$i\ times\"\;update\}\n\ \ \ \ \$a\ setcp1\ 123\n\ \}\n\n\ #\ NB\ \$a\ destroy\ did\ not\ free\ the\ memory\n\n========\n\nAfter\ 6\ million\ operations\ using\ Activestate's\ 8.6.0.0.b4\ I\ had\ gobbled\ about\ 400MB\ (by\ just\ ONE\ TclOO\ object).\ Memory\ was\ still\ gobbled\ if\ you\ remove\ the\ \"my\"\ variable\n\n\ \ \ \ method\ setcp1\ \{vv\}\ \{\ variable\ cp1\;set\ cp1\ \$vv\}\n\nBut\ it\ was\ not\ gobbled\ if\ no\ variable\ was\ declared.\n\n\ \ \ \ method\ setcp1\ \{vv\}\ \{\ set\ cp1\ \$vv\}\n\n\[MS\]\ just\ ran\ this\ on\ HEAD/linux\ and\ does\ not\ see\ anything\ untoward\n\n\[GWM\]\ DKF\ reported\ to\ me\ privately\ this\ bug\ is\ cured\;\ the\ 8.6.0.0.b4\ (beta\ release)\ for\ Windows\ from\ Activestate\ gave\ this\ effect.\ I\ can\ report\ 'fully\ cured\ and\ distributed'\ on\ this\ question\ with\ 8.6.0.0.b5.\ The\ resulting\ code\ runs\ faster\ too,\ not\ surprising\ as\ wish\ doesn't\ have\ to\ keep\ on\ finding\ blocks\ of\ memory.\n\ \ \n--------------\n**\ How\ to\ call\ one's\ own\ methods\ in\ TclOO\ **\n\n2010-12-02\ \[jbr\]\ How\ to\ call\ ones\ own\ methods\ in\ TclOO?\n\nI\ don't\ do\ a\ lot\ of\ OO\ programming\ but\ I've\ tried\ snit\ and\ tcl\ oo\ on\ occasion.\ \ Today\ my\ question\ is,\ What\ best\ for\ calling\ a\ TclOO\ method\ from\ another\ method\ of\ the\ same\ object?\n\n\n\ \ \ 1.\ my\ some_method\ arg1\ arg2\ ...\n\ \ \ 2.\ \[\[self\]\]\ some_method\ arg1\ arg2\ ...\n\ \ \ 3.\ some_method\ arg1\ arg2\n\nOption\ #3\ doesn't\ appear\ to\ work,\ I\ guess\ namespace\ command\ path\ nesting\ isn't\ working\ as\ I\ thought\ it\ might?\n\n??\n\nThanks\n\n\[gwm\]\ Correct,\ option\ 3\ deliberately\ does\ not\ work.\ 1\ &\ 2\ are\ equivalent\ although\ I\ would\ suggest\ using\ 1\ so\ that\ any\ modification\ in\ a\ future\ release\ of\ TclOO\ affecting\ the\ 'my'\ operation\ would\ be\ implemented\ into\ your\ code.\n\nMethod\ 3\ is\ more\ like\ how\ C++\ would\ be\ coded\;\ use\ of\ 'my'\ ensures\ that\ any\ overridden\ method\ of\ the\ base\ class\ is\ called\ by\ methods\ in\ the\ base\ class\ which\ call\ the\ (overridden)\ method.\n\ \n--------------\n**\ How\ to\ http\ \"GET\"\ without\ using\ http\ package\ ?\ **\n\n<Start\ of\ New\ Question>\n\[Kirov\]\ How\ to\ http\ \"GET\"\ without\ using\ http\ package\ ?\n\nfconfigure\ manual\ page\ says\ :\ \"Upon\ output\ (i.e.,\ with\ puts),\ the\ I/O\ system\ translates\ newlines\ to\ the\ external\ end-of-line\ representation.\"\n\nThis\ doesn't\ work\ :\ \n\n======\nproc\ down\ \{args\}\ \{\n\ \ \ \ \ \ \ \ #\ splitting\ first\ arg\ into\ usefull\ components\n\ \ \ \ \ \ \ \ set\ srv\ \[lindex\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 2\]\n\ \ \ \ \ \ \ \ set\ tar\ \[join\ \[lrange\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 3\ end\]\ /\]\n\ \ \ \ \ \ \ \ #\ connecting\ socket\n\ \ \ \ \ \ \ \ set\ s\ \[socket\ \$srv\ 80\]\n\ \ \ \ \ \ \ \ #\ requesting\ target\ url\ via\ http\ protocol\n\ \ \ \ \ \ \ \ puts\ \$s\ \"GET\ /\$tar\ HTTP/1.0\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ puts\ \$s\ \"Host:\ \$srv\\n\\n\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ #\ check\ if\ active\ socket\n\ \ \ \ \ \ \ \ while\ \{\[gets\ \$s\ in\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ data\ handling\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \$in\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ close\ \$s\n\}\ndown\ http://www.tcl.tk/man/tcl8.5/TclCmd/fconfigure.htm\n======\n\nBut\ this\ works\ just\ fine\ :\n\n======\nproc\ down\ \{args\}\ \{\n\ \ \ \ \ \ \ \ #\ splitting\ first\ arg\ into\ usefull\ components\n\ \ \ \ \ \ \ \ set\ srv\ \[lindex\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 2\]\n\ \ \ \ \ \ \ \ set\ tar\ \[join\ \[lrange\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 3\ end\]\ /\]\n\ \ \ \ \ \ \ \ #\ connecting\ socket\n\ \ \ \ \ \ \ \ set\ s\ \[socket\ \$srv\ 80\]\n\ \ \ \ \ \ \ \ #\ requesting\ target\ url\ via\ http\ protocol\n\ \ \ \ \ \ \ \ puts\ \$s\ \"GET\ /\$tar\ HTTP/1.0\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ puts\ \$s\ \"Host:\ \$srv\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ puts\ \$s\ \"\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ #\ check\ if\ active\ socket\n\ \ \ \ \ \ \ \ while\ \{\[gets\ \$s\ in\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ data\ handling\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \$in\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ close\ \$s\n\}\ndown\ http://www.tcl.tk/man/tcl8.5/TclCmd/fconfigure.htm\n======\n\nMy\ question\ is\ :\ Why\ ?\n<End\ of\ Question>\n\n<Answer>\n\n2011-11-20\ \[AMW\]\nThe\ two\ versions\ do\ NOT\ send\ identical\ requests!\n\nVersion\ 1\ sends\ '''two\ '''empty\ lines\ (three\ newlines)\ after\ the\ last\ HTTP\ header\ line\ (\"Host:\"...):\ two\ newlines\ generated\ by\ \"\\n\\n\",\ a\ third\ being\ added\ by\ the\ '''puts'''\ command\ when\ called\ without\ ''-nonewline''.\n\nVersion\ 2\ correctly\ sends\ just\ '''one'''\ empty\ line.\n\nVersion\ 1\ could\ be\ fixed\ in\ either\ of\ the\ following\ ways:\n======\nputs\ -nonewline\ \$s\ \"Host:\ \$srv\\n\\n\"\nputs\ \$s\ \"Host:\ \$srv\\n\"\n======\n\nBy\ the\ way:\ a\ single\ call\ to\ '''flush\ \$s'''\ after\ sending\ the\ last\ byte\ would\ suffice,\ and\ will\ enhancen\ performance\ on\ connections\ with\ poor\ bandwith.\n\n----\n**\ Too\ many\ initializer's\ errors\ in\ MS\ VS\ 2005\;\ while\ writing\ a\ Tcl\ extension\ for\ C++)**\n\n<Start\ of\ New\ Question>\n\[To\ Many\ Initiallizers\ error\ in\ MS\ VS\ 2005\]\nHello\ everyone,\ \nI\ am\ trying\ to\ write\ a\ Tcl\ extension\ for\ C++.\ Below\ is\ my\ code.\n\nint\ DLLEXPORT\ \nLitePoint_Init(Tcl_Interp\ *interp)\n\{\n\ \ \ if\ (Tcl_InitStubs(interp,TCL_VERSION,0)==NULL)\ \{\ \ \n\ \ \ \ \ \ \ \ \ \ return\ TCL_ERROR\;\n\ \ \ \ \ \ \ \ \}\n\ \ \ if\ (Tcl_PkgProvide(interp,\ \"Hello\",\ \"1.0\")\ ==\ TCL_ERROR)\ \{\n\ \ \ \ \ \ \ \ \ return\ TCL_ERROR\;\n\ \ \ \ \ \}\n\n\ \ \ Tcl_Command\ Tcl_CreateObjCommand(interp,\ \"connect\",\ ConnectSystem\ ,\ NULL,\ NULL)\;\n\ \ \ return\ TCL_OK\;\n\}\n\ \ \nBelow\ is\ the\ ConnectSystem\ proc.\n\nstatic\ int\ ConnectSystem(ClientData\ clientData,\ Tcl_Interp\ *interp,\ int\ objc,\ Tcl_Obj\ *\ const\ objv\[\])\n\{\n\ \ \ \ \ \ \ \ int\ LP_InitTester(char\ *ipAddress)\;\n\ \ \ \ \ \ \ \ return\ TCL_OK\;\n\}\n\nConnectSystem\ is\ calling\ another\ function\ LP_InitTester().\ I\ am\ using\ MS\ VC++\ 2005.\ When\ i\ try\ to\ build\ it,\ it's\ giving\ me\ \"\ Too\ many\ initiallizers\ \"\ pointing\ at\ Tcl_Command\ Tcl_CreateObjCommand().\ How\ do\ i\ resolve\ this.\n\nThanks\n<End\ of\ Question>\n<Answer>\nTcl_CreateObjCommand(interp,\ \"connect\",\ ConnectSystem\ ,\ NULL,\ NULL)\;\n\ndoes\ not\ require\ the\ type\ of\ its\ return\ argument\ (Tcl_Command)\ to\ be\ declared\ too.\ Compiler\ gets\ that\ from\ the\ tcl.h\ file.\ just\ omit\ Tcl_Command\ from\ your\ code.\n\n---------------\n**\ Increasing\ the\ number\ of\ elements\ in\ a\ graph\ option\ **\n\n\[KESHAV\]\ -\ 2010-08-19\ 00:37:40:\ HI,\ I\ am\ using\ a\ graph\ command\ from\ \[BLT\]/TK.\nThe\ -xdata\ and\ -ydata\ options\ takes\ only\ 349524\ elements.\ \ Is\ there\ any\ way\ to\nincrease\ it?\ \ Or\ any\ settings\ to\ overcome\ this\ limitation?\ \ Please\ help\n\n\ \[gold\]\ 2010-10-11,\ found\ ref.\ \n\ \ http://www.usenix.org/events/tcl98/tcl98/full_papers/howlett/howlett_html/howlett.html\n\n----\n**\ Problem\ with\ the\ thrashcan\ object\ for\ canvas\ on\ Canvas\ Object\ Movement\ **\ \n\ \ \n\[gold\]\ 2Aug2010:\ I\ loaded\ a\ thrashcan\ object\ for\ canvas\ on\ Canvas\ Object\ Movement\ Example,\ [\;Canvas\ Object\ Movement\ Example\].\ \ This\ trashcan\ is\ sticking\ a\ little,eg\ sometimes\ the\ object\ does\ not\ disappear\ over\ the\ X\ on\ the\ first\ move\ or\ entry.\ \ Can\ somebody\ fix\ this\ item?\ Thanks.\ The\ deep\ patch\ appears\ to\ be:\n\ \ \ \ \ \ \ if\ \{\ \$y\ >=\ 20\ &&\ \$y\ <=\ 70\ \}\n\ \ \ \ \ \ \ \{\ if\ \{\ \$x\ >=\ 20\ &&\ \$x\ <=\ 70\ \}\n\ \ \ \ \ \ \ \{\$w\ delete\ obj_\$tilex\ \}\ \}\ #maybe\ should\ \[lindex\ obj_\$tilex\ 1\ \]etc\ ?\n\n----\n**\ Drawing\ a\ new\ series\ or\ new\ dataplot\ using\ Tklib\ Plotchart\ **\n\[JULY\]\ -\ 2010-07-30\n\nQuestion:\ Hi,\ I\ am\ using\ TKlib\ Plotchart.\ Once\ I\ have\ drawn\ a\ plot,\ say\ an\ xyplot,\ I\ want\ to\ clear\ it\ and\ draw\ a\ new\ series\ or\ new\ dataplot.\ I\ am\ unable\ to\ find\ any\ command\ to\ clear\ the\ plots\ and\ draw\ a\ new\ one.\ I\ tried\ using\ the\ destroy\ command,\ but\ it\ doesn't\ work.\n\nI\ don't\ want\ to\ destroy\ the\ whole\ canvas\ to\ plot\ all\ over\ again.\ Any\ suggestions/comments\ are\ appreciated!\n\n----\n\[gold\]\ Possible\ to\ 1)raise\ or\ lower\ the\ previous\ work\ on\ the\ canvas,\ 2)raise\ a\ncovering\ object\ (white\ rectangle)\ or\ 3)write\ on\ top?\ \ I\ installed\ a\ raise\ or\nlower\ button\ in\ \[Chinese\ Xianqi\ Chessboard\].\ \ grid\ is\ a\ tag\ on\ created\ objects\ in\ canvas.\n\n\ \ \ \ \ \ \ \ .cv\ itemconfigure\ grid\ -fill\ blue\ \n\ \ \ \ \ \ \ \ if\ \{\ \$state2\ ==\ 1\ \}\ \{\ .cv\ raise\ grid\ \;\}\ \n\ \ \ \ \ \ \ \ if\ \{\ \$state2\ ==\ 2\ \}\ \{\ .cv\ lower\ grid\ \;\}\ \n\nand\ \[Simple\ Canvas\ Demo\]\ Also,\ look\ at\ my\ \[gold\]\ \ \ perambulations\ with\ \$c\naddtag\ point\ withtag\ \$item\ &\ \$w\ addtag\ selected\ withtag\ current\ on\ \[Ask,\ and\ it\ shall\ be\ given\ #\ 7\].\ If\ you\ can\ add\ a\ tag\ to\ current\ and\ selected\ plot_1\ like\ \$w\ addtag\ plot_1\ withtag\ current,\ you\ can\ raise\ or\ lower\ plot_1\ with\ .c\ raise\ plot_1\ or\ .c\ lower\ plot_1.(or\ .c\ lower\ all?)\n\n----\n**\ Low\ volume\ level\ for\ a\ 24\ bit\ wave\ file\ using\ snack\ **\n\nSergey,\ 10\ july\ 2010\n\nI\ have\ a\ problem\ with\ snack,\ which\ i\ can't\ find\ solution\ for.\n\nIf\ i\ open\ a\ 24\ bit\ wave\ file\ using\ snack\ and\ try\ to\ save\ it,\ resulting\ wave\ file\ has\ extremely\ low\ volume\ level,\ but\ if\ file\ is\ 16\ or\ 32\ bit,\ everything\ goes\ fine.\ Same\ thing\ happens\ in\ wavesurfer,\ so\ it's\ likely\ to\ be\ snack\ bug.\n\nDoes\ anyone\ know\ about\ this\ bug?\ Is\ there\ any\ workaround?\nThanks\ in\ advance.\n\n----\n**\ Making\ a\ tk\ image\ from\ a\ tk\ widget\ **\n\[ARR\]\ -\ 2010-06-30\n\nQuestion\ 1:\ Hello\ specialists,\ how\ can\ I\ make\ a\ tk\ image\ from\ a\ tk\ widget?\n\nAnswer\ 1:\ use\ the\ image\ command:\ '''image\ create\ photo\ widget_image\ -format\ window\ -data\ \$widget'''\n\nQuestion\ 2:\ This\ is\ fine,\ but\ the\ widget\ must\ be\ fully\ visible.\ So,\ how\ can\ I\ make\ an\ image\ from\ a\ withdrawn\ widget?\ Any\ ideas\ anybody?\n\nAnswer\ 2:\ ???\n\n----\n**\ Errors\ with\ tests\ for\ enable\ threads\ **\ \n\n\[rhinerfeld\]\ -\ 2009-09-02\ 18:56:28\n\nI\ have\ just\ downloaded\ the\ TK8.5.7\ build.\ \ I\ am\ using\ Linux\ Fedora\ Core\ 10\ as\ an\ OS.\ \ I\ configure\ for\ --enable-threads\ and\ then\ make\ test.\ \ I\ receive\ a\ number\ of\ errors\ from\ the\ tests\ that\ are\ run.\n\n\ Tests\ ended\ at\ Wed\ Sep\ 02\ 18:45:24\ EDT\ 2009\n\ all.tcl:\ \ \ \ \ \ \ \ Total\ \ \ \ \ \ \ \ 8788\ \ \ \ \ \ \ \ Passed\ \ \ \ \ \ \ \ 7776\ \ \ \ \ \ \ \ Skipped\ \ \ \ \ \ \ \ 945\ \ \ \ \ \ \ \ Failed\ \ \ \ \ \ \ \ 67\n\ Sourced\ 87\ Test\ Files.\n\ Files\ with\ failing\ tests:\ canvText.test\ entry.test\ filebox.test\ font.test\ scrollbar.test\ spinbox.test\ text.test\ textDisp.test\ textImage.test\ textTag.test\ textWind.test\ unixEmbed.test\ unixFont.test\ unixSelect.test\ unixWm.test\ wm.test\n\ Number\ of\ tests\ skipped\ for\ each\ constraint:\n\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ altDisplay\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ aqua\n\ \ \ \ \ \ \ \ 16\ \ \ \ \ \ \ \ colorsFree\n\ \ \ \ \ \ \ \ 3\ \ \ \ \ \ \ \ colorsLeftover\n\ \ \ \ \ \ \ \ 21\ \ \ \ \ \ \ \ defaultPseudocolor8\n\ \ \ \ \ \ \ \ 10\ \ \ \ \ \ \ \ emptyTest\n\ \ \ \ \ \ \ \ 139\ \ \ \ \ \ \ \ fonts\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ havePseudocolorVisual\n\ \ \ \ \ \ \ \ 6\ \ \ \ \ \ \ \ knownBug\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ memory\n\ \ \ \ \ \ \ \ 103\ \ \ \ \ \ \ \ nonPortable\n\ \ \ \ \ \ \ \ 33\ \ \ \ \ \ \ \ nt\n\ \ \ \ \ \ \ \ 5\ \ \ \ \ \ \ \ pseudocolor8\n\ \ \ \ \ \ \ \ 72\ \ \ \ \ \ \ \ secureserver\n\ \ \ \ \ \ \ \ 11\ \ \ \ \ \ \ \ testmetrics\n\ \ \ \ \ \ \ \ 7\ \ \ \ \ \ \ \ testwinevent\n\ \ \ \ \ \ \ \ 141\ \ \ \ \ \ \ \ textfonts\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ unthreaded\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ userInteraction\n\ \ \ \ \ \ \ \ 310\ \ \ \ \ \ \ \ win\n\ \ \ \ \ \ \ \ 51\ \ \ \ \ \ \ \ winSend\n\nIs\ this\ normal?\n\n----\n**\ Errors\ in\ a\ Hello\ world\ code\ (attempting\ to\ make\ an\ IDE\ in\ C)\ **\n\n\[arin\]\ -\ 2010-06-09\ 02:10:43\n\nhi,\ i\ am\ working\ on\ an\ ubuntu\ system.\ My\ aim\ is\ to\ basically\ make\ an\ IDE\ in\ C\ language\ using\ GUI\ tools\ from\ TCL/TK.\ I\ installed\ tcl\ 8.4,\ tk8.4,\ tcl8.4-dev,\ tk8.4-dev\ and\ have\ the\ tk.h\ and\ tcl.h\ headers\ file\ in\ my\ system.\ But,\ when\ I\ am\ running\ a\ basic\ hello\ world\ program\ it's\ showing\ a\ hell\ lot\ of\ errors.\n\n\ #include\ \"tk.h\"\n\ #include\ \"stdio.h\"\n\ void\ hello()\ \{\n\ \ \ \ \ \ puts(\"Hello\ C++/Tk!\")\;\n\ \}\n\ int\ main(int,\ char\ *argv\[\])\n\ \{\ \ \ \ \ init(argv\[0\])\;\n\ \ \ \ \ \ button(\".b\")\ -text(\"Say\ Hello\")\ -command(hello)\;\n\ \ \ \ \ \ pack(\".b\")\ -padx(20)\ -pady(6)\;\n\ \}\n\nSome\ of\ the\ errors\ are\ \n\n\ tkDecls.h:644:\ error:\ expected\ declaration\ specifiers\ before\ ‘EXTERN’\n\ \n\ /usr/include/libio.h:488:\ error:\ expected\ ‘)’\ before\ ‘*’\ token\n\ \n\ In\ file\ included\ from\ tk.h:1559,\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ from\ new1.c:1:\n\ tkDecls.h:1196:\ error:\ storage\ class\ specified\ for\ parameter\ ‘TkStubs’\n\ tkDecls.h:1201:\ error:\ expected\ ‘=’,\ ‘,’,\ ‘\;’,\ ‘asm’\ or\ ‘__attribute__’\ before\ ‘*’\ token\n\ \n\ /usr/include/stdio.h:145:\ error:\ storage\ class\ specified\ for\ parameter\ ‘stdin’\n\ \n\ tk.h:1273:\ error:\ declaration\ for\ parameter\ ‘Tk_PhotoHandle’\ but\ no\ such\ parameter\n\nCan\ anyone\ please\ tell\ me\ how\ can\ I\ rectify\ these\ errors?\ Please\ help...\n\n\[AM\]\ A\ better\ place\ to\ ask\ such\ questions\ is\ comp.lang.tcl\n\n----\n**\ Getting\ rid\ of\ a\ console\ window\ for\ a\ game\ listed\ at\ the\ bottom\ of\ Mahjong\ Style\ Deletion\ page\ 99\n\n\[gold\]\ 5jun2010.\ I\ have\ some\ starter\ code\ for\ a\ game\ listed\ at\ the\ bottom\ of\ Mahjong\ Style\ Deletion\ page.\n\nwhen\ i\ drop\ the\ cheap_poker.tcl\ into\ etcl,\ i\ get\ a\ console\ window\ that\ i\ don't\ want.\ I\ have\ a\ statement\ for\ console\ hide\ but\ doesn't\ seem\ to\ work.\ How\ do\ i\ get\ rid\ of\ console\ window?\ thanks,\[gold\]\n\n\[AMG\]:\ \[\[\[console\]\ hide\]\]\ works\ just\ fine\ for\ me.\ \ I\ don't\ know\ what\ your\ problem\ could\ be.\ \ I'm\ not\ familiar\ with\ \[eTcl\]\;\ maybe\ it's\ been\ customized\ somehow.\n\nBy\ the\ way,\ do\ you\ realize\ your\ last\ edit\ deleted\ this\ page?\ \ Please\ be\ more\ careful\ in\ the\ future!\n\n\[gold\]\ Problem\ gone.\ \ I'll\ close\ out\ this\ question.\ Have\ rewritten\ code\ leaving\ out\ some\ upvar\ and\ canvas\ name\ substitutions.\ Problem\ gone.\n\n\n\ \ \ \ \ rewritten\ code\ left\ at\ \[Mahjong_Style_Deletion\]\n\n----\n**\ Running\ \"cd\"\ ,\ \"source\ <script>\"\ etc.\ commands\ using\ a\ GUI\ running\ all\ shell\ command\ **\n\n\[raja\]\ May\ 11\ 2010:\ Hi,\ I\ have\ created\ one\ simple\ GUI\ application\ using\ tcl\ with\ one\ \"entry\"\ widget\ and\ \"Run\"\ button.My\ intention\ is\ to\ use\ this\ GUI\ to\ run\ all\ shell\ commands\ (like\ \"cd\"\ and\ other\ commands(I\ will\ enter\ command\ using\ \"entry\"\ widget\ and\ click\ on\ \"Run\"\ button\ to\ execute).\ i\ am\ able\ to\ run\ few\ commands\ like\ \"ls\",\"date\",\ \"cat\"\ etc..\ but\ i\ couldn't\ run\ \"cd\"\ ,\ \"source\ <script>\"\ etc.\ commands.\ \ Could\ some\ one\ please\ help\ me\ in\ this?\n\nThanks\ for\ your\ time.\n\n\[LV\]\ \[cd\]\ is\ not\ a\ normal\ command.\ It\ has\ to\ take\ action\ on\ the\ current\ process,\ but\ programs\ like\ you\ describe\ typically\ invoke\ exec\ or\ an\ opened\ pipe\ to\ execute\ commands\ in\ a\ second\ process.\ This\ means\ that\ things\ work\ something\ like\ this:\n\n===\nProcess\ A:\ User\ logged\ into\ system\nProcess\ B:\ User's\ tk\ program\nProcess\ C:\ User\ types\ in\ \"cd\ /tmp\"\ and\ tk\ program\ invokes\ \"exec\ cd\ /tmp\"\n===\n\nWhen\ Process\ C\ completes,\ it\ goes\ away,\ and\ user\ is\ back\ in\ Process\ B.\n\nThe\ way\ to\ handle\ this\ is\ to\ add\ some\ code\ in\ your\ program\ that\ looks\ at\ the\ string\ before\ executing\ it.\ If\ the\ string\ begins\ with\ \"cd\ \",\ then\ don't\ use\ exec,\ but\ call\ cd\ with\ the\ rest\ of\ the\ line\ as\ an\ argument.\n\nThat\ should\ take\ care\ of\ this\ problem.\ Depending\ on\ what\ platform\ and\ shell\ you\ are\ using,\ there\ are\ probably\ some\ additional\ commands\ you\ will\ end\ up\ having\ to\ add\ special\ code\ for\ as\ well.\n\n\[RAJA\]\ May\ 12\ 2010:\ Thank\ you\ very\ much\ for\ your\ response.\ \ i\ have\ tried\ your\ suggestion\ but\ still\ i\ am\ getting\ error\ like\ \"couldn't\ execute\ \"cd\":\ permission\ denied\ \[\[for\ setenv\ commands\ i\ am\ getting\ \"\ couldn't\ execute\ \"setenv\":\ no\ such\ file\ or\ directory\ \"\ error\]\].\ \ I\ believe\ only\ shell\ built-in\ command\ i\ am\ getting\ errors.\ \ All\ other\ commands\ (ls\ ,\ date\ ,\ pwd\ etc..)\ are\ working\ fine.\n\nhere\ is\ my\ \"Run\"\ procedure.\n\n\ button\ .top.quit\ -text\ Quit\ -command\ exit\ \ \;\ \n\ set\ but\ \[button\ .top.run\ -text\ \"Run\ it\"\ -command\ Run\]\ \;\n\ pack\ .top.quit\ .top.run\ -side\ right\ \ \;\ \n\ \n\ label\ .top.l\ -text\ Command:\ -padx\ 0\ \ \;\ \n\ entry\ .top.cmd\ -width\ 20\ -relief\ sunken\ -textvariable\ command\ \ \;\n\ proc\ Run\ \{\}\ \{\n\ \ \ \ \ \ \ \ \ global\ command\ input\ log\ but\n\ \ \ \ \ \ \ \ \ if\ \[catch\ \{open\ \"|\$command\ |&\ cat\"\}\ input\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$input\\n\n\ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fileevent\ \$input\ readable\ Log\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$command\\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$but\ config\ -text\ Stop\ -command\ Stop\n\ \ \ \ \ \ \ \ \ \}\n\ \}\n\nI\ have\ added\ all\ other\ required\ things\ into\ my\ application.\ \"log\"\ in\ the\ above\ code\ is\ text\ widget\ to\ log\ the\ output.\n\nI\ have\ added\ another\ if\ statement\ in\ the\ above\ \"Run\"\ procedure\ to\ tackle\ \"cd\"\ command\ but\ didnt\ work.\ Please\ help\ me\ in\ this\ issue.\n\nMy\ hardware\ config\ is\ :\ Linux\ 2.6.9-67.ELlargesmp\ x86_64\ x86_64\ x86_64\ GNU/Linux\ (from\ \"uname\"\ command)\n\n\[AMG\]:\ cd\ isn't\ the\ only\ command\ that\ modifies\ the\ shell's\ internal\ state\;\ setenv\ is\ another.\ \ Both\ are\ shell\ built-in\ commands,\ which\ means\ they\ aren't\ actual\ executable\ files\ on\ disk.\ \ (Unless\ you're\ using\ \[execline\].)\n\nOne\ approach\ is\ to\ create\ a\ single\ instance\ of\ the\ shell\ and\ feed\ it\ a\ sequence\ of\ command\ lines,\ rather\ than\ start\ a\ new\ shell\ for\ each\ command.\ \ The\ shell\ can\ internally\ decide\ whether\ the\ command\ line\ is\ a\ program\ on\ disk\ or\ a\ built-in,\ and\ it\ can\ remember\ all\ its\ state\ changes.\ \ At\ this\ point\ you\ will\ have\ reimplemented\ \[xterm\],\ at\ a\ very\ basic\ level.\n\nAnother\ approach\ is\ to\ handle\ cd\ and\ all\ other\ built-in\ commands\ yourself\ (like\ \[LV\]\ suggests),\ and\ only\ \[\[\[exec\]\]\]\ or\ \[\[\[open\]\ |\]\]\ external\ programs.\ \ At\ this\ point\ you\ will\ have\ reimplemented\ the\ shell.\ \ If\ you\ go\ this\ route,\ you\ will\ have\ to\ decide\ what\ set\ of\ built-ins\ you\ want\ and\ what\ their\ syntax\ should\ be.\ \ If\ your\ built-in\ commands\ are\ equal\ to\ or\ a\ superset\ of\ the\ Tcl\ commands,\ you\ will\ basically\ be\ reimplementing\ \[Tkcon\],\ which\ already\ falls\ back\ on\ external\ programs\ when\ the\ Tcl\ interpreter\ can't\ internally\ handle\ a\ command.\n\n\[raja\]\ May\ 12\ 2010:\ Thank\ you\ AMG.\ so\ in\ short,\ I\ have\ 2\ options\ one\ is\ to\ implement/create\ xterm\ or\ create/handle\ built-in\ commands\ on\ my\ own\ using\ Tkcon.I\ am\ just\ beginner\ in\ Tcl.\ so\ i\ didn't\ have\ a\ idea\ of\ Tkcon.\ Can\ we\ just\ modify\ below\ code\ to\ handle\ shell\ build-in\ commands.\ BTM\ how\ can\ we\ create\ a\ new\ shell\ using\ this\ GUI/Tcl\ code\ (i.e\ using\ buttons\ and\ entry\ and\ Run\ procedure).\ \ I\ would\ appreciate\ your\ help.\ \n\n\ proc\ Run\ \{\}\ \{\n\ \ \ \ \ \ \ \ \ global\ command\ input\ log\ but\n\ \ \ \ \ \ \ \ \ if\ \[catch\ \{open\ \"|\$command\ |&\ cat\"\}\ input\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$input\\n\n\ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fileevent\ \$input\ readable\ Log\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$command\\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$but\ config\ -text\ Stop\ -command\ Stop\n\ \ \ \ \ \ \ \ \ \}\n\ \}\n\nThank\ you.\n\n\[LV\]\ Sorry,\ but\ that\ proc\ is\ not\ easily\ modified\ to\ do\ what\ you\ want.\n\n\[raja\]\ May\ 14\ 2010:\ i\ tried\ below\ code\ to\ get\ my\ application\ working.But\ it\ didnt.\ Now\ i\ have\ to\ create\ a\ single\ instance\ of\ the\ shell\ and\ feed\ it\ a\ sequence\ of\ commands\ in\ tcl.right\ now\ i\ dont\ have\ any\ clue\ how\ to\ create\ this\ but\ i\ will\ try.\ \ \n\n======\nif\ \{\ \[string\ first\ \"cd\"\ \[string\ tolower\ \$getcommand\]\]\ !=\ -1\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \[catch\ \{exec\ \"\$getcommand\ |&\ cat\"\}\ input\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ pwd\ \[pwd\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cd\ \$pwd\ \ \ \ \ \ \ \ \ #as\ a\ example\ cd\ to\ pwd\ \ \ #cd\ is\ a\ tcl\ built\ in\ command\n\ \ \ \ \ \ \ \ \ \}\n======\n\nor\n\n======\nif\ \{\ \[string\ first\ \"cd\"\ \[string\ tolower\ \$getcommand\]\]\ !=\ -1\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ pwd\ \[pwd\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cd\ \$pwd\ \ #cd\ is\ a\ tcl\ built\ in\ command\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #exec\ \"cd\ \$pwd\"\n\ \ \ \ \ \ \ \ \ \}\n======\n\[AMG\]:\ That's\ not\ how\ comments\ work.\ \ Unless\ #\ is\ the\ first\ character\ of\ a\ command,\ it\ has\ no\ special\ meaning.\ \ Either\ put\ it\ on\ a\ line\ by\ itself,\ or\ put\ a\ semicolon\ (\;)\ before\ it,\ as\ in\ \"cd\ \$pwd\ \;#\ cd\ is\ a\ tcl\ built\ in\ command\".\n\nTo\ create\ a\ single\ instance\ of\ the\ shell,\ use\ \[\[\[open\]\ |\]\],\ like\ you\ did\ in\ your\ first\ code\ sample,\ but\ the\ command\ you\ open\ is\ the\ shell.\ \ The\ shell\ will\ execute\ commands\ it\ receives\ on\ stdin,\ and\ it\ will\ direct\ the\ output\ of\ the\ commands\ to\ stdout.\ \ I\ assume\ you're\ using\ \[csh\]\ because\ you\ mentioned\ setenv.\n\nHere's\ code!\n\n======\npackage\ require\ Tk\nset\ shell\ csh\nproc\ log\ \{text\ \{tags\ \{\}\}\}\ \{\n\ \ \ \ .output\ configure\ -state\ normal\n\ \ \ \ .output\ insert\ end\ \$text\ \$tags\n\ \ \ \ .output\ configure\ -state\ disabled\n\ \ \ \ .output\ see\ end\n\}\nproc\ transmit\ \{\}\ \{\n\ \ \ \ global\ chan\n\ \ \ \ log\ \"\\\$\ \[.input\ get\]\\n\"\ input\n\ \ \ \ puts\ \$chan\ \[.input\ get\]\n\ \ \ \ .input\ delete\ 0\ end\n\}\nproc\ receive\ \{\}\ \{\n\ \ \ \ global\ chan\n\ \ \ \ log\ \[read\ \$chan\]\n\}\nentry\ .input\nscrollbar\ .scroll\ -orient\ vertical\ -command\ \{.output\ yview\}\ntext\ .output\ -state\ disabled\ -yscrollcommand\ \{.scroll\ set\}\n.output\ tag\ configure\ input\ -background\ gray\npack\ .input\ -fill\ x\ -side\ bottom\npack\ .scroll\ -fill\ y\ -side\ right\npack\ .output\ -fill\ both\ -expand\ 1\nfocus\ .input\nset\ chan\ \[open\ |\$shell\ a+\]\nfconfigure\ \$chan\ -buffering\ line\ -blocking\ 0\nfileevent\ \$chan\ readable\ receive\nbind\ .input\ <Return>\ transmit\n======\n\nIf\ I\ understand\ what\ you're\ asking\ for,\ the\ above\ code\ does\ what\ you\ want,\ and\ we\ should\ move\ this\ discussion\ to\ its\ own\ Wiki\ page.\n\nUnfortunately,\ this\ code\ only\ handles\ the\ shell's\ stdin\ and\ stdout\;\ it\ ignores\ stderr.\ \ I\ haven't\ figured\ out\ how\ to\ effectively\ and\ portably\ handle\ stderr.\ \ Right\ now\ the\ only\ thing\ I\ can\ think\ of\ is\ to\ use\ \[exec\]\ to\ run\ mknod\ \[http://linux.die.net/man/1/mknod\]\ to\ make\ a\ FIFO,\ open\ the\ FIFO\ for\ reading,\ monitor\ it\ in\ the\ same\ way\ \$chan\ is\ monitored,\ and\ redirect\ the\ shell's\ stderr\ to\ that\ FIFO\ using\ '''2>'''\ notation.\ \ I'd\ like\ to\ do\ this\ all\ in\ \[pure-Tcl\]\ with\ reflected\ channels,\ but\ this\ is\ not\ possible\ at\ the\ moment.\n\n\[raja\]\ 17-05-10\ Thank\ you\ very\ much\ AMG.It\ is\ working\ fine\ now.\ The\ only\ problem\ I\ am\ seeing\ now\ is\ when\ I\ source\ any\ file(file\ with\ multiple\ commands)\ it\ is\ not\ working\ properly\ but\ when\ I\ execute\ commands\ one\ by\ one\ then\ it\ is\ working\ fine.\ Some\ times\ it\ is\ showing\ \"ctrl-m\"\ characters\ (after\ and\ before\ filename)\ while\ i\ am\ executing\ \"ls\"\ command.\n\n\[AMG\]:\ Sounds\ like\ a\ DOS/Unix\ line\ ending\ problem.\ \ Are\ you\ using\ a\ Windows\ text\ editor\ to\ create\ files\ you're\ reading\ on\ Unix?\ \ Check\ if\ there\ are\ ctrl-m\ (carriage\ return)\ characters\ in\ the\ file\ you're\ sourcing.\ \ I\ assume\ you're\ asking\ csh\ to\ do\ the\ sourcing,\ not\ Tcl.\n\nHere's\ a\ version\ of\ the\ code\ that\ separately\ handles\ stdout\ and\ stderr.\ \ It\ turns\ out\ this\ ''is''\ possible\ in\ \[pure-Tcl\],\ if\ you\ have\ Tcl\ 8.6.\ \ For\ fun,\ I\ threw\ in\ some\ \[apply\]\ magic\ to\ demonstrate\ how\ to\ make\ \[fileevent\]\ and\ anonymous\ \[lambda\]s\ instead\ of\ named\ \[proc\]s.\ \ Also\ I\ switched\ to\ the\ \[Ttk\]\ widgets\ and\ the\ \[chan\]\ \[ensemble\]\ commands,\ and\ I\ added\ end-of-file\ detection.\n\n======\npackage\ require\ Tcl\ 8.6\npackage\ require\ Tk\nset\ shell\ \[list\ csh\]\nproc\ log\ \{text\ \{tags\ \{\}\}\}\ \{\n\ \ \ \ .output\ configure\ -state\ normal\n\ \ \ \ .output\ insert\ end\ \$text\ \$tags\n\ \ \ \ .output\ configure\ -state\ disabled\n\ \ \ \ .output\ see\ end\n\}\nttk::entry\ .input\nttk::scrollbar\ .scroll\ -orient\ vertical\ -command\ \{.output\ yview\}\ntext\ .output\ -state\ disabled\ -yscrollcommand\ \{.scroll\ set\}\n.output\ tag\ configure\ input\ -background\ gray\n.output\ tag\ configure\ error\ -background\ red\npack\ .input\ -fill\ x\ -side\ bottom\npack\ .scroll\ -fill\ y\ -side\ right\npack\ .output\ -fill\ both\ -expand\ 1\nfocus\ .input\nlassign\ \[chan\ pipe\]\ rderr\ wrerr\nset\ stdio\ \[open\ |\[concat\ \$shell\ \[list\ 2>@\ \$wrerr\]\]\ a+\]\nforeach\ \{chan\ tags\}\ \[list\ \$stdio\ \"\"\ \$rderr\ error\]\ \{\n\ \ \ \ chan\ configure\ \$chan\ -buffering\ line\ -blocking\ 0\n\ \ \ \ chan\ event\ \$chan\ readable\ \[list\ apply\ \{\{chan\ tags\}\ \{\n\ \ \ \ \ \ \ \ log\ \[chan\ read\ \$chan\]\ \$tags\n\ \ \ \ \ \ \ \ if\ \{\[chan\ eof\ \$chan\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ log\ EOF\ error\n\ \ \ \ \ \ \ \ \ \ \ \ .input\ state\ disabled\n\ \ \ \ \ \ \ \ \ \ \ \ chan\ close\ \$chan\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\}\ \$chan\ \$tags\]\n\}\nbind\ .input\ <Return>\ \[list\ apply\ \{\{chan\}\ \{\n\ \ \ \ log\ \[.input\ get\]\\n\ input\n\ \ \ \ chan\ puts\ \$chan\ \[.input\ get\]\n\ \ \ \ .input\ delete\ 0\ end\n\}\}\ \$stdio\]\n======\n\nI\ really\ think\ it's\ time\ to\ move\ this\ to\ a\ new\ page!\ :^)\n\n----\n**\ Expect\ question\ (Re:\ Automating\ the\ login\ to\ a\ remote\ machine)**\n\n\[pcam\]\ -\ 2010-04-27\ 08:30:00\n\nI\ am\ trying\ to\ automate\ as\ much\ as\ possible\ the\ login\ to\ a\ remote\ machine.\nFrom\ my\ Solaris\ box\ I\ manually\ I\ am\ doing\ the\ following:\n\n\ \ \ 1.\ In\ a\ teminal\ establish\ a\ SSH\ tunnel\ ssh\ -l\ <username>\ -L\ 5988:localhost:5901\ <ip_address>\n\n\ \ \ 2.\ In\ ANOTHER\ terminal\ launch\ vncviewer\ :5988\n\n\ \ \ 3.\ Login\ from\ the\ vnc\ GUI\ login\ prompt\ (a\ step\ not\ required\ to\ be\ scripted/automatic)\n\n\nI\ can\ do\ both\ bits\ independently,\ but\ cannot\ manage\ with\ one\ expect\ session.\ \n\nI\ thought\ about\ using\ fork\ \n\nbut\ I\ am\ unsure\ and\ suspect\ this\ is\ not\ the\ best\ way\ to\ go\ about\ that.\nAny\ ideas\ or\ pointers\ ?\n\n----\n**\ Cross-compiling\ Tcl\ on\ arm-linux\ **\n\n\[Smarak\]\ -\ 2010-04-23\ 04:44:40\n\nHi\nI\ am\ using\ ubuntu\ 8.04.\ I\ have\ a\ arm-linux\ installed\ on\ to\ this\ ubuntu.\ My\ gumstix\ supports\ arm-angstrom-linux-gnueabi-gcc.\ Now\ my\ problem\ is\ I\ want\ to\ cross\ compile\ tcl\ on\ arm-linux.\ But\ I\ am\ confused\ with\ configure,make\ and\ make\ install.\ My\ overo-oe\ is\ in\ the\ folder\ named\ gumstix\ and\ tcl84.19-src.tar\ extracted\ in\ another\ folder\ named\ DTN2.\ Now\ i\ don't\ know\ how\ to\ use\ the\ below\ commands\n\n\n======\n'''''PATH=\ \$PATH:/usr/local/arm/oe/bin'''''\n\n'''''export\ CROSS_COMPILE=arm-linux'''''\n'''''export\ CC=arm-linux-gcc'''''\n\nexport\ tcl_cv_type'''bold\ text'''_64bit=\"long\ long\"\nexport\ ac_cv_c_bigendian=no\nexport\ tcl_cv_strtod_buggy=1\nexport\ ac_cv_func_strstr=yes\nexport\ ac_cv_func_opendir=yes\nexport\ ac_cv_func_strtod=yes\nexport\ tcl_cv_strtod_buggy=1\n\n./configure\ ../..\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--prefix=/home/zhepeng/Desktop/tcl-for-arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-tcl=/home/zhepeng/Desktop/tcl-for-arm/lib/tcl8.4\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm-linux\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--build=i386-pc-linux\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ --with-endianness=little\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-cc=arm-linux-gcc\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-ar=arm-linux-ar\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-install-prefix=../'''''..\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ --with-cflags=\"-O2\"\ \n\nexport\ tcl_cv_type_64bit=\"long\ long\"\nexport\ ac_cv_c_bigendian=no\nexport\ tcl_cv_strtod_buggy=1\nexport\ ac_cv_func_strstr=yes\nexport\ ac_cv_func_opendir=yes\nexport\ ac_cv_func_strtod=yes\nexport\ tcl_cv_strtod_buggy=1\n\n./configure\ ../..\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--prefix=/home/zhepeng/Desktop/tcl-for-arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-tcl=/home/zhepeng/Desktop/tcl-for-arm/lib/tcl8.4\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm-linux\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ --build=i386-pc-linux\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ --with-endianness=little\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-cc=arm-linux-gcc\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-ar=arm-linux-ar\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-install-prefix=../..'''''\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ --with-cflags=\"-O2\"\ \n======\n\nPls\ help!!!\nthanks\ in\ advance\n\n\[Steve\ Bennett\]\ I'm\ not\ sure\ what\ you\ have\ planned\ for\ Tcl,\ but\ you\ might\ want\ to\ check\ out\ \[Jim\].\ It\ is\ very\ compatible\ with\ Tcl,\ smaller\ and\ easy\ to\ cross\ compile.\n\n\ \$\ \ ./configure\ --host=arm-linux\n\ \ ...\n\ checking\ extension\ aio...\ enabled\ (default)\n\ checking\ extension\ array...\ enabled\ (default)\n\ checking\ extension\ bio...\ not\ enabled\n\ checking\ extension\ clock...\ enabled\ (default)\n\ checking\ extension\ eventloop...\ enabled\ (default)\n\ checking\ extension\ exec...\ enabled\ (default)\n\ checking\ extension\ file...\ enabled\ (default)\n\ checking\ extension\ glob...\ enabled\ (default)\n\ checking\ extension\ load...\ enabled\ (default)\n\ checking\ extension\ nvp...\ not\ enabled\n\ checking\ extension\ package...\ enabled\ (default)\n\ checking\ extension\ posix...\ enabled\ (default)\n\ checking\ extension\ readdir...\ enabled\ (default)\n\ checking\ extension\ regexp...\ enabled\ (default)\n\ checking\ extension\ signal...\ enabled\ (default)\n\ checking\ extension\ stdlib...\ enabled\ (default)\n\ checking\ extension\ syslog...\ enabled\ (default)\n\ checking\ extension\ tclcompat...\ enabled\ (default)\n\ checking\ extension\ tree...\ not\ enabled\n\ Jim\ extensions:\ aio\ array\ clock\ eventloop\ exec\ file\ glob\ load\ package\ posix\ readdir\ regexp\ signal\ stdlib\ syslog\ tclcompat\n\ configure:\ creating\ ./config.status\n\ config.status:\ creating\ Makefile\n\ config.status:\ creating\ jimautoconfext.h\n\ config.status:\ creating\ jimautoconf.h\n\ \$\ make\ &&\ make\ DESTDIR=/tmp/installdir\ install\n\n----\n**RFC5322\ compliant\ mails\ with\ tcllib\ mime\ package\;\ Tcllib\ reveice\ emails**\n\n\[Linkel\ Stephan\]\ -\ 2010-04-08\ 05:38:28\n\nmoved\ the\ question/answer\ to\ page\ \[RFC5322\ compliant\ mails\ with\ tcllib\ mime\ package\].\ Please\ have\ a\ look\ there.\ Thx\n\n----\n**Tcl\ and\ memory\ mapped\ files\ question\ **\n\n\[plap\]\ 2010.03.12\n\nIs\ it\ possible\ to\ communicate\ with\ a\ Windows\ application\ via\ a\ \"memory\ mapped\ file\"\ \n(commands\ such\ as\ CreateFileMapping())\ ?\nI\ see\ that\ mmap\ is\ sort\ of\ available\ but\ it\ doesn't\ seem\ to\ be\ the\ same\ thing.\nAny\ ideas?\n\n----\n**\ Coroutine\ names\ in\ the\ \[info\]\ procs\ list?\n\n\[jbr\],\ May\ 5\ 2010:\ Coroutine\ names\ don't\ appear\ in\ the\ \[info\]\ procs\ list?\n\n\[AMG\]:\ See\ \[coroutine\]\ for\ the\ answer.\n\n----\n**Dont\ brace\ your\ expressions**\n\n\[GeoffM\]:\ Problem\ with\ braced\ expressions.\ \[Brace\ your\ expressions\]\ recommends\ always\ bracing\ your\ expressions.\ \ Here\ is\ a\ counter\ example\ where\ I\ wish\ to\ evaluate\ an\ expression\ created\ as\ a\ string.\n\n\ \ proc\ sqr\ \{a\}\ \{return\ \[expr\ \{sqrt(\$a)\}\]\}\n\ \ proc\ tn\ \{a\}\ \{\ return\ \"2*tan(\[sqr\ \$a\])\"\}\n\nThen\ the\ command\ \"sqr\ 8\"\ and\ \"expr\ \{\[\[sqr\ 8\]\]\}\"\ returns:\ 2.8284271247461903.\nAnd\ 'tn\ 2'\ returns\ \"2*tan(1.4142135623730951)\"\n\nHowever:\n\n\ \ expr\ \[tn\ 2\]\ returns:\ 12.668238334084391\n\ \ expr\ \{\[tn\ 2\]\}\ returns:\ 2*tan(1.4142135623730951)\n\nDon't\ brace\ your\ expr-essions?\n\n\[Lars\ H\]:\ Why\ didn't\ you\ simply\n\ \ proc\ tn\ \{a\}\ \{\ return\ \[expr\ \{2*tan(\[sqr\ \$a\])\}\]\}\n?\ Then\ \[\[tn\ 2\]\]\ will\ return\ the\ wanted\ result,\ with\ no\ need\ for\ a\ surrounding\ \[expr\].\n\nBut\ in\ general:\ Yes,\ if\ you're\ constructing\ \[expr\]essions\ dynamically,\ then\ you\ do\ want\ ordinary\ substitution\ to\ take\ place\ in\ the\ argument\ of\ the\ \[expr\]\ command,\ and\ therefore\ cannot\ brace\ it.\ (\[expr\]\ is\ just\ like\ \[eval\]\ in\ this\ respect.)\ \ The\ price\ for\ doing\ so\ is\ speed,\ since\ each\ dynamic\ reconstruction\ of\ such\ an\ expression\ must\ be\ parsed\ anew.\ In\ your\ \"expr\ \[\[tn\ 2\]\]\"\ example,\ this\ happens\ every\ time\ it\ is\ used,\ and\ there\ is\ furthermore\ shimmering\ going\ on\ since\ the\ 1.4142135623730951\ is\ (under\ the\ hood)\ first\ converted\ double->string,\ then\ pasted\ into\ a\ larger\ string,\ \ cut\ out\ from\ that\ string\ by\ the\ \[expr\]\ parser,\ and\ finally\ converted\ back\ string->double\ by\ \[tan\].\ Lots\ of\ unnecessary\ work,\ so\ you'd\ be\ better\ off\ bracing\ your\ expr-esssions.\n\n\[GeoffM\]:\nActually\ my\ proc\ is\ a\ little\ more\ complex\ than\ my\ example.\ Proc\ tn\ defines\ a\ formula\;\ but\ if\ some\ constants\ of\ the\ formula\ are\ not\ defined\ (there\ are\ values\ other\ than\ the\ argument\ \"a\"\ used\ in\ evaluation\ the\ result\ is\ an\ algebraic\ manipulation\ of\ the\ best\ values\ so\ far)\ then\ tn\ returns\ the\ formula\ with\ as\ many\ variables\ substituted\ as\ possible.\ Finally\ if\ the\ result\ can\ become\ a\ number\ I\ expr\ it\;\ if\ this\ fails\ then\ I\ retain\ the\ formula\ for\ printing/debugging.\ It\ should\ however\ be\ possible\ for\ each\ component\ of\ the\ formula\ tn\ to\ be\ 'expr'd\ before\ returning\ its\ value.\ However\ I\ will\ need\ to\ do\ the\ expr\ finally\ to\ evaluate\ all\ the\ terms\ in\ the\ formula.\ \n\nIs\ there\ a\ test\ for\ 'would\ this\ value\ (string)\ evaluate\ to\ a\ numerical\ value'?\ I\ have\ used\ \n\ \ if\ \{\[catch\ \{return\ \[expr\ \[tn\ 2\]\]\}\]\}\ \{return\ \[tn\ 2\]\}\nbut\ I\ think\ the\ catch\ has\ significant\ overhead.\n\n\[Lars\ H\]:\ That's\ pretty\ much\ it,\ but\ the\ \[return\]\ in\ there\ will\ make\ your\ test\ misbehave,\ since\n\ \ catch\ \{return\ something\}\nalways\ has\ the\ value\ 2\ (\[catch\]\ catches\ \[return\]\ too).\ You're\ probably\ looking\ for\n\ \ set\ formula\ \[tn\ 2\]\n\ \ if\ \{\[catch\ \{expr\ \$formula\}\ val\]\}\ then\ \{return\ \$formula\}\ else\ \{return\ \$val\}\nWhether\ this\ (relying\ on\ that\ the\ string\ representation\ of\ a\ number\ is\ also\ a\ valid\ \[expr\]ession,\ which\ takes\ on\ the\ same\ value)\ is\ Good\ Style\ is\ another\ matter.\ Programming-wise,\ you\ might\ be\ better\ off\ using\ a\ \[apply%|%lambda%|%\]\ or\ \[command\ prefix\]\ than\ a\ dynamically\ generated\ \[expr\]ession.\n\n----\n**\ Event\ loop\ in\ tclsh\ **\n\n\[ero\]\ -\ 2010.02.26:\ event\ loop\ in\ tclsh\n\nThe\ following\ test\ code\ works\ correclty\ using\ Tk\ (wish):\n\n\ proc\ pp\ \{\}\ \{\n\ \ global\ x\n\ \ puts\ \$x\n\ \ if\ \{\$x\ >\ 10000\}\ \{return\}\n\ \ incr\ x\n\ \ after\ 10\ \[list\ pp\]\n\ \}\n\ #\n\ set\ ::x\ 1\n\ pp\n\nTo\ use\ the\ same\ proc\ in\ Tcl\ (tclsh)\ I\ added\ the\ vwait\ command\ (to\ trigger\ the\ event\ loop):\n\n\ proc\ pp\ \{\}\ \{\n\ \ global\ x\n\ \ puts\ \$x\n\ \ if\ \{\$x\ >\ 10000\}\ \{return\}\n\ \ incr\ x\n\ \ after\ 10\ \[list\ pp\]\n\ \ vwait\ x\n\ \}\n\nbut\ after\ 500\ dummy\ lines\ I\ got:\n\nerror\ in\ background\ error\ handler:\ntoo\ many\ nested\ evaluations\ (infinite\ loop?)\ \ while\ executing\n\"::tcl::Bgerror\ \{too\ many\ nested\ evaluations\ (infinite\ loop?)\}\ \n\{-code\ 1\ -level\ 0\ -errorcode\ NONE\ -errorinfo\ \{too\ many\ nested\ evaluations\ (infinite\ loop...\"\n\nWhy\ this\ happens?\ How\ start\ the\ event\ loop\ correctly\ in\ tclsh?\nThanks.\n\n\[Lars\ H\]:\ Don't\ call\ \[vwait\]\ inside\ '''pp''',\ but\ instead\ once\ after,\ like\ so:\n\ proc\ pp\ \{\}\ \{\n\ \ global\ x\n\ \ puts\ \$x\n\ \ if\ \{\$x\ >\ 10000\}\ \{set\ ::done\ 1\;\ return\}\n\ \ incr\ x\n\ \ after\ 10\ \[list\ pp\]\n\ \}\n\ #\n\ set\ ::x\ 1\n\ pp\n\ vwait\ ::done\nThis\ is\ what\ most\ closely\ corresponds\ to\ the\ Wish\ case,\ since\ there\ your\ script\ is\ being\ run\ from\ within\ a\ surrounding\ event\ loop.\n\n----\n**Problem\ running\ a\ starpack'd\ app\ on\ Fedora**\ \n\n\[MG\]\ A\ friend\ trying\ to\ run\ a\ starpack'd\ app\ on\ Fedora\ has\ run\ into\ an\ issue:\ using\ the\ 8.5.8\ Tclkit\ from\ the\ http://code.google.com/p/tclkit/downloads/list?can=3%|%Google\ Code\ site%|%,\ he\ gets\ an\ error\ \"error\ while\ loading\ shared\ libraries:\ libstdc++.so.5:\ cannot\ open\ shared\ object\ file:\ No\ such\ file\ or\ directory.\".\ According\ to\ Fedora's\ Add/Remove\ Software\ dialog,\ libstdc++\ is\ installed/available.\ The\ 8.5.2\ Tclkit\ (from\ http://www.equi4.com/tclkit/download.html%|%equi4.com%|%),\ which\ is\ the\ last\ build\ version\ I\ used\ for\ my\ app,\ works\ fine.\ Does\ anyone\ have\ any\ ideas/fixes\ that\ might\ help?\n\n----\n**How\ can\ I\ stop\ my\ TCL\ app\ from\ taking\ focus\ and\ moving\ to\ the\ top\ (over\ TPlayer)\ if\ it\ is\ clicked?**\n\n\[Beware\]:\ Here's\ a\ strange\ one,\ hopefully\ with\ an\ easy\ answer...\ \ I\ want\ to\ write\ an\ app\ that\ is\ a\ full\ black\ screen.\ \ It\ then\ loads\ another\ (already\ compiled)\ app\ (called\ TPlayer\ -\ google\ is\ your\ friend).\ \ The\ reason\ is\ I\ don't\ want\ to\ see\ my\ desktop\ while\ using\ TPlayer\ (looks\ more\ professional\ at\ a\ gig,\ as\ Tplayer\ is\ a\ DJ\ app).\ \ All\ easy\ enough\ so\ far,\ but\ how\ can\ I\ stop\ my\ TCL\ app\ from\ taking\ focus\ and\ moving\ to\ the\ top\ (over\ TPlayer)\ if\ it\ is\ clicked?\ (Tplayer\ has\ very\ few\ options).\ \ Secondly,\ how\ can\ I\ link\ the\ two\ apps\ so\ if\ the\ user\ closes\ TPlayer,\ the\ TCL\ closes,\ and\ vice-versa?\n\nAny\ hints/tips\ much\ appreciated.\n\nPS.\ Windows\ XP.\ I'd\ rather\ not\ use\ extensions\ if\ possible,\ as\ I\ like\ a\ nice\ easy\ freewrap\ compile\ :)\n\n\[Beware\](the\ next\ day):\ Using\ a\ program\ called\ PowerMenu,\ I\ can\ make\ TPlayer\ always\ on\ top.\ \ This\ works\ well,\ but\ is\ there\ a\ TCL\ solution?\n\n\[MG\]\ I'm\ not\ aware\ of\ any\ Pure-Tcl\ one.\ While\ you\ can\ easily\ position\ .\ to\ fill\ the\ screen\ and\ then\ use\ 'exec\ \$app\ \;\ exit'\ to\ launch\ the\ app\ (the\ \[exec\]\ call\ won't\ return\ until\ your\ app\ closes,\ then\ running\ the\ \[exit\]),\ the\ .\ window\ will\ still\ take\ focus\ on\ click,\ and\ appear\ to\ Windows\ to\ have\ hung.\ There\ might\ be\ an\ extension\ that\ would\ let\ you\ easily\ embed\ another\ app\ into\ a\ Tk\ window,\ though?\n\n\[Duoas\]\ There\ isn't\ any\ simple\ way\ to\ do\ this\ without\ extensions.\ You\ can\ get\ kind\ of\ close,\ though,\ with\ standard\ Tcl/Tk\ by\ configuring\ your\ main\ window\ as\ \"disabled\"\ and\ using\ the\ XP\ Pro\ utility\ \"tasklist\"\ to\ watch\ for\ when\ TPlayer\ closes.\ If\ you\ don't\ have\ XP\ Pro,\ you'll\ have\ to\ get\ a\ copy\ of\ tasklist.exe\ from\ online.\n\nKeep\ in\ mind\ that\ this\ is\ a\ ''very''\ simple\ solution\ --\ but\ it\ satisfies\ your\ requirements.\ You\ can\ still\ switch\ things\ around\ with\ Alt-Tab\ and\ other\ stuff,\ so\ if\ anything\ goes\ wrong\ just\ Alt-Tab\ back\ to\ your\ application.\n\nAlso\ remember\ that\ tasklist\ is\ another\ application\ that\ gets\ loaded\ and\ unloaded\ each\ time\ it\ is\ used.\ That\ is\ a\ lot\ of\ overhead\ just\ to\ watch\ a\ child.\ You\ would\ be\ better\ off\ using\ an\ extension\ like\ \[Ffidl\]\ to\ track\ the\ child's\ status.\n\nHere's\ what\ I\ wrote:\n\ #\ dj.tcl\n\ #\ 2009\ Michael\ Thomas\ Greer\n\ #\ Released\ to\ the\ Public\ Domain\n\n\ #-----------------------------------------------------------------------------\n\ #\ Modify\ these\ to\ the\ appropriate\ values.\n\ #\ \n\ #\ COMMAND\ is\ the\ full\ path\ and\ any\ command\ arguments\ to\ the\ program\ to\ run.\n\ #\ IMAGE\ \ \ is\ the\ x,y\ position\ and\ name\ of\ the\ image\ to\ display\ in\ the\n\ #\ \ \ \ \ \ \ \ \ background.\ You\ can\ give\ an\ empty\ list\ if\ you\ desire\ no\ image\ to\n\ #\ \ \ \ \ \ \ \ \ display.\n\ #\ \ \ \ \ \ \ \ \ The\ x\ value\ may\ be\ a\ pixel\ coordinate\ (as\ in\ \"100\"),\ a\ percentage\n\ #\ \ \ \ \ \ \ \ \ (as\ in\ \"20%\"),\ the\ value\ \"left\",\ or\ the\ value\ \"right\".\n\ #\ \ \ \ \ \ \ \ \ The\ y\ value\ may\ also\ be\ a\ pixel\ coordinate,\ a\ percentage,\ or\ the\n\ #\ \ \ \ \ \ \ \ \ values\ \"top\"\ or\ \"bottom\".\n\ #\ \ \ \ \ \ \ \ \ Remember,\ the\ image\ file\ must\ be\ a\ BMP\ or\ a\ GIF.\n\ #\ TIMEOUT\ The\ number\ of\ milliseconds\ to\ wait\ before\ checking\ to\ see\ if\ the\n\ #\ \ \ \ \ \ \ \ \ COMMAND\ has\ terminated\ yet\ or\ not.\n\ #\n\ set\ COMMAND\ \{Notepad.exe\ dj.tcl\}\n\ set\ IMAGE\ \ \ \[list\ right\ 50%\ C:/WINDOWS/system32/ntimage.gif\]\n\ set\ TIMEOUT\ 500\n\n\ #-----------------------------------------------------------------------------\n\ #\ The\ following\ is\ the\ main\ program\n\ #\n\ package\ require\ Tcl\ 8.5\n\ package\ require\ Tk\ \ 8.5\n\n\ proc\ position\ \{value\ dimension\ image\}\ \{\n\ \ \ \ set\ d\ \[expr\ \{\[winfo\ screen\$dimension\ .\]\ -\ \[image\ \$dimension\ \$image\]\}\]\n\ \ \ \ switch\ -glob\ -nocase\ --\ \$value\ \{\n\ \ \ \ \ \ *%\ \ \ \ \ \ \{\ return\ \[expr\ \{\$d\ *\ \[string\ range\ \$value\ 0\ end-1\]\ /\ 100\}\]\ \}\n\ \ \ \ \ \ c*\ \ \ \ \ \ \{\ return\ \[expr\ \{\$d\ /\ 2\}\]\ \}\n\ \ \ \ \ \ l*\ -\ t*\ \{\ return\ 0\ \}\n\ \ \ \ \ \ r*\ -\ b*\ \{\ return\ \$d\ \}\n\ \ \ \ \ \ default\ \{\ return\ \$value\ \}\n\ \ \ \ \}\n\ \}\n\n\ proc\ initialize_gui\ \{\}\ \{\n\n\ \ \ \ .\ configure\ -background\ black\ -bd\ 0\ -highlightthickness\ 0\n\n\ \ \ \ wm\ attributes\ .\ -fullscreen\ true\n\ \ \ \ wm\ title\ \ \ \ \ \ .\ \{DJ\ Background\}\n\n\ \ \ \ lassign\ \$::IMAGE\ x\ y\ imagefile\n\ \ \ \ if\ \{\$imagefile\ ne\ \{\}\}\ \{\n\ \ \ \ \ \ \ \ set\ image\ \[image\ create\ photo\ -file\ \$imagefile\]\n\ \ \ \ \ \ \ \ set\ x\ \[position\ \$x\ width\ \ \$image\]\n\ \ \ \ \ \ \ \ set\ y\ \[position\ \$y\ height\ \$image\]\n\n\ \ \ \ \ \ \ \ label\ .image\ -image\ \[image\ create\ photo\ -file\ \$imagefile\]\ -bd\ 0\ -highlightthickness\ 0\n\ \ \ \ \ \ \ \ place\ .image\ -x\ \$x\ -y\ \$y\n\ \ \ \ \}\n\n\ \ \ \ update\n\n\ \ \ \ wm\ attributes\ .\ -disabled\ true\n\ \}\n\n\ proc\ check\ pid\ \{\n\ \ \ \ set\ tasklist\ \[open\ \"|\ tasklist\ /fi\ \\\"pid\ eq\ \$pid\\\"\"\]\n\ \ \ \ set\ data\ \[read\ \$tasklist\]\n\ \ \ \ if\ \{\[catch\ \{close\ \$tasklist\}\ err\]\}\ \\\n\ \ \ \ \ \ then\ \{\ exit\ \}\ \\\n\ \ \ \ \ \ else\ \{\ after\ \$::TIMEOUT\ check\ \$pid\ \}\n\ \}\n\n\ proc\ main\ \{\}\ \{\n\n\ \ \ \ initialize_gui\n\n\ \ \ \ if\ \{\[catch\ \{open\ \"|\ \$::COMMAND\"\}\ pipe\]\}\ \{\n\ \ \ \ \ \ \ \ tk_messageBox\ -message\ \"Could\ not\ execute:\ \$::COMMAND\"\n\ \ \ \ \ \ \ \ exit\ 1\n\ \ \ \ \}\n\ \ \ \ set\ pid\ \[pid\ \$pipe\]\n\n\ \ \ \ after\ \$::TIMEOUT\ check\ \$pid\n\ \}\n\n\ main\nYou'll\ have\ to\ change\ the\ COMMAND\ of\ course.\ I\ don't\ know\ if\ your\ PC\ has\ that\ IMAGE\ on\ it\ (it\ should),\ but\ my\ ActiveState\ Tk\ 8.5\ couldn't\ load\ the\ windows\ Bliss.bmp\ as\ an\ example.\n\nHope\ this\ helps.\n\n----\n**\ Strange\ behaviour\ with\ \[text\]\ widget\ \[bind\]ings\ **\ \n\n\[MG\]\ has\ just\ discovered\ some\ behaviour\ with\ \[text\]\ widget\ \[bind\]ings\ that\ seem\ a\ little\ strange.\ If\ you\ do:\n\n\ \ pack\ \[text\ .t\]\n\ \ .t\ insert\ end\ foo\ bar\n\ \ foreach\ x\ \[list\ Enter\ Leave\ ButtonPress-1\ ButtonRelease-1\]\ \{\n\ \ \ bind\ .t\ <\$x>\ \[list\ puts\ \"Widget\ \$x\"\]\n\ \ \ .t\ tag\ bind\ bar\ <\$x>\ \[list\ puts\ \"Tag\ \$x\"\]\n\ \ \}\n\nThen\ move\ the\ mouse\ over\ the\ 'foo'\ text,\ hold\ down\ the\ left\ button,\ drag\ the\ mouse\ out\ of\ the\ text\ widget,\ and\ then\ release\ the\ mouse\ button.\ The\ \"tag\"\ binding\ doesn't\ trigger\ a\ Leave\ event\ until\ after\ the\ button\ is\ released,\ but\ the\ \"widget\"\ binding\ triggers\ both\ the\ moment\ the\ mouse\ leaves\ the\ widget\ (as\ I\ would've\ expected),\ and\ then\ again\ when\ the\ button\ is\ released.\ This\ is\ on\ Win\ XP\ with\ an\ 8.5.7\ Tclkit.\ Can\ anyone\ confirm\ and\ tell\ me\ whether\ or\ not\ this\ is\ a\ bug?\ (I\ would\ expect\ both\ the\ tag\ and\ widget\ bindings\ to\ fire\ just\ once,\ when\ the\ mouse\ moves\ outside\ the\ text/widget\ boundaries.)\ Any\ help\ is\ greatly\ appreciated.\n\n----\n**\ Accessing\ UNIX\ filters\ from\ TCL\ **\n\nI\ use\ UNIX\ filters\ every\ day,\ almost\ every\ thing\ I\ type\ at\ the\ command\ line\ is\ a\ filter.\ \ How\ can\ I\ access\ these\ filters\ from\ Tcl?\n\n\[How\ can\ I\ run\ data\ through\ an\ external\ filter?\]\n\n\[jbr\]\n\n-----\n**Basic\ code\ for\ the\ switch\ function:\ Running\ two\ procedures\ and\ a\ cancel**\n\nKeith\ Sarandon\ 2009-11-05\ I\ am\ asking\ a\ very\ simple\ question\ re:\ the\ \[switch\]\ function.\ See\ on\ top\ of\ the\ \[switch\]\ page.\ Tx.\ \n\n(\[aricb\]\ moved\ the\ question\ back\ here.)\n\nNovember\ 5th\ 2009\ by\ Keith\ Sarandon\n\nI\ need\ some\ very\ basic\ code\ for\ the\ switch\ function.\ If\ the\ user\ clicks\ on\ Item\ a\ in\ the\ window,\ proc\ open.a\ runs\ and\ conversely\ if\ he\ clicks\ on\ item\ b\ in\ the\ window\ proc\ open.b\ runs.\ There\ is\ also\ a\ third\ item:\ Cancel.\ Tx\ for\ the\ help.\n\n\[Duoas\]\ You\ don't\ need\ '''switch'''\ for\ that.\ Instead\ you\ should\ \[bind\]\ on\ the\ button\ press\ to\ do\ the\ right\ thing.\ In\ your\ case,\ your\ bindings\ may\ be\ as\ simple\ as\n\ \ \ \ bind\ .a\ <ButtonPress>\ open.a\n\ \ \ \ bind\ .b\ <ButtonPress>\ open.b\n\ \ \ \ bind\ .c\ <ButtonPress>\ cancelproc\ \ \;#\ whatever\ your\ cancel\ proc\ does\nHope\ this\ helps.\n\n-----\n**Way\ to\ trace\ changes\ to\ a\ font**\n\n\[Duoas\]\ 2009-11-03:\ Is\ there\ any\ way\ to\ '''trace'''\ changes\ to\ a\ font?\n\nI\ ask,\ because\ I\ want\ to\ avoid\ a\ full\ set\ of\ traces\ on\ the\ '''font'''\ command\ itself...\nI\ am\ currently\ playing\ with\ zooming\ fonts,\ and\ it\ would\ be\ nice\ for\ changes\ to\ the\ font\ that\ the\ user\ supplied\ to\ be\ automagically\ reflected\ in\ the\ local\ fonts\ that\ I\ scale\ and\ display.\ Would\ a\ trace\ like\ that\ prove\ burdensome\ to\ the\ application's\ running\ time?\n\n\n-----\n**\ Question\ regarding\ creating\ a\ directory\ **\nSteven,\ October\ 22nd\ 2009:\ I\ put\ a\ simple\ question\ here\ in\ regards\ to\ creating\ a\ directory.\ \[Directory,\ General\ Questions\]\;\ \ Thanks\ for\ your\ help!\n\n----\n**\ Problem\ with\ coding\ several\ different\ grid-layouts\ on\ the\ same\ window.**\ \ \n\ \n\[HJG\]\ 2009-09-27:\ I\ want\ several\ different\ grid-layouts\ on\ the\ same\ window.\ \ \nE.g.\ a\ table\ as\ in\ the\ example\ on\ the\ page\ for\ \[grid\],\ and\ below\ the\ table\ a\ set\ to\ buttons,\ using\ a\ new\ grid:\n======\n\ \ \ \ foreach\ field\ \{Name\ Address\ City\ State\ Phone\}\ \{\n\ \ \ \ \ \ \ \ set\ l\ \[label\ .lab\$field\ -text\ \$field\]\n\ \ \ \ \ \ \ \ set\ e\ \[entry\ .ent\$field\ -justify\ right\]\n\ \ \ \ \ \ \ \ grid\ \$l\ \$e\ -padx\ 4\ -pady\ 4\n\ \ \ \ \ \ \ \ grid\ \$l\ -sticky\ e\n\ \ \ \ \ \ \ \ grid\ \$e\ -sticky\ ew\n\ \ \ \ \}\n\ \ \ \ button\ .b1\ -text\ New\n\ \ \ \ button\ .b2\ -text\ Search\n\ \ \ \ button\ .b3\ -text\ Delete\n\ \ \ \ button\ .b4\ -text\ Exit\n\ \ \ \ grid\ .b1\ .b2\ .b3\ .b4\ \ \ \;#\ !!\ uses\ same\ grid-layout\ as\ table\ above\n======\nIt\ seems,\ there\ is\ no\ command\ to\ reset/finish\ one\ grid\ and\ start\ another.\nAlso,\ packing\ a\ grid\ inside\ a\ frame\ does\ not\ work\ as\ expected,\ \nand\ the\ docs\ have\ no\ info\ about\ how\ to\ use\ \[Geometry\ managers\]\ like\ grid\ and\ \[pack\]\ together.\n\n\[HE\]\ 2009-09-28:\ You\ need\ to\ put\ different\ layouts/geometry\ managers\ into\ different\ frames:\n\n======\n\ frame\ .f1\n\ foreach\ field\ \{Name\ Address\ City\ State\ Phone\}\ \{\n\ \ \ \ \ \ \ \ set\ l\ \[label\ .f1.lab\$field\ -text\ \$field\]\n\ \ \ \ \ \ \ \ set\ e\ \[entry\ .f1.ent\$field\ -justify\ right\]\n\ \ \ \ \ \ \ \ grid\ \$l\ \$e\ -padx\ 4\ -pady\ 4\n\ \ \ \ \ \ \ \ grid\ \$l\ -sticky\ e\n\ \ \ \ \ \ \ \ grid\ \$e\ -sticky\ ew\n\ \ \ \ \}\n\n\ frame\ .f2\n\ button\ .f2.b1\ -text\ New\ \ \ \ \n\ button\ .f2.b2\ -text\ Search\ \ \ \ \n\ button\ .f2.b3\ -text\ Delete\ \ \ \ \n\ button\ .f2.b4\ -text\ Exit\ \ \ \ \n\ grid\ .f2.b1\ .f2.b2\ .f2.b3\ .f2.b4\ \n\ pack\ .f1\ .f2\ -side\ top\n======\n\n----\n**\ Using\ re-entrant\ procedures\ **\n\n\[lannet\]\ 06\ Aug\ 09\ -\ \[Am\ I\ heading\ for\ trouble\ if\ I\ use\ re-entrant\ procedures?\]\n\n----\n**\ Problems\ with\ list\ handling\ in\ connection\ with\ the\ \"unknown\"\ proc\ **\n\n\[lannet\]\ 23\ Jul\ 09\ -\ \[Problems\ with\ list\ handling\ in\ connection\ with\ the\ \"unknown\"\ proc\]\n\n----\n**Separate\ spec\ and\ body\ source\ files**\ \n\n\[LGT\]\ Jul\ 13\ 2009\ -\ \[itcl\ :\ Is\ it\ recommended\ to\ have\ separate\ spec\ and\ body\ source\ files\ ?\]\n\n----\n**Silly\ link!!!**\n\n\[tehbrozor\]\ Jul\ 7\ 2009\ -\ \[My\ question\ is\ listed\ here--Please\ help!!!\]\n\n----\n**\ Working\ with\ button\ press\ with\ a\ ttk::treeview\ widget\ **\n\n\[MG\]\ Jun\ 16\ 2009\ -\ I\ have\ a\ ttk::treeview\ widget\ set\ up\ along\ these\ lines:\n\n\ \ set\ image\ \[image\ create\ photo\ -file\ \$path\]\n\ \ pack\ \[ttk::treeview\ .t\]\n\ \ set\ id\ \[.t\ insert\ \{\}\ end\ -text\ Foo\ -image\ \$image\]\n\ \ .t\ insert\ \$id\ end\ -text\ Bar\ -image\ \$image\n\ \ .t\ insert\ \$id\ end\ -text\ Baz\ -image\ \$image\n\nI'd\ like\ to\ do\ something\ particular\ when\ a\ ButtonPress\ occurs\ over\ the\ image\;\ anyone\ know\ if\ this\ is\ possible?\ I\ had\ a\ look\ at\ the\ bindings\ in\ treeview.tcl\ and\ found\ an\ undocumented\n\ \ \$treeview\ identify\ \$x\ \$y\ncommand,\ but\ (at\ least\ in\ the\ usage\ in\ treeview.tcl,\ and\ from\ my\ quick\ test\ of\ it)\ it\ doesn't\ seem\ to\ return\ anything\ special\ for\ the\ image.\ Is\ there\ another\ way?\n\nWhat\ I'm\ trying\ to\ create\ is\ something\ akin\ to\ the\ MS\ installers\ which\ show\ a\ tree\ of\ program\ components\ grouped\ together,\ with\ a\ checkbutton\ for\ each\ group/component.\ I\ was\ planning\ to\ use\ different\ images\ (empty\ box,\ box\ with\ tick,\ greyed\ out\ box\ with\ tick)\ to\ simulate\ a\ tri-state\ checkbutton,\ and\ alter\ the\ image/state\ when\ the\ image\ is\ clicked.\ Would\ be\ interested\ to\ hear\ any\ suggestions\ for\ a\ better/different\ way\ to\ go\ about\ it,\ too.\n\nThanks\ for\ your\ help.\n\n----\n**Problem\ using\ bindvariables\ with\ oratcl\ 4.4**\n\n\[HE\]\ June\ 7\ 2009\ -\ I\ have\ a\ problem\ to\ use\ \[bindvariables\ with\ oratcl\ 4.4\].\ Something\ like\ a\ memoryleak.\n\n----\n**Transferring\ files\ of\ using\ ftp\ over\ TLS**\n\[Hai\ Vu\]\ June\ 1\ 2009\ -\ How\ do\ I\ \[Transfer\ Files\ of\ Using\ ftp\ over\ TLS\]?\ I\ often\ need\ to\ do\ this,\ so\ am\ thinking\ of\ a\ way\ to\ automate\ it.\n\n----\n**\ Problems\ using\ Tile/Ttk\ **\ \n\n\[MG\]\ May\ 12\ 2009\ -\ I'm\ having\ some\ (more)\ issues\ with\ Tile,\ explained\ at\ \[Problems\ using\ Tile/Ttk\],\ and\ would\ greatly\ appreciate\ any\ help.\n\n----\n**\ General\ question\ regarding\ Undo\ **\n\[ARA\]\ (May\ 2\ 2009)\ My\ question\ has\ been\ placed\ in\ a\ new\ page\ called:\ \[Undo,\ a\ few\ pointers\ at\ how\ to\ code\ the\ Undo\ function\ for\ a\ text\ editor\].\ Please\ have\ a\ look\ there.\ Tx.\ \n\n----\n**\ Coding\ recognizable\ radio/checkbuttons\ in\ Tk8.5\ menus\ **\ \n\n\[Schnexel\]\ (May\ 5\ 2009)\ Is\ it\ possible\ to\ have\ radio/checkbuttons\ in\ Tk8.5\ menus\ that\ are\ recognizable\ as\ such\ even\ if\ not\ checked?\ I\ don't\ want\ to\ change\ much\ of\ my\ old\ 8.4\ code.\ See\ new\ page:\ \[Tk8.5\ menu\ radio/checkbutton\ without\ information\ loss?\].\ Tx.\ \n\n-----\n**\ Uploadable\ images\ to\ a\ Teclers'\ wiki\ page\ instead\ of\ a\ link\ out\ to\ a\ remote\ site**\n\n\[why\ can't\ wiki\ have\ uploadable\ images\ ?\]\ I\ just\ want\ to\ have\ a\ picture\ included\ with\ a\ wiki\ page.\ I\ don't\ wan't\ it\ to\ link\ out\ to\ a\ remote\ web\ site.\ Is\ this\ possible\ yet\ ?\ thanks.\ Art\n\n-----\n**Implementation\ of\ a\ command\ with\ an\ ensemble**\n\nI'm\ finding\ many\ cases\ where\ the\ \"obvious\"\ implementation\ of\ a\ command\ is\ with\ an\ ensemble,\ but\ the\ command\ is\ actually\ a\ method\ on\ an\ object.\ I\ can\ hack\ up\ an\ implementation,\ but\ it's\ very\ ugly.\ Any\ suggestions\ as\ to\ a\ better\ way\ to\ do\ it?\ Does\ anybody\ else\ want\ to\ do\ this\ too?\ Thanks,\ Paul\ \[Object\ method\ ensemble\]\n\n----\n**Talking\ to\ a\ device\ using\ RS\ 232\;\ Developing\ a\ GUI\ which\ can\ send\ and\ receive\ strings\ from\ the\ device**\n\ \ \n\[ADESH\]\ -\ 2009-09-15\ 15:03:26\n\nI\ am\ trying\ to\ talk\ to\ a\ device\ using\ RS\ 232\ and\ my\ programming\ platform\ is\ Tcl/Tk\ in\ ubuntu.\ I\ need\ to\ be\ able\ to\ develop\ a\ GUI\ which\ can\ send\ and\ receive\ strings\ from\ the\ device.\ To\ start\ with,\ I\ ran\ the\ following\ piece\ of\ codes\ to\ open\ the\ serial\ port,\ then\ send\ the\ string\ MN\ to\ the\ device.\ and\ to\ get\ the\ output\ from\ the\ device\ :\n\n======\n\ set\ serial\ \[open\ /dev/ttyUSB0\]\n\ fconfigure\ \$serial\ -mode\ \"9600,n,8,1\"\n\ fconfigure\ \$serial\ -blocking\ 0\ -buffering\ none\n\ puts\ -nonewline\ \$serial\ \"MN\\r\"\n\ puts\ \"Modem\ echo:\ \[read\ \$serial\]\"\n======\n\nI\ have\ connected\ the\ device\ to\ my\ computer\ via\ RS\ 232\ and\ a\ USB.\ When\ I\ wish\ the\ above\ command\ containing\ file\ I\ get\ the\ following\ response\;\n\n======\nError\ in\ startup\ script:\ channel\ \"file6\"\ wasn't\ opened\ for\ writing\n\ \ \ \ while\ executing\n\"puts\ -nonewline\ \$serial\ \"MN\\r\"\"\n\ \ \ \ (file\ \"tt.tcl\"\ line\ 8)\n======\n\nPlease\ help\ me\ get\ rid\ of\ the\ problem.\n\nThanks\ in\ advance\nAdesh\n\n----\n\[LV\]\ Have\ you\ read\ the\ wiki\ page\ for\ \[open\]?\ In\ your\ code\ above,\ you\ don't\ provide\ an\ indicator\ of\ whether\ you\ are\ opening\ for\ read\ or\ for\ write.\nAlso,\ be\ certain\ to\ read\ the\ information\ about\ setting\ appropriate\ fconfigure\ value\ if\ you\ need\ to\ send\ or\ receive\ binary\ data\ over\ the\ device.\n\n----\n**\ Tool\ implemented\ in\ expect\ that\ sends\ commands\ to\ remote\ node\ **\ \ \n\[srinadh\]\ -\ 2009-10-03\ 11:22:46\n\nI\ have\ a\ tool\ implemented\ in\ expect\ that\ sends\ commands\ to\ remote\ node\ (I\ spawn\ telnet\ session\ to\ the\ node)\ and\ parses\ its\ output.\ \n\nBut\ when\ I\ launch\ the\ tool\ from\ a\ small\ window,\ the\ command\ that\ is\ being\ sent\ by\ the\ tool\ is\ getting\ stripped\ at\ the\ beginning\ so\ node\ cannot\ understand\ the\ command\ and\ fails\ to\ respond,\ my\ tool\ stops.\ \n\nTo\ fix\ this\ issue,\ I\ added\ \"stty\ rows\ 50\ columns\ 120\"\ before\ it\ sends\ command\ to\ the\ node.\ \nIt\ works\ fine\ but\ when\ I\ run\ the\ tool\ in\ background,\ it\ goes\ to\ suspended\ mode:\ \"\[1\]\ \ +\ Suspended\ (tty\ output)\ \ \ \ \ \ ./console_logs\ -l\ tmp\".\ \nI\ need\ to\ type\ 'fg'\ explicitly\ for\ the\ tool\ to\ resume\ its\ operation..\ \n\nI\ cannot\ use\ stty???\ If\ not,\ please\ suggest\ me\ a\ better\ way\ to\ be\ able\ to\ run\ the\ tool\ from\ smaller\ windows..\n\n\[HJG\]\ That\ looks\ like\ a\ task\ for\ \[expect\].\n\n----\n**Problems\ with\ developing\ a\ GUI\ in\ VTCL**\n\[plasma\]\ -\ 2009-11-02\ 23:20:57\n\nI\ am\ developing\ a\ GUI\ in\ VTCL\ that\ involves\ drag\ and\ drop\ of\ widgets.\ These\ are\ the\ components\ in\ my\ GUI:\n\n\ \ \ *\ a\ tree\ with\ nodes\ and\ child\ nodes\n\ \ \ *\ an\ 'Insert'\ button\n\ \ \ *\ A\ Separator\ widget\n\nWhen\ I\ select\ a\ node\ and\ click\ on\ Insert,a\ widget\ should\ get\ inserted\ in\ the\ Separator.The\ widget\ can\ be\ either\ a\ button\ or\ a\ labelentry,having\ the\ name\ of\ the\ selected\ node\ as\ the\ text\ value.The\ purpose\ is\ that\ once\ the\ widget\ comes\ in\ the\ Separator,\ it\ should\ be\ dragable\ inside\ the\ Separator.\nOn\ the\ Wiki,I\ was\ told\ that\ the\ button\ widget\ cannot\ be\ made\ dragable,\ so\ now\ I\ insert\ a\ LabelEntry\ widget\ instead,which\ being\ a\ BWidget,has\ an\ option\ to\ be\ made\ dragable.\n\nI\ have\ done\ the\ insertion\ part\ using\ the\ following\ code:\n\n======\n#############################################################################\n##\ Procedure:\ \ insertElement\n\nproc\ ::insertElement\ \{\}\ \{\nglobal\ widget\nset\ sep\ \$::widget(Separator1)\nset\ tr\ \$::widget(Tree1)\n\nset\ sel_element\ \[\$tr\ selection\ get\]\nif\ \{\ \$sel_element\ !=\ \"\"\}\ \{\n\ set\ lb\ \[LabelEntry\ \$sep\[incr\ ::my_data::count\]\ -label\ \"\"\ -text\ \"\$sel_element\"\ \\\n\ \ \ \ \ \ \ \ -relief\ \"raised\"\ -justify\ \"center\"\ -width\ \"15\"\ -editable\ \"No\"\ \\\n\ \ \ \ \ \ \ \ -font\ \{-family\ helvetica\ -size\ 10\ -weight\ \"bold\"\}\ \\\n\ \ \ \ \ \ \ \ -dragenabled\ 1\ -dragevent\ 1\]\n\ place\ \$lb\ -in\ \$sep\ -x\ \$::my_data::x_pos\ -y\ \[incr\ ::my_data::y_pos\ 30\]\n\}\ else\ \{\n\ tk_messageBox\ -title\ \"Error\"\ -message\ \"Please\ select\ an\ element\"\ -type\ ok\n\}\nif\ \{\ \$::my_data::y_pos\ >\ 180\ \}\ \{\ \n\ incr\ ::my_data::x_pos\ 60\n\ set\ ::my_data::y_pos\ 0\n\}\nif\ \{\ \$::my_data::x_pos\ >\ 550\ \}\ \{\n\ set\ ::my_data::x_pos\ 50\n\}\n\}\n#############################################################################\n======\n\nNow\ the\ separator\ has\ to\ be\ registered\ as\ a\ drop\ site\ for\ the\ labelentrty\ widget\ using\ DropSite::regsiter.\ Please\ tell\ me\ how\ to\ write\ the\ dropendcmd\ for\ the\ separator.\nEDIT:\ JOB\ has\ posted\ a\ code\ for\ making\ a\ button\ dragable\ \[http://wiki.tcl.tk/16126\]here.\ Is\ it\ possible\ to\ change\ the\ position\ of\ a\ widget\ in\ real\ time\ by\ dragging?\n\n-----\n**Problems\ writing\ a\ small\ Tcl\ extension\ that\ makes\ driver\ specific\ ioctl()\ calls\ on\ files\ that\ are\ otherwise\ handled\ by\ the\ normal\ Tcl\ file\ commands**\n\n\[filker0\]\ -\ 2009-11-04\ 18:50:46\nI\ am\ attempting\ to\ write\ a\ small\ Tcl\ extension\ that\ makes\ driver\ specific\ ioctl()\ calls\ on\ files\ that\ are\ otherwise\ handled\ by\ the\ normal\ Tcl\ file\ commands.\ \ (This\ is\ to\ be\ used\ in\ an\ embedded\ environment.)\ \ An\ example\ of\ usage\ would\ be:\n\n======\n#############################################################################\npackage\ require\ fldr\n#\ The\ device\ node\ opens\ an\ IPC\ channel\ between\ two\ CPU\ boards\ using\ a\ special\n#\ minor\ device\ number\ (the\ main\ purpose\ of\ the\ driver\ is\ a\ different\ type\ of\n#\ domain\ specific\ IPC\ not\ being\ used\ for\ remote\ ROM\ access)\nproc\ update_remote_if_needed\ \{remote\ local\}\ \{\n\ \ if\ \{!\[file\ exists\ \$local\]\}\ \{\n\ \ \ \ puts\ stderr\ \"Local\ file\ \$local\ does\ not\ exist\"\n\ \ \ \ return\ 0\n\ \ \}\n\ \ if\ \{!\[file\ exists\ \$remote\]\}\ \{\n\ \ \ \ puts\ stderr\ \"Remote\ file\ \$remote\ does\ not\ exist\"\n\ \ \ \ return\ 0\n\ \ \}\n\ \ set\ localSize\ \[file\ size\ \$local\]\n\ \ set\ rfd\ \[open\ remote\ rw\]\n\ \ set\ limit\ \[fldr::getLimit\ \$rfd\]\ \ #\ performs\ an\ ioctl()\ and\ returns\ a\ long\ integer\ value\n\ \ if\ \{\$limit\ <\ \$localSize\}\ \{\n\ \ \ \ puts\ stderr\ \"Local\ file\ \$local\ (\$localSize\ bytes)\ exceeds\ limit\ for\ \$remote\ (\$limit\ bytes)\"\n\ \ \ \ close\ \$rfd\n\ \ \ \ return\ 0\n\ \ \}\n\n\ \ set\ lfd\ \[open\ \$local\ r\]\n\ \ fconfigure\ \$rfd\ -translation\ binary\ -encoding\ binary\n\ \ fconfigure\ \$lfd\ -translation\ binary\ -encoding\ binary\n\ \ seek\ \$rfd\ 20\n\ \ seek\ \$lfd\ 20\n\ \ set\ remote_version\ \[read\ \$rfd\ 32\]\n\ \ set\ local_version\ \[read\ \$lfd\ 32\]\n\ \ if\ (\$remote_version\ ==\ \$local_version)\ \{\n\ \ \ \ puts\ stdout\ \"Remote\ file\ is\ up\ to\ date\"\n\ \ \ \ close\ \$lfd\n\ \ \ \ close\ \$rfd\n\ \ \ \ return\ 1\n\ \ \}\n\ \ seek\ \$lfd\ 0\n\ \ seek\ \$rfd\ 0\n\ \ puts\ stdout\ \"Erasing\ at\ least\ \$localSize\ bytes\ of\ remote\ flash\"\n\ \ if\ \{\[fldr::eraseFileArea\ \$rfd\ \$localSize\]\ <\ 0\}\ \{\n\ \ \ \ puts\ stderr\ \"Error\ when\ erasing\ \$localSize\ bytes\ on\ remote\ file\ \$remote\"\n\ \ \ \ close\ \$lfd\n\ \ \ \ close\ \$rfd\n\ \ \ \ return\ 0\n\ \ \}\n\ \ puts\ stdout\ \"Copying\ \$localSize\ bytes\ of\ data\ from\ local\ file\ \$local\ to\ remote\ file\ \$remote\"\n\ \ set\ remain\ \$localSize\n\ \ set\ chunk\ \ 2048\n\ \ while\ \{\$remain\ >\ 0\}\ \{\n\ \ \ \ if\ \{\$chunk\ >\ \$remain\}\ \{\n\ \ \ \ \ \ set\ chunk\ \$remain\n\ \ \ \ \}\n\ \ \ \ set\ copyBuff\ \[read\ \$lfd\ \$chunk\]\n\ \ \ \ puts\ -nonewline\ \$rfd\ \$copyBuff\n\ \ \ \ set\ remain\ \[expr\ \$remain\ -\ \$chunk\]\n\ \ \ \ puts\ -nonewline\ stdout\ .\n\ \ \}\n\ \ close\ \$lfd\n\ \ close\ \$rfd\n\ \ puts\ stdout\ \"\"\n\ \ puts\ stdout\ \"Copy\ successful\"\n\ \ return\ 1\n\}\n#############################################################################\n======\n\nNote\ that\ the\ above\ code\ is\ not\ the\ real\ thing\;\ there\ are\ things\ done\ between\ each\ write\ and\ the\ following\ read.\n\nUnfortunately,\ I\ can\ find\ no\ standard\ way\ to\ get\ the\ file\ descriptor\ for\ the\ open\ channel\ (Tcl_Channel\ being\ a\ pointer\ to\ an\ incomplete\ type),\ and\ there\ is\ no\ uniformity\ between\ the\ Windows,\ Mac\ and\ Unix\ ports\ as\ to\ the\ name\ of\ the\ system\ specific\ channel\ information\ and\ the\ names\ of\ the\ fields.\ \ The\ Unix\ specific\ header\ file\ is\ not\ visible\ to\ apps\ using\ an\ installed\ version\ of\ Tcl\ (I\ have\ to\ use\ the\ 8.2\ that\ is\ provided\ by\ the\ embedded\ OS\ vendor,\ and\ the\ sources\ for\ their\ port\ are\ not\ provided).\n\nAm\ I\ overlooking\ something?\ \ Is\ there\ a\ standard\ (and\ portable)\ way\ for\ extensions\ to\ access\ the\ POSIX\ style\ file\ descriptor\ for\ a\ Tcl_Channel\ object?\ \ I've\ written\ several\ Tcl\ extensions\ in\ the\ past,\ but\ none\ of\ them\ had\ to\ deal\ with\ Tcl_Channels\ at\ this\ level.\n\n----\n**\ Call\ to\ discussion\ regarding\ the\ Semantics\ of\ the\ oo::class\ command\ **\ \nmpdanielson\ would\ like\ to\ discuss\ the\ \[Semantics\ of\ the\ oo::class\ command\],\ wrt\ the\ interaction\ with\ packages\n\n----\n**Finding\ a\ faster\ a\ faster\ reaching\ a\ particular\ line\ number\ N\ in\ a\ file\ than\ by\ looping\ on\ \"gets\ \$f\"\ for\ lines\ before\ it**\n\n\[\[m\]\]\ -\ 2009-11-28\ 12:27:47\n\nIs\ there\ a\ faster\ way\ of\ reaching\ a\ particular\ line\ number\ N\ in\ a\ file\ than\ by\ looping\ on\ \"gets\ \$f\"\ for\ lines\ before\ it?\ In\ my\ case,\ the\ file\ is\ 2GB\ in\ size,\ ASCII\ content,\ with\ varying\ number\ of\ characters\ per\ line.\ It\ takes\ about\ 5\ minutes\ just\ to\ reach\ line\ 5000000\ (N),\ and\ only\ then\ does\ the\ actual\ processing\ begin.\ I\ can't\ use\ \"seek\"\ because\ number\ of\ bytes\ before\ line\ N\ is\ not\ known.\n\n\[EG\]\ You\ can\ combine\ \[chan\ read\],\ \[chan\ gets\]\ and\ \[split\]\ to\ build\ reasonably-sized\ lists\ of\ one\ element\ per\ line,\ and\ iterate\ over\ the\ file\ until\ you\ reach\ the\ line\ you\ want.\n\n======\n#\ pure\ gets\nproc\ UsingGets\ \{fname\ linenumber\}\ \{\n\ \ \ \ set\ fd\ \[open\ \$fname\]\n\ \ \ \ for\ \{set\ i\ 1\}\ \{\$i\ <=\ \$linenumber\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ chan\ gets\ \$fd\ data\n\ \ \ \ \}\n\ \ \ \ chan\ close\ \$fd\n\ \ \ \ return\ \$data\n\}\n\n#\ using\ read\ plus\ gets\ for\ the\ remaining\ chars\n#\ chunk\ is\ the\ chunk\ size\ to\ read\ in\ one\ go\nproc\ UsingRead\ \{fname\ linenumber\ \{chunk\ 100000\}\}\ \{\n\ \ \ \ set\ fd\ \[open\ \$fname\]\n\ \ \ \ set\ line\ 0\n\ \ \ \ while\ 1\ \{\n\ \ \ \ \ \ \ \ set\ data\ \[chan\ read\ \$fd\ \$chunk\]\n\ \ \ \ \ \ \ \ append\ data\ \[chan\ gets\ \$fd\]\n\ \ \ \ \ \ \ \ set\ sdata\ \[split\ \$data\ \\n\]\n\ \ \ \ \ \ \ \ set\ nl\ \[llength\ \$sdata\]\n\ \ \ \ \ \ \ \ if\ \{\$line\ +\ \$nl\ <\ \$linenumber\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ incr\ line\ \$nl\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ chan\ close\ \$fd\n\ \ \ \ \ \ \ \ \ \ \ \ return\ \[lindex\ \$sdata\ \[expr\ \{\$linenumber\ -\ \$line\ -\ 1\}\]\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n\n#\ this\ is\ a\ big_but_not_THAT_big\ file\ on\ my\ system\nset\ f\ /var/log/messages.1\nset\ linenumber\ 13500\n\nputs\ \"Pure\ gets:\ \[time\ \{puts\ \[UsingGets\ \$f\ \$linenumber\]\}\]\"\nputs\ \"Read-gets:\ \[time\ \{puts\ \[UsingRead\ \$f\ \$linenumber\]\}\]\"\n======\n\nOn\ my\ system,\ the\ output\ is\n\n======\n\$\ tclsh8.6\ reading.tcl\nNov\ 26\ 17:07:24\ merlot\ kernel:\ sd\ 6:0:0:0:\ \[sdc\]\ ASC=0x24\ ASCQ=0x0\nPure\ gets:\ 153451\ microseconds\ per\ iteration\nNov\ 26\ 17:07:24\ merlot\ kernel:\ sd\ 6:0:0:0:\ \[sdc\]\ ASC=0x24\ ASCQ=0x0\nRead-gets:\ 67498\ microseconds\ per\ iteration\n======\n\nTry\ testing\ several\ values\ of\ the\ chunk\ parameter\ to\ find\ the\ optimal\ for\ your\ system.\nNote\ that\ I've\ not\ tested\ the\ behaviour\ with\ another\ line\ ending\ than\ \\n\ (Unix\ system).\n\n\[dcd\]\ -\ 2009-12-30\n\ \ \ I'm\ assuming\ you\ don't\ care\ about\ the\ first\ part\ of\ the\ file\ before\ line\ N\ (although\ even\ \n\ \ \ if\ you\ do,\ I\ think\ I'm\ proposing\ a\ faster\ line\ counter.)\ Given\ that,\ regexp\ is\ pretty\ fast\n\ \ \ and\ you\ don't\ need\ to\ malloc\ for\ lines\ you\ don't\ care\ about.\ ok,\ untested\ code\ alert...\n\n\ \ \ set\ N\ 5000000\ #\ or\ whatever\n\ \ \ set\ n\ 0\n\ \ \ set\ eolre\ \{\\n\}\ #\ or\ whatever\n\ \ \ set\ f\ \[open\ file\]\n\ \ \ set\ lines\ \[read\ \$f\ \$chunksize\]\n\ \ \ while\ \{!\ \[eof\ \$f\]\}\ \{\n\ \ \ \ \ \ incr\ n\ \[regexp\ -all\ \$eolre\ \$lines\]\n\ \ \ \ \ \ if\ \{\$n\ >=\ \$N\}\ \{break\}\n\ \ \ \ \ \ set\ lines\ \[read\ \$f\ \$chunksize\]\n\ \ \ \}\n\ \ \ #\ deal\ with\ what's\ in\ \$lines\ and\ go\ on\n\n\[dcd\]\ -\ a\ little\ later\n\ \ \ I\ tested\ a\ variant\ of\ my\ implementation\ against\ \[EG\]s\ and\ on\ a\ reasonably\ large\ file\ mine\ lost.\n\ \ \ we\ have:\n\ \ \ \$\ ls\ -l\ bigfile.txt\n\ \ \ -rw-r--r--\ 1\ dcd\ Domain\ Users\ 876275714\ Dec\ 30\ 16:59\ bigfile.txt\n\ \ \ \$\ time\ wc\ -l\ bigfile.txt\n\ \ \ 6085879\ bigfile.txt\n\n\ \ \ real\ \ \ \ 0m4.187s\n\ \ \ user\ \ \ \ 0m2.343s\n\ \ \ sys\ \ \ \ \ 0m1.421s\n\n\ \ \ so,\ I\ tried,\ in\ tkcon\n\ \ \ %\ time\ \{UsingRead\ bigfile.txt\ 5000000\}\ 1\n\ \ \ 12592066\ microseconds\ per\ iteration\n\ \ \ vs\ a\ version\ of\ my\ code\ above\n\ \ \ %\ time\ \{readto\ \$f\ 5000000\ 100000\}\ 1\n\ \ \ 28341788\ microseconds\ per\ iteration\n\n\ \ \ near\ as\ I\ can\ tell,\ this\ means\ that\ tcl\ can\ allocate\ space\ and\ split\ on\ lines\ about\ twice\ as\ \n\ \ \ fast\ as\ regexp\ can\ walk\ through\ a\ buffer\ counting\ matches\ of\ a\ single\ character.\ whoda\ thunk\ it?\n\n\ \ \ %\ puts\ \$tcl_version\n\ \ \ 8.6\n\n----\n**\ Invoking\ tclsh\ for\ interactive\ execution,\ but\ specify\ file(s)\ to\ be\ sourced\ before\ issuing\ the\ first\ command\ prompt\ **\n\n\[Lavin\],\ 2009-12-24\ 12:58:52:\ How\ can\ I\ invoke\ tclsh\ for\ interactive\ execution,\ but\ specify\ file(s)\ to\ be\ sourced\ before\ issuing\ the\ first\ command\ prompt?\ \ TIA,\ \ --\ Mark\n\n\[AMG\]:\ See\ \[tclshrc\]\ for\ the\ answer.\n\n----\n**\ Resizable\ text\ widget\ **\n\n\[gasty\]\ -\ 2009-12-29\ 09:34:04\n\nHi\ all!\ I\ need\ a\ resizable\ text\ widget.\ Using\ pack\ as\ geometry\ manager\ works\ well:\n\n======\npack\ .t\ -expand\ 1\ -fill\ both\n======\n\nHowever\ I\ want\ to\ use\ grid:\n\n======\ngrid\ .t\ -row\ 0\ -column\ 0\ -sticky\ nwes\n======\n\nbut\ the\ widget\ do\ not\ \"expand\"\ when\ I\ change\ the\ size\ of\ their\ container.\ I\ also\ tried\ with\ rowconfigure\ and\ columnconfigure\ for\ this\ widget\ to\ set\ the\ weight\ parameter,\ but\ the\ results\ are\ the\ same.\nWhich\ can\ be\ the\ problem?\ I\ need\ some\ other\ option\ in\ the\ command\ above?\ Thanks\ in\ advance\ for\ any\ tip.\n\n\[Duoas\]\ 2009-12-29\ 10:28\ \ What\ did\ you\ set\ the\ weight\ as?\ The\ following\ should\ work\ just\ fine:\n\ \ grid\ .t\ -row\ 0\ -column\ 0\ -sticky\ news\n\ \ grid\ rowconfigure\ \ \ \ .\ .t\ -weight\ 1\n\ \ grid\ columnconfigure\ .\ .t\ -weight\ 1\nHope\ this\ helps.\n\n\[gasty\]\ I\ was\ using\ rowconfigure\ and\ columnconfigure\ incorrectly...\ Thanks!\n\n----\n**\ How\ to\ execute\ an\ application\ in\ the\ background\ while\ being\ able\ to\ know\ when\ that\ application\ has\ ended.**\ \ \n\ \n\[OK\]\ -\ 2010\ -1-25\ 10:36\n\nHi\ all,\nI'm\ new\ to\ tcl\ and\ need\ to\ find\ out\ how\ to\ exec\ an\ application\ in\ the\ background\ but\ be\ able\ to\ know\ when\ that\ application\ has\ ended.\ \ \n\nSo\ far,\ I\ browsed\ different\ sources\ and\ know\ I\ can\ execute\ in\ the\ background\ with\ &,\ but\ are\ not\ able\ to\ find\ how\ to\ known\ when\ this\ application\ has\ ended.\n\nexec\ cmd\ /c\ \"path_to_exec/prog.exe\ /123q\"\ &\n\nPeople\ recommended\ using\ wait,\ but\ I\ can't\ find\ an\ example\ of\ how\ to\ implement\ this.\ \ Please\ advise.\n\n\[AMG\]:\ Use\ \[\[\[open\]\ |cmdline\]\]\ to\ create\ \[pipeline\]s.\ \ \[\[\[wait\]\]\]\ is\ a\ \[TclX\]\ command.\n\n\[Hai\ Vu\]\ See\ this\ thread:\ http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/f8ccd018858026a0/e109d759a3debcb2?lnk=gst&q=exec+wait#e109d759a3debcb2\n\n----\n**\ Problem\ with\ the\ documentation\ that\ comes\ with\ critcl,\ i.e.\ the\ file\ critcl.tkd.**\ \ \n\n\[sdwillingham\]\ 2010.02.12:\n\nI'm\ having\ trouble\ with\ the\ documentation\ that\ comes\ with\ critcl,\ i.e.\ the\ file\ critcl.tkd.\ \ I've\ tried\ several\ versions\ of\ Wikit,\ both\ as\ regulars\ scripts\ and\ using\ tclkit\ on\ two\ different\ Windows\ XP\ computers\ with\ ActiveTCL\ 8.4\ and\ 8.5.\ \ The\ problem\ is\ that\ the\ the\ first\ page\ loads\ up\ and\ renders\ fine,\ but\ when\ I\ click\ on\ links,\ most\ pages\ are\ nearly\ empty\ with\ just\ a\ character\ or\ two.\ \ Using\ wikitool.tcl,\ I\ can\ see\ that\ the\ information\ is\ intact\ within\ critcl.tkd,\ but\ other\ than\ that,\ I\ am\ stumped\ on\ how\ to\ fix\ the\ problem.\n\n----\n**\ Problem\ with\ using\ tcom\ to\ interface\ with\ into\ the\ SAPI\ COM\ object\ for\ Text\ To\ Speech\ **\n\[notlistening\]\ 2010.02.27\n\nI\ am\ using\ tcom\ to\ interface\ with\ into\ the\ SAPI\ COM\ object\ for\ Text\ To\ Speech.\ I\ am\ trying\ to\ get\ SAPI\ to\ pass\ back\ an\ audio\ stream\ for\ use\ within\ my\ tcl\ script.\ I\ have\ come\ up\ short\ on\ a\ problem\ with\ iDispatch\ on\ tcom.\ I\ was\ hoping\ that\ someone\ could\ begin\ to\ explain\ where\ i\ need\ to\ look\ to\ make\ the\ nessesary\ changes\ to\ make\ ole32\ to\ implement\ iDispatch\ or\ suggest\ some\ ideas\ on\ how\ I\ can\ get\ the\ audio\ stream\ directly\ into\ my\ app.\ The\ test\ code\ that\ I\ have\ so\ far\ is:\n\n======\npackage\ require\ tcom\n\n\ \ \ \ \ \ \ #\ ::tcom::configure\ -concurrency\ multithreaded\n\ \ \ \ \ \ \ set\ voice\ \[::tcom::ref\ createobject\ Sapi.SpVoice\]\n\ \ \ \ \ \ \ set\ APO\ \[::tcom::ref\ createobject\ Sapi.SpCustomStream\]\n\ \ \ \ \ \ \ set\ GI\ \[::tcom::ref\ createobject\ \ Sapi.SPStream\]\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ set\ GIC\ \[\$GI\ -call\ CreateStreamOnHGlobal\]\;\ #\ At\ the\ moment\ the\ code\ errors\ here\ with\ -\ object\ does\ not\ implement\ IDispatch\n\n\ \ \ \ \ \ \ \[\$GIC\ hGlobal\ NULL\]\n\ \ \ \ \ \ \ \[\$GIC\ fDeleteOnRelease\ True\]\n\ \ \ \ \ \ \ \[\$GIC\ ppstm\ \$GI\]\n\n\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ set\ APOBS\ \[\$APO\ BaseStream\]\n\ \ \ \ \ \ \ set\ \$APOBS\ \$GI\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ set\ VAOS\ \[\$voice\ AudioOutputStream\]\ \n\ \ \ \ \ \ \ set\ \$VAOS\ \$APO\n\ \ \ \ \ \ \ \ \n\n\ \ \ \ \ \ \ \$voice\ Speak\ \"Welcome!\"\n\ \ \ \ \ \ \ while\ \{1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \[\$APO\ Read\ \$GI\ 100\]\n\ \ \ \ \ \ \ \ \ \ \ puts\ \$test\n\ \ \ \ \ \ \ \}\n======\n\nAny\ suggestions\ on\ how\ i\ can\ go\ about\ getting\ this\ to\ work\ in\ tcl\ /\ tcom\ /\ other\ would\ be\ great.\ I\ am\ not\ afraid\ of\ doing\ the\ hard\ work\ in\ the\ background\ but\ am\ a\ little\ bit\ unclear\ how\ to\ start.\ I\ have\ very\ little\ to\ no\ knowledge\ of\ COM\ objects\ and\ mechanisms\ in\ Windows\ but\ I\ am\ willing\ to\ learn.\ Ideally\ a\ quick\ dirty\ hack\ would\ suffice\ but\ beggars\ can\ not\ be\ choosers.\n\n----\ \ \n**\ How\ to\ make\ the\ frame\ with\ the\ data\ to\ fill\ both\ vertical\ and\ horizontal\ with\ BWidget\ ScrollableFrame\ **\ \n\[ICU\]\ -\ 2010-03-01\ 06:59:59\ \n\nI\ added\ scrollbar\ to\ http://wiki.tcl.tk/14901%|%simple\ Tktable%|%\ with\ the\ help\ of\ BWidget\ ScrollableFrame.\ It\ works\ BUT\ I\ just\ can't\ figure\ out\ how\ to\ make\ the\ frame\ with\ the\ data\ to\ fill\ both\ vertical\ and\ horizontal.\ I\ can\ make\ it\ work\ with\ ScrollableFrame\ -width/-height\ commands,\ but\ it\ would\ be\ better\ if\ the\ frame\ would\ resize\ itself.\ \n\nHere\ is\ the\ code\ where\ the\ table\ is\ being\ built.\ I\ would\ appreciate\ if\ someone\ could\ help\ me\ at\ where\ I'm\ going\ wrong.\n\n\ \ \ \ \ \ \ \ destroy\ \$pathName\n\ \ \ \ \ \ \ \ frame\ \$pathName\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ set\ r\ 0\;\ set\ c\ 0\n\ \ \ \ \ \ \ \ set\ w\ \[ScrolledWindow\ \"\$pathName.r\$\{r\},\$c\"\]\n\ \ \ \ \ \ \ \ pack\ \$w\ -fill\ both\ -expand\ true\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ set\ t\ \[ScrollableFrame\ \$w\$pathName\ -height\ 650\ -width\ 650\]\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \$w\ setwidget\ \$t\n\ \ \ \ \ \ \ \ set\ uf\ \[\$t\ getframe\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ for\ \{set\ r\ 0\}\ \{\$r\ <\ \$A(-rows)\}\ \{incr\ r\}\ \{\n\ \ \ \ \ \ \ \ for\ \{set\ c\ 0\}\ \{\$c\ <\ \$A(-cols)\}\ \{incr\ c\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ w\ \"\$uf.r\$\{r\},\$c\"\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$r\ <\ \$A(-titlerows)\ ||\ \$c\ <\ \$A(-titlecols)\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\ \$::tcl_platform(platform)\ eq\ \"windows\"\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ bg\ SystemDisabledText\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ bg\ darkgrey\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ label\ \$w\ \ -textvariable\ \$A(-variable)\\(\$r,\$c\\)\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ flat\ -bg\ \$bg\ -fg\ white\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ elseif\ \{\[lsearch\ \$A(-readonlyrows)\ \$r\]\ !=\ -1\ ||\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lsearch\ \$A(-readonlycols)\ \$c\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ label\ \$w\ -textvariable\ \$A(-variable)\\(\$r,\$c\\)\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ sunken\ -bd\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$w\ config\ -font\ \[lindex\ \[\$w\ config\ -font\]\ 3\]\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ entry\ \$w\ -textvariable\ \$A(-variable)\\(\$r,\$c\\)\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ sunken\ -bd\ 2\ -justify\ center\ -width\ 0\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #if\ \{\[info\ exists\ A(-vcmd)\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\$w\ config\ -validate\ key\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -vcmd\ \[list\ \$A(-vcmd)\ \$r\ \$c\ %P\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ grid\ \$uf.r\$\{r\},\$c\ -row\ \$r\ -column\ \$c\ -sticky\ ew\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \}\n\n\[ICU\]\nI\ was\ able\ to\ solve\ it.\n\n\[Fro\]\ -\ 2010-04-06\ 17:28:34\n\nThanks\ for\ the\ reply,\ I\ got\ it\ working.\n\n----\n**\ Problem\ with\ info\ hostname\ **\n\n\[MaheshD\]\ -\ 2010-04-08\ 05:38:28\n\[info\ hostname\]\ issue\n\nHelp\ needed\ with\ the\ following\ issue\ :\n\[ambiguous\ result\ with\ \"info\ hostname\ \"\]\n\n----\n**\ Problem\ in\ namespace\ scope\ of\ variables\ **\n\n\[MaheshD\]\ -\ 2010-04-14\ 04:40:12\n\nProblem\ in\ namespace\ scope\ of\ variables\n\nWrite\ a\ TCL\ file\ with\ a\ namespace\ definition\ in\ it\ as\ :\n\nfile\ \"a.tcl\"\n\n\ \ namespace\ eval\ nse\ \{\n\ \ \ \ set\ WorkDir\ \"/home/sj/name\"\n\ \ \}\n\nUnder\ TCL\ prompt,\ do\ the\ following\ :\n\n\ %\ set\ WorkDir\ \"asdf\"\n\ asdf\n\ %\ source\ a.tcl\n\ /home/sj/name\n\ %\ puts\ \$nse::WorkDir\n\ can't\ read\ \"nse::WorkDir\":\ no\ such\ variable\n\ %\n\nWhy\ is\ this\ behaviour,\ why\ are\ the\ variable\ names\ in\ global\ scope\ clashing\ with\ the\ one\ in\ namespace\ \"nse\"\n\nPlease\ help\ ?\n\n\[Martyn\ Smith\]\ 14\ Apr\ 2010\ There\ is\ not\ a\ clash\ your\ namespace\ eval\ only\ executes\ the\ code\ in\ the\ namespace\ fo\ your\ WorkingDir\ variable\ is\ destroyed\ at\ the\ end\ of\ the\ namespace\ eval.\ \ What\ you\ are\ looking\ for\ is\n\n\ \ namespace\ eval\ nse\ \{\n\ \ \ \ variable\ WorkDir\ \"/home/sj/name\"\n\ \ \}\n\nWhich\ creates\ a\ variable\ in\ the\ nse\ namespace\ and\ initialises\ it.\ Then\ to\ access\ you\ variable\ in\ another\ procedure\ you\ use\n\ \ variable\ WorkDir\n\n\[Lars\ H\]:\ While\ Martyn's\ fix\ is\ correct,\ I\ think\ his\ explanation\ is\ wrong.\ Namespace\ variables\ don't\ get\ destroyed\ when\ a\ \[namespace\ eval\]\ ends,\ this\ is\ rather\ an\ example\ of\ the\ \[dangers\ of\ creative\ writing\]:\ the\ namespaced\ \[set\]\ chose\ to\ update\ the\ existing\ ::WorkDir\ variable\ rather\ than\ the\ ::nse::WorkDir\ that\ would\ have\ to\ be\ created.\n\n----\n**Help\ with\ tcltest\ harness\ **\n\n18MAR2010\n\nHi\ all,\ I'm\ new\ to\ tcltest\ but\ not\ completely\ green\ with\ tcl\ in\ general.\ \ I'm\ trying\ to\ get\ my\ head\ around\ the\ use\ of\ the\ tcltest\ harness.\ \ We\ tend\ to\ write\ multiple\ .tcl\ files\ as\ part\ of\ a\ Component-level\ test\ (CSC\ test).\ \ So\ I\ think\ what\ I\ would\ do\ is\ write\ an\ individual\ .test\ file\ for\ each\ software\ Component,\ which\ would\ have\ some\ number\ of\ calls\ to\ tcltest::test\ in\ order\ to\ run\ each\ script\ file\ that\ makes\ up\ the\ whole\ set\ of\ functionality\ tests\ for\ a\ given\ Component.\n\nBelow\ is\ the\ high-level\ 'master'\ tcl\ that\ whould\ run\ all\ lower-level\ '.test'\ tcl\ files,\ and\ then\ one\ sample\ .test\ file\ for\ a\ Component\ named\ CSC_foo.\ \ \n\nI\ guess\ I\ have\ 2\ questions:\n1)\ Am\ I\ understanding\ all\ this\ correctly\ as\ far\ as\ what\ goes\ in\ each\ type\ of\ file\ (.tcl,\ .test),\ and\ \n2)\ Where\ I\ need\ to\ use\ a\ raw\ 'filename.tcl'\ vs.\ a\ 'source\ filename.tcl'\ call\ in\ order\ to\ have\ individual\ .tcl\ files\ get\ run.\ (this\ stems\ from\ the\ man\ page\ text\ talking\ about\ -setup,\ -cleanup,\ and\ -body.\ For\ example,\ for\ -setup,\ it\ says\ \"The\ optional\ -setup\ attribute\ indicates\ a\ ''script''\",\ I'm\ not\ sure\ if\ the\ -setup\ syntax\ is\ \"-setup\ filename.tcl\"\ or\ if\ it\ would\ be\ \"-setup\ source\ filename.tcl\".)\n\nThanks\ very\ much\ in\ advance.\n\n-\ Jeff\n\n======\n#\ FILENAME:\ CSCI.tcl\n#\ Top-level\ script\ (usually\ named\ all.tcl)\ to\ run\ all\ tests\ defined\ in\n#\ .test\ files\ \n#\ \n\npackage\ require\ Tcl\npackage\ require\ tcltest\nnamespace\ import\ tcltest::*\nconfigure\ \{*\}\$argv\ -testdir\ \[file\ dir\ \[info\ script\]\]\nrunAllTests\n\n#\ end\ CSCI.tcl\n\n#\ FILENAME:\ CSC_foo.test\n#\ \ \ \ \ \ \ \ \ \ \ \n#\ There's\ one\ of\ these\ .test\ files\ for\ each\ CSC.\n#\ A\ CSC\ test\ may\ have\ multiple\ .tcl\ files\ associated\ with\ it.\n#\ \ \n#\ \ e.g.\ \ As\ part\ of\ CSC\ foo,\ there\ may\ be\ the\ following\ script\ files\n#\ \ \ \ \ \ \ \ to\ segregate\ testing\ into\ logical\ chunks:\ \n#\n#\ \ \ \ \ \ \ \ foo_mode_tests.tcl\ \n#\ \ \ \ \ \ \ \ foo_parameter_tests.tcl\n#\ \ \ \ \ \ \ \ foo_fault_tests.tcl\n#\npackage\ require\ tcltest\neval\ ::tcltest::configure\ \$argv\npackage\ require\ CSC_foo\nnamespace\ eval\ ::CSC_foo::test\ \{\n\ \ \ namespace\ import\ ::tcltest::*\n\ \ \ testConstraint\ X\ \[expr\ \{...\}\]\n\ \ \ variable\ SETUP\ \{FQT_TC_Setup.tcl\}\n\ \ \ variable\ CLEANUP\ \{FQT_TC_Cleanup.tcl\}\n\n\ \ \ #\ Run\ all\ 3\ test\ cases\ for\ CSC_foo\n\n\ \ \ test\ CSC_foo-mode_tests\ \{runs\ foo_mode_tests.tcl\ script\}\ \n\ \ \ \ \ \ -setup\ \$SETUP\ \n\ \ \ \ \ \ -constraints\ X\ \n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_mode_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\n\ \ \ test\ CSC_foo-param_tests\ \{runs\ foo_param_tests.tcl\ script\}\ \n\ \ \ \ \ \ -setup\ \$SETUP\ \n\ \ \ \ \ \ -constraints\ X\ \n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_parameter_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\n\ \ \ test\ CSC_foo-fault_tests\ \{runs\ foo_fault_tests.tcl\ script\}\ \n\ \ \ \ \ \ -setup\ \$SETUP\ \n\ \ \ \ \ \ -constraints\ X\ \n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_fault_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\n\ \ \ cleanupTests\ #\ this\ is\ a\ tcltest\ function,\ it\ prints\ the\ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ PASS/FAIL/SKIP\ info\ #\ among\ other\ things\n\n\}\ #\ end\ namespace\ eval\ ::CSC_XYZ::test\n\nnamespace\ delete\ ::CSC_foo::test\n\n#\ end\ CSC_foo.test\n======\n\n\[hv\]\ Here\ are\ what\ I\ notice:\ \ (1)\ Yes,\ you\ understood\ correctly.\ By\ default,\ the\ *.test\ files\ will\ be\ included\ in\ the\ test\ suite.\ (2)\ The\ arguments\ to\ -setup\ and\ -cleanup\ are\ just\ a\ block\ of\ code.\ For\ example:\n\n\ \ \ \ set\ SETUP\ \{\n\ \ \ \ \ \ \ \ set\ x\ 1\ \n\ \ \ \ \ \ \ \ set\ s\ \"some\ string\"\n\ \ \ \ \}\ \ \ \n\n\ \ \ \ test\ testName\ \{description\}\ -setup\ \$SETUP\ -body\ \{\n\ \ \ \ \ \ \ \ #\ Body\ of\ test\ ...\n\ \ \ \ \}\ -result\ \{expected\ result\}\n\nSimilarly,\ you\ can\ define\ a\ variable\ and\ pass\ that\ to\ the\ -cleanup\ flag.\ Note\ that\ if\ you\ don't\ fit\ everything\ into\ one\ line,\ you\ have\ to\ use\ line\ contiuation\ (\\),\ the\ only\ exception\ is\ the\ open\ brace\ \{:\n\n\ \ \ test\ CSC_foo-mode_tests\ \{runs\ foo_mode_tests.tcl\ script\}\ \\\n\ \ \ \ \ \ -setup\ \$SETUP\ \\\n\ \ \ \ \ \ -constraints\ X\ \\\n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_mode_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\nAs\ a\ personal\ preference,\ I\ structure\ my\ tests\ as:\n\n\ \ \ \ test\ testName\ \{\n\ \ \ \ \ \ \ \ Test\ description\ goes\ here\n\ \ \ \ \}\ -setup\ \$SETUP\ -cleanup\ \$cLEANUP\ -body\ \{\n\ \ \ \ \ \ \ \ #\ test\ body\ goes\ here\n\ \ \ \ \}\ -result\ \{expected\ result\}\n\n\n\[Fro\]\ Thanks\ for\ the\ reply\ hv,\ I\ was\ able\ to\ get\ it\ working.\ \n\n----\n**\ How\ to\ return\ a\ list\ of\ arguments\ from\ a\ procedure\ **\n\[mreister\]\ -\ 2010-05-26\ 23:18:42\n\nOk\ so\ I\ am\ pretty\ new\ to\ TCL\ and\ I\ am\ using\ it\ for\ scripting\ a\ command\ line\ (modelsim\ for\ anyone\ who\ cares)\ but\ anyways\ I\ am\ having\ trouble\ figuring\ out\ how\ i\ can\ return\ a\ string\ of\ arguements\ from\ a\ precudure.\ As\ i\ understand\ it\ when\ a\ procedure\ i\ wrote\ executes\ its\ return\ value\ get\ executed\ on\ the\ command\ line.\ So\ I\ am\ able\ to\ return\ a\ command\ with\ a\ singal\ word\ but\ when\ i\ try\ to\ return\ a\ command\ with\ multiple\ words\ tcl\ seems\ to\ only\ try\ to\ read\ the\ first\ word\ of\ the\ command\ and\ when\ i\ put\ it\ return\ command\ in\ quotes\ it\ seems\ that\ the\ command\ line\ interprets\ the\ return\ value\ in\ quotes\"\".\ For\ example:\n\nproc\ set_f\ \{cycle_number\}\ \{\n\ \ \ \ \n\ \ \ \ switch\ \ \$cycle_number\ \{\n\ \ \ \ \ \ \ \ 1\{\n\ \ \ \ \ \ \ \ \ \ \ \ return\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ 2\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"force\ -freeze\ sim:/uart/reset\ 0\ 0\"\ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ default\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"hello\"\ \ \ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \n\ \ \ \ return\ force\ -freeze\ sim:/uart/reset\ 1\ 0\n\}\n\nIn\ this\ situation\ its\ seems\ to\ try\ to\ return\ force\n\nBut\ when\ I\ do\ this:\n\nproc\ set_f\ \{cycle_number\}\ \{\n\ \ \ \ \n\ \ \ \ switch\ \ \$cycle_number\ \{\n\ \ \ \ \ \ \ \ 1\{\n\ \ \ \ \ \ \ \ \ \ \ \ return\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ 2\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"force\ -freeze\ sim:/uart/reset\ 0\ 0\"\ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ default\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"hello\"\ \ \ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \n\ \ \ \ return\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\n\}\n\nIt\ seems\ to\ retrun\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\ to\ the\ command\ line\ rather\ than\ force\ -freeze\ sim:/uart/reset\ 1\ 0.\ Which\ is\ what\ I\ want.\ So\ my\ question\ is\ how\ can\ i\ return\ the\ line\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\ to\ the\ command\ line\ WITHOUT\ the\ quotes?\n\n\[AM\]\ You\ do\ not\ describe\ the\ code\ that\ gets\ this\ returned\ string\ and\ needs\ to\ deal\ with\ the\ multiple\ returned\ strings.\ I\ will\ make\ a\nguess:\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\ is\ meant\ as\ an\ external\ program\ with\ arguments.\ If\ so,\ then:\n\n(if\ you\ use\ Tcl\ 8.5)\n\n\ \ \ \ set\ command\ \[set_f\ \$cycle_number\]\n\ \ \ \ exec\ \{*\}\$command\n\n(or\ if\ you\ use\ Tcl\ 8.4\ or\ previous)\n\n\ \ \ \ set\ command\ \[set_f\ \$cycle_number\]\n\ \ \ \ eval\ exec\ \$command\n\nwill\ run\ the\ program\ \"force\"\ with\ the\ individual\ arguments\ -freeze,\ sim:/uart/reset,\ 1\ and\ 0.\n\nThe\ expansion\ operator\ \[\{*\}\]\ expands\ a\ list\ into\ individual\ arguments\ and\ the\ command\ eval\ re-interprets\ the\ entire\ list\ of\ arguments\ as\ a\ string.\ (Note\ the\ eval\ command\ should\ actually\ be\ more\ complicated\ to\ avoid\ nasty\ stuff\ with\ embedded\ \[\[\]\]\ and\ the\ like\ -\ the\ very\ reason\ for\nthe\ introduction\ of\ \{*\}).\n\nSo,\ it\ is\ the\ caller\ that\ needs\ to\ deal\ with\ the\ multiple\ arguments,\ not\ the\ callee.\n\nFurthermore:\ if\ you\ want\ to\ return\ multiple\ pieces,\ it\ is\ best\ to\ use\ a\ list:\n\n\ \ \ \ return\ \[list\ force\ -freeze\ sim:/uart/reset\ 1\ 0\]\n\nas\ then\ the\ individual\ pieces\ are\ well\ defined\ and\ protected\ against\ haphazard\ conversions.\n\n----\n**\ How\ to\ copy\ drawings\ from\ the\ canvas\ and\ paste\ into\ Word\ or\ PowerPoint\ **\n\n\[Beware\],\ 5th\ June\ 2010:\ Where\ can\ I\ find\ some\ information\ on\ 'general'\ Windows\ copy\ and\ paste?\ \ I'd\ quite\ like\ to\ be\ able\ to\ copy\ drawings\ from\ the\ canvas\ and\ paste\ into\ Word\ or\ PowerPoint,\ where\ they\ would\ become\ Office\ drawings.\n\nI\ can't\ find\ any\ useful\ information\ through\ Microsoft.\n\n\[Lars\ H\]:\ The\ -type\ option\ of\ \[clipboard\]\ is\ probably\ relevant,\ but\ I\ don't\ know\ what\ might\ be\ meaningful\ values\ on\ \[Microsoft\ Windows\].\ The\ likeliest\ place\ to\ find\ an\ answer\ to\ this\ is\ probably\ some\ sort\ of\ Windows/Tk\ FAQ,\ as\ this\ is\ an\ area\ where\ the\ Tk\ manpages\ are\ very\ \[X\]-centric.\ I\ also\ notice\ the\ Wiki\ \[clipboard\]\ page\ has\ some\ pointers\ regarding\ bitmap\ copy\ and\ paste\ on\ Windows.\n\n\[MG\]\ \[Copy\ image\ to\ and\ from\ the\ Windows\ clipboard\]\ may\ be\ of\ some\ use.\n\n----\n**\ Problem\ with\ directories\ which\ are\ to\ be\ checked\ **\n\[maheshd\]\ -\ 2010-06-30\ 08:44:06\n\nThe\ command\ \[file\ writable\]\ was\ used\ to\ know,\ if\ a\ certain\ directory\ has\ write\ permissions\ for\ a\ certain\ user.\nThe\ command\ is\ written\ as\ a\ TCL\ script\ which\ is\ then\ remotely\ executed\ onto\ the\ slave\ machine\ from\ the\ master.\nNow,\ the\ problem\ is,\ the\ directories\ which\ are\ to\ be\ checked\ for\ write\ permissions\ are\ automounted\ on\ slave.\nAs\ is\ the\ case\ with\ auto\ mount,\ until\ and\ unless\ the\ mount\ partition\ is\ used,\ the\ partition\ remains\ unmounted.\nHence\ the\ command\ \"file\ writable\ <DirectoryName>\"\ fails,\ i.e\ it\ reports\ that\ <DirectoryName>\ has\ no\ write\ permissions.\nBut,\ if\ the\ remote\ directory\ <DirectoryName>\ is\ visited\ once,\ i.e\ a\ \"cd\ <Directoryname>\ and\ ls\",\ it\ results\ in\ the\npartition\ being\ mounted\ and\ from\ then\ on\ the\ TCL\ script\ containing\ '''file\ writable'''\ command\ works\ fine.\n\n'''The\ question'''\ :\ Is\ there\ any\ way\ to\ check\ for\ the\ same\ without\ actually\ hard\ mounting\ the\ partition\ and\ without\ visiting\ the\ directory\ (not\ even\ once).\n\n\[AMG\]:\ This\ isn't\ a\ Tcl\ question.\ \ It's\ very\ OS-specific.\n\nI\ suspect\ the\ answer\ is\ \"no\"\ because\ (if\ I\ read\ you\ right)\ you're\ trying\ to\ figure\ out\ the\ permissions\ of\ the\ root\ directory\ of\ a\ filesystem\ without\ mounting\ that\ filesystem.\ \ It's\ impossible\ to\ read\ the\ permissions\ bits\ without\ reading\ the\ filesystem,\ and\ the\ only\ sensible\ way\ to\ do\ this\ is\ to\ mount\ it.\n\n----\nDoes\ anyone\ have\ a\ simple\ TK\ C\ callback\ Example?\n\nstevieb\ -\ 2011-07-17\ 21:54:00\n\nI\ am\ new\ to\ TCL/TK,\ I\ have\ some\ C\ code\ and\ I\ want\ to\ put\ a\ TK\ front\ end\ on\ it,\ can\ anyone\ get\ me\ started\ by\ providing\ a\ simple\ example\ of\ a\ TK\ GUI\ that\ invokes\ a\ C\ callback,\ it\ could\ be\ as\ simple\ as\ the\ HelloWorld.c\ example,\ where\ you\ click\ a\ button\ and\ the\ C\ function\ is\ called\ by\ TK\ to\ write\ out\ Hello\ World!\n\nThanks\n\nstevieb\ \ \n\n\[RLE\]\ (2011-07-17):\ You\ may\ want\ to\ take\ a\ look\ at\ the\ \[Critcl\]\ and\ \[Critcl\ 2\]\ pages,\ as\ well\ as\ search\ for\ other\ wiki\ pages\ relating\ to\ Critcl.\ \ It\ provides\ a\ very\ easy\ way\ to\ interface\ C\ code\ into\ Tcl\ code.\n\n\n\n<<categories>>\ Discussion\ |\ Development regexp2} CALL {my render {Ask, and it shall be given # 8} ''This\ page\ has\ had\ numerous\ incidents\ of\ being\ deleted\ and\ corrupted.\ \ Please\ be\ very\ careful\ when\ editing\ it.\ \ If\ you\ inadvertently\ delete\ it,\ immediately\ revert\ your\ edit\ using\ the\ History\ link\ on\ the\ left\ side\ of\ this\ page.\ \ Do\ NOT\ attempt\ to\ restore\ it\ by\ copying'n'pasting\ the\ text\ from\ a\ previous\ revision,\ or\ all\ page\ formatting\ will\ be\ lost!''\n\n!!!!!!\n'''Please\ add\ hyperlinks\ leading\ to\ your\ question\ at\ the\ top\ of\ this\ page.'''\n<<br>>\nAlso\ consider\ putting\ a\ **section\ heading**\ on\ the\ top\ of\ each\ new\ question.\n<<br>>\nAnd\ of\ course,\ please\ put\ new\ questions\ at\ the\ '''TOP'''\ of\ the\ page,\ so\ that\ as\ the\ page\ grows\ longer,\ new\ questions\ are\ seen\ first.\n!!!!!!\n\nOnce\ you\ have\ received\ a\ satisfactory\ answer,\ ''please''\ put\ your\ question\ and\ answer\ directly\ on\ an\ appropriate\ page\ of\ the\ wiki\ (if\ you\ cannot\ find\ an\ existing\ page,\ create\ a\ new\ one).\ \n\nAnd\ of\ course,\ please\ put\ new\ questions\ at\ the\ TOP\ of\ the\ page,\ so\ that\ as\ the\ page\ grows\ longer,\ new\ questions\ are\ seen\ first.\n\nAfterwards,\ remove\ the\ original\ question\ and\ answer\ and\ leave\ a\ hyperlink\ here\ (as\ \[ARA\]\ has\ done\ on\ May\ 2\ 2009)\;\ this\ way\ everyone\ will\ know\ who\ needs\ help.\ This\ page\ could\ then\ act\ as\ a\ sort\ of\ reference\ page\ for\ questions\ asked\ by\ the\ Community\ -\ sort\ of\ ''Who\ has\ asked\ what\ and\ when''.\ Thanks\ for\ your\ help.\n\n\ \ \ \ *\ '''Started\ on:'''\ 2009\ May\ 02\n\ \ \ \ *\ '''Ended\ on:'''\ 2011\ February\ 5th\ (Saturday)\n\n----\n**\ linsert\ in\ recursive\ lists***\n\nHi\ all,\ \n\nI\ have\ written\ a\ code\ to\ get\ the\ index\ of\ recursive\ lists:\ \nset\ a\ \{a\ b\ \{c\ \{d\ e\}\}\}\ \n%proc\ List\{list_name\ \{prefix\ \{\}\}\}\ \{\ \n\ \ \ \ set\ end_point\ \[expr\ \[llength\ \$list_name\]\ -1\]\ \n\ \ \ \ for\ \{set\ start_point\ 0\}\ \{\$start_point\ <=\ \$end_point\}\ \{incr\ start_point\}\ \{\ \n\ \ \ \ if\ \{\[llength\ \[lindex\ \$list_name\ \$start_point\]\]\ ==\ 1\}\ \{\ \n\ \ \ \ puts\ \"Index\ for\ \[lindex\ \$list_name\ \$start_point\]\ is\ \$prefix\$start_point\"\ \n\ \ \ \ \ \}\ else\ \{\ \n\ \ \ \ append\ prefix\ \$start_point\ \n\ \ \ \ List\[lindex\ \$list_name\ \$start_point\]\ \$prefix\ \n\ \ \ \}\ \n\}\ \n\nNow\ in\ this\ i\ want\ insert\ some\ elements\ inside,\ how\ can\ i\ do\ that.\ \nEg:\ This\ is\ how\ the\ program\ should\ look\ like\ \nputs\ \"Enter\ element\"\ \ngets\ stdin\ el\ \{\ user\ enters\ as\ 4\ \}\ \nputs\ \"Enter\ insert\ posittion\"\ \ngets\ stdin\ ind\ \{\ user\ gives\ as\ 210\}\ \nSo\ if\ 210\ index\ is\ valid\ in\ the\ list\ the\ new\ element\ should\ be\ inserted\ and\ if\ the\ user\ gives\ ind\ as\ something\ like\ 530\ it\ should\ display\ \"error\ in\ index\ entered\"..\ \nHow\ can\ i\ do\ this?\ \nPlease\ help.\ \n\nThanks\ in\ advance\n\n\[gold\]16jun2011,\ \ Ask9\ has\ question\ on\ \ nested\ list\ input\ also.\nMaybe\ combine\ q&a?\ Found\ refs.\ \[list\ level\],\ discussion\ in\ \[linsert\]\ and\ \[lset\]\nSee\ section\ on\ list\ in\ http://en.wikibooks.org/wiki/Tcl_Programming/Introduction.\nReally\ asking\ for\ lset\ with\ multiple\ index.\n======\n\ console\ operation\n\ %\ set\ test\ \{\{a\ b\}\ \{c\ d\}\}\n\ \{a\ b\}\ \{c\ d\}\n\ %\ lset\ test\ 1\ 1\ x\n\ \{a\ b\}\ \{c\ x\}\n\ %\ lset\ test\ 1\ 1\ \{\ x\ gosh\}\n\ \{a\ b\}\ \{c\ \{\ x\ gosh\}\}\n\ \ if\ \{\ \[\ lset\ test\ 1\ 1\ 2\ 3\ 4\ x\ \]\ !=\ 1\ \}\ \{\n\ \ \ \ error\ \"\ index\ level\ not\ found\"\n\ \ \}\n\ console\ returns\ \"list\ index\ out\ of\ range\"\n\n======\n\n\[jbr\]\ -\ Here\ is\ a\ similar\ strange\ command\ I\ created\ just\ a\ little\ while\ ago.\ \ Maybe\ there\ should\ be\ a\ general\ discussion\ on\ commands\ that\ build\ data\ structures\ and\ need\ list\ variable\ semantics\ with\ multiple\ indices?\n\n\ proc\ dict-lappend\ \{\ dict\ args\ \}\ \{\n\ \ \ \ upvar\ \$dict\ D\n\n\ \ \ \ set\ keys\ \ \[lrange\ \$args\ 0\ end-1\]\n\ \ \ \ set\ value\ \[lindex\ \$args\ end\]\n\n\ \ \ \ if\ \{\ \[info\ exists\ D\]\ &&\ \[dict\ exists\ \$D\ \{*\}\$keys\]\ \}\ \{\n\ \ \ \ \ \ \ \ dict\ set\ D\ \{*\}\$keys\ \[list\ \{*\}\[dict\ get\ \$D\ \{*\}\$keys\]\ \$value\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ dict\ set\ D\ \{*\}\$keys\ \[list\ \$value\]\n\ \ \ \ \}\n\ \}\n\n\n\n======\n\n**\ Shutting\ down\ a\ virtual\ machine\ by\ ssh'ing\ into\ it\ via\ Tcl/Expect\ **\n\n\[sg332\]\ 2011-012-06\ I\ am\ trying\ to\ shutdown\ down\ a\ Virtual\ machine\ by\ ssh'ing\ into\ it\ via\ Tcl/Expect.\ At\ the\ point\ after\ I\ send\ \"yes\\r\"\ using\ the\ send\ command\ in\ response\ to\ a\ confirmation\ request\ of\ my\ earlier\ shutdown\ request,\ sometimes\ I\ find\ a\ print\ out\ of\ just\ \"y\"\ and\ expect\ times\ out\ while\ waiting\ for\ the\ follow-on\ shutdown\ confirmation.\ Can\ someone\ help\ with\ a\ solution/workaround\ asap?\ I\ assume,\ send\ was\ not\ able\ to\ flush\ out\ the\ remaining\ characters\ for\ some\ reason\ to\ the\ Linux\ box.\ The\ Tcl/Expect\ script\ is\ on\ a\ Linux\ machine.\n\n\[RLE\]\ (2011-02-06)\ Are\ you\ ssh'ing\ into\ another\ Linux\ based\ system?\ \ If\ so,\ any\ reason\ you\ can\ not\ just\ use\ \"shutdown\ -h\ now\"\ to\ shutdown\ immediately\ without\ asking\ any\ confirmation?\n\n\[sg332\]\ (2011-02-07)\ Thanks\ for\ replying.\ Good\ question.\ The\ reason\ is\ I\ want\ to\ gracefully\ shutdown\ the\ box,\ which\ means\ applications\ on\ that\ remote\ machine\ should\ shutdown\ gracefully\ before\ the\ OS\ starts\ shutting\ down.\ A\ OS\ platform\ command\ that\ I\ am\ using\ allows\ me\ to\ do\ so.\ But\ for\ that,\ I\ have\ to\ ssh\ into\ the\ platform\ using\ platform\ credentials.\n\n----\n**\ Finding\ a\ way\ to\ have\ the\ 'alt'\ (and\ 'default')\ \[Ttk\]\ themes\ ttk::checkbox\ display\ their\ indeterminate\ state\ when\ the\ widget\ variable\ is\ undefined**\n\n\[peterc\]\ 2011-01-25\ I'm\ trying\ to\ find\ a\ way\ to\ have\ the\ 'alt'\ (and\ 'default')\ \[Ttk\]\ themes\ ttk::checkbox\ display\ their\ indeterminate\ state\ when\ the\ widget\ variable\ is\ undefined.\ It\ works\ on\ Windows\ but\ not\ in\ these\ themes.\ It\ seems\ that\ the\ indeterminate\ state\ image\ has\ either\ never\ been\ set\ or\ has\ been\ set\ to\ the\ same\ image\ as\ \"off\".\n\nI'm\ hoping\ the\ fix\ is\ something\ I\ can\ put\ at\ the\ start\ of\ my\ own\ scripts\ (after\ package\ require\ Ttk),\ rather\ than\ being\ an\ edit\ in\ Ttk's\ source,\ so\ I\ don't\ have\ to\ update\ Ttk's\ source\ every\ time\ I\ update\ Ttk.\ I'm\ happy\ to\ run\ up\ my\ own\ indeterminate\ state\ images,\ assuming\ that's\ part\ of\ the\ solution.\n\n----\n**Difference\ in\ the\ types\ of\ objects\ returned\ with\ 'array\ get'\ when\ moving\ from\ 8.4\ to\ 8.5**\n\[JonC\]\ Jan-21-2011\ In\ moving\ from\ 8.4\ to\ 8.5\ we\ see\ a\ difference\ in\ the\ types\ of\ objects\ returned\ with\ 'array\ get.\ The\ otype\ command\ returns\ the\ typePtr->name\ from\ the\ object\ (based\ on\ the\ Islist\ c\ code\ from\ the\ wiki).\n\n======\narray\ set\ arr\ \[list\ a\ 1\ b\ 2\ c\ \[list\ 3\]\ d\ \[list\ 4\ 5\]\]\nputs\ \"from\ array\"\nforeach\ a\ \[array\ names\ arr\]\ \{\ puts\ \"\[otype\ \$arr(\$a)\]\ \$arr(\$a)\"\ \}\nputs\ \"from\ get\"\nforeach\ a\ \[array\ get\ arr\]\ \{\ puts\ \"\[otype\ \$a\]\ \$a\"\ \}\n======\n\nIn\ 8.4.9\ the\ values\ in\ the\ array\ retrieved\ with\ 'array\ get'\ are\ still\ lists.\n\n======\n%\ load\ otype.so\n%\ \ source\ check_array.tcl\nfrom\ array\nlist\ 4\ 5\nnone\ 1\nnone\ 2\nlist\ 3\nfrom\ get\nnone\ d\nlist\ 4\ 5\nnone\ a\nnone\ 1\nnone\ b\nnone\ 2\nnone\ c\nlist\ 3\n%\ \n======\n\nIn\ 8.5.1\ they\ turn\ into\ strings\ when\ using\ 'array\ get'.\n\n======\n%\ load\ otype.so\n%\ \ source\ check_array.tcl\nfrom\ array\nlist\ 4\ 5\nnone\ 1\nnone\ 2\nlist\ 3\nfrom\ get\nnone\ d\nnone\ 4\ 5\nnone\ a\nnone\ 1\nnone\ b\nnone\ 2\nnone\ c\nnone\ 3\n======\n\nWhy\ does\ this\ happen?\ \ In\ our\ actual\ application\ we\ have\ other\ object\ types\ some\ of\ which\ may\ be\ expensive\ to\ construct.\n\n--------------\nEDIT:\ It\ didn't\ timestamp\ my\ edit,\ so\ I'll\ add\ it\ below\ manually.\n\n----\n**\ Question\ regarding\ lappend's\ adding\ the\ bounding\ braces\ to\ each\ list\ element\ **\n\n2011-12-01\ LtDrebin\ I\ have\ a\ simple\ question\ regarding\ lappend.\ In\ the\ following\ script:\n\n======\nset\ c\ varia\[34\]ble\nset\ p\ \[list\]\nset\ pins\ \"YC\ YE\"\nforeach\ pin\ \$pins\ \{\n\ \ \ lappend\ p\ \$c/\$pin\n\}\n======\nan\ echo\ \$p\ will\ display\ the\ following:\ \{varia\[\[34\]ble/YC\}\ \{varia\[\[34\]ble/YE\}.\ \ Why\ is\ lappend\ adding\ the\ bounding\ braces\ to\ each\ list\ element?\ I\ want\ the\ output\ to\ be:\ varia\[\[34\]ble/YC\ varia\[\[34\]ble/YE\n\nThe\ variable\ c\ has\ brackets\ around\ the\ 34.\ It\ is\ being\ interpreted\ as\ an\ image\ link\ here.\n\nI\ have\ also\ tried\ setting\ each\ new\ element\ to\ variable\ p\ as\ a\ separate\ variable\ and\ then\ appending\ just\ that\ variable,\ but\ I\ get\ the\ same\ result.\n\nI\ have\ a\ workaround\ to\ this\ using\ concat,\ but\ I'm\ curious\ as\ to\ why\ lappend\ is\ behaving\ this\ way.\ It\ seems\ that\ the\ brackets\ in\ the\ variable\ c\ are\ causing\ this.\ If\ c\ only\ has\ a\ slash\ in\ it,\ for\ instance,\ it\ seems\ to\ work\ correctly.\n\nMy\ workaround,\ fyi:\n\n======\nset\ c\ varia\[34\]ble\nset\ p\ \[list\]\nset\ pins\ \"YC\ YE\"\nforeach\ pin\ \$pins\ \{\n\ \ \ set\ p\ \[concat\ p\ \$c/\$pin\]\n\}\n======\n\[MG\]\ Is\ that\ exactly\ the\ script\ you're\ using?\ For\ me\ that\ results\ in\ an\ 'invalid\ command\ name\ \"34\"'\ error\ in\ the\ 'set\ c\ ..'\ statement.\ But,\ ignoring\ that\ (and\ assuming\ you're\ actually\ escaping\ them\ there,\ with\n\n\ \ set\ c\ \{varia\[34\]ble\}\n\ \ set\ c\ varia\\\[34\\\]ble\n\nor\ something\ similar),\ lappend\ isn't\ really\ adding\ curly\ braces\ -\ they're\ simply\ displayed\ in\ the\ string\ representation\ of\ the\ list.\n\n======\n\ \ %\ set\ c\ \{varia\[34\]ble\}\n\ \ varia\[34\]ble\n\ \ %\ set\ p\ \[list\]\n\ \ %\ set\ pins\ \"YC\ YE\"\n\ \ YC\ YE\n\ \ %\ foreach\ pin\ \$pins\ \{\n\ \ \ \ lappend\ p\ \$c/\$pin\n\ \ \ \ \}\n\ \ %\ set\ p\n\ \ \{varia\[34\]ble/YC\}\ \{varia\[34\]ble/YE\}\n\ \ %\ lindex\ \$p\ 0\n\ \ varia\[34\]ble/YC\n\ \ %\ join\ \$p\ \"\ \"\n\ \ varia\[34\]ble/YC\ varia\[34\]ble/YE\n======\n\nUsing\ \[join\]\ creates\ a\ \"true\"\ string\ from\ the\ list,\ which\ doesn't\ include\ the\ curly\ braces\ (which\ are\ used\ only\ to\ denote/escape\ the\ individual\ list\ elements,\ as\ they\ contain\ special\ characters).\n\n\{gwm\}\ also\ \"lindex\ \$p\ 0\"\ and\ \"lindex\ \$p\ 1\"\ return\ the\ 'true'\ elements\ of\ the\ list\ without\ the\ \{\}\;\ any\ operation\ (such\ as\ foreach\ part\ \$p\ \{...\})\ which\ uses\ the\ list\ will\ then\ use\ the\ form\ you\ expected\ for\ each\ element\ of\ the\ list.\n\n\{LtDrebin\}\ I'm\ running\ these\ scripts\ inside\ of\ a\ microchip\ development\ tool.\ It\ uses\ tcl\ for\ user-level\ scripting.\ I\ have\ tried\ both\ escaping\ the\ brackets\ and\ not,\ and\ setting\ the\ varaible\ works\ just\ fine.\ I'm\ guessing\ that\ our\ tcl\ shell\ has\ some\ sort\ of\ protection\ for\ brackets,\ as\ many\ of\ the\ instances\ in\ a\ microchip\ have\ all\ sorts\ of\ symbols\ used\ in\ their\ names.\n\nIt's\ probably\ more\ efficient\ to\ use\ lappend,\ then?\ I\ might\ have\ to\ use\ the\ entire\ list\ p\ as\ an\ argument\ in\ a\ later\ function.\ In\ that\ case,\ it\ will\ still\ keep\ the\ bounding\ braces.\ \ The\ function\ can\ handle\ that\ (I\ think),\ but\ it's\ not\ what\ I\ intended\ and\ I'm\ a\ perfectionist,\ dammit!\n\nWhen\ I\ use\ the\ command\ set\ c\ varia\[34\]ble,\ the\ console\ of\ my\ tool\ gives\ the\ message:\ \[\]'s\ in\ strings\ are\ used\ to\ invoke\ sub-functions,\ escape\ \[\]'s\ or\ use\ \{\}'s\ to\ define\ the\ string.\ \ I\ understand\ that,\ but\ running\ echo\ \$c\ shows\ that\ c\ was\ set\ correctly.\n\nIn\ my\ script,\ c\ will\ be\ set\ by\ a\ foreach\ statement,\ where\ c\ is\ an\ individual\ element\ of\ a\ list\ of\ all\ sorts\ of\ c's.\ The\ only\ way\ I\ can\ see\ to\ \"properly\"\ set\ c\ using\ \{\}'s\ would\ be\ to\ scrap\ the\ foreach\ and\ just\ iterate\ through\ the\ list\ of\ c's.\n\n\{LtDrebin\}\ I'm\ running\ into\ more\ problems\ with\ lappend\ adding\ extra\ braces\ to\ list\ elements.\ My\ script\ has\ a\ lot\ of\ nested\ loops\ and\ so\ I'm\ a\ bit\ concerned\ about\ runtime.\ I\ read\ that\ using\ lappend\ is\ more\ efficient\ than\ using\ concat\ to\ append\ elements\ to\ a\ list.\ If\ I\ use\ concat\ via\ the\ workaround\ above,\ the\ list\ does\ not\ contain\ extra\ braces\ (well,\ so\ far...).\ \ So,\ I\ have\ a\ few\ options\ on\ how\ to\ remove\ these\ braces\ for\ future\ operations.\n\n1)\ Use\ the\ \\\[concat\\\]\ workaround.\n2)\ After\ lappending\ everthing,\ use\ \\\[join\ \$list\\\]\ to\ convert\ it\ to\ a\ string\ with\ spaces\ in\ between.\ This\ seems\ to\ remove\ the\ extra\ braces\ and\ retains\ the\ list\ elements.\n3)\ Whenever\ I\ need\ to\ call\ an\ element\ of\ the\ list,\ use\ \\\[lindex\\\]\ or\ \\\[lrange\\\]\ (haven't\ tested\ lrange\ yet).\n\nAs\ for\ the\ reason\ why\ lappend\ is\ adding\ the\ extra\ braces,\ I\ think\ it's\ because\ the\ tcl\ parser\ is\ using\ braces\ in\ strings\ with\ brackets\ to\ keep\ the\ parser\ from\ substituting\ results\ of\ the\ bracket\ phrase,\ which\ might\ be\ seen\ as\ a\ command.\n\n\[gwm\]\ You\ might\ also\ like\ to\ experiment\ with\ append\ -\ this\ is\ like\ lappend,\ it\ adds\ at\ the\ end\ of\ the\ string,\ but\ is\ pure\ string.\ To\ retain\ the\ 'list-like'\ behaviour\ you\ need\ to\ put\ 'append\ p\ \"\ new\\\[34\\\]bit\",\ like\ this:\n\n======\nforeach\ pin\ \$pins\ \{\n\ \ \ \ append\ p\ \"\ \$c/\$pin\"\n\}\nputs\ \$p\n======\n\n--------------\n**\ Major\ memory\ leak\ bug\ in\ TclOO\ **\n\n2011-02-01\ \[gwm\]\ memory\ leak\ bug\ in\ TclOO\ (cured\ by\ 12\ Feb\ 2011).\ I\ have\ created\ the\ following\ minimal\ demo\ of\ TclOO\ which\ creates\ one\ object,\ then\ uses\ its\ only\ method\ 6\ million\ times.\n\n========\n\n\ console\ show\ \;\ update\n\ #\ make\ it\ an\ O-O\ program\ using\ oo::\n\ package\ require\ TclOO\ \n\n\ oo::class\ create\ cell\ \{\n\ \ \ \ #\ a\ general\ cell.\n\ \ \ \ method\ setcp1\ \{vv\}\ \{my\ variable\ cp1\;set\ cp1\ \$vv\}\n\ \}\n\n\ set\ a\ \[cell\ new\]\ \;#\ create\ just\ one\ object!\n\n\ set\ i\ 0\;while\ \{\$i<6000000\}\ \{\n\ \ \ \ incr\ i\;\n\ \ \ \ if\ \{!(\$i%25000)\}\ \{puts\ \"Looped\ \$i\ times\"\;update\}\n\ \ \ \ \$a\ setcp1\ 123\n\ \}\n\n\ #\ NB\ \$a\ destroy\ did\ not\ free\ the\ memory\n\n========\n\nAfter\ 6\ million\ operations\ using\ Activestate's\ 8.6.0.0.b4\ I\ had\ gobbled\ about\ 400MB\ (by\ just\ ONE\ TclOO\ object).\ Memory\ was\ still\ gobbled\ if\ you\ remove\ the\ \"my\"\ variable\n\n\ \ \ \ method\ setcp1\ \{vv\}\ \{\ variable\ cp1\;set\ cp1\ \$vv\}\n\nBut\ it\ was\ not\ gobbled\ if\ no\ variable\ was\ declared.\n\n\ \ \ \ method\ setcp1\ \{vv\}\ \{\ set\ cp1\ \$vv\}\n\n\[MS\]\ just\ ran\ this\ on\ HEAD/linux\ and\ does\ not\ see\ anything\ untoward\n\n\[GWM\]\ DKF\ reported\ to\ me\ privately\ this\ bug\ is\ cured\;\ the\ 8.6.0.0.b4\ (beta\ release)\ for\ Windows\ from\ Activestate\ gave\ this\ effect.\ I\ can\ report\ 'fully\ cured\ and\ distributed'\ on\ this\ question\ with\ 8.6.0.0.b5.\ The\ resulting\ code\ runs\ faster\ too,\ not\ surprising\ as\ wish\ doesn't\ have\ to\ keep\ on\ finding\ blocks\ of\ memory.\n\ \ \n--------------\n**\ How\ to\ call\ one's\ own\ methods\ in\ TclOO\ **\n\n2010-12-02\ \[jbr\]\ How\ to\ call\ ones\ own\ methods\ in\ TclOO?\n\nI\ don't\ do\ a\ lot\ of\ OO\ programming\ but\ I've\ tried\ snit\ and\ tcl\ oo\ on\ occasion.\ \ Today\ my\ question\ is,\ What\ best\ for\ calling\ a\ TclOO\ method\ from\ another\ method\ of\ the\ same\ object?\n\n\n\ \ \ 1.\ my\ some_method\ arg1\ arg2\ ...\n\ \ \ 2.\ \[\[self\]\]\ some_method\ arg1\ arg2\ ...\n\ \ \ 3.\ some_method\ arg1\ arg2\n\nOption\ #3\ doesn't\ appear\ to\ work,\ I\ guess\ namespace\ command\ path\ nesting\ isn't\ working\ as\ I\ thought\ it\ might?\n\n??\n\nThanks\n\n\[gwm\]\ Correct,\ option\ 3\ deliberately\ does\ not\ work.\ 1\ &\ 2\ are\ equivalent\ although\ I\ would\ suggest\ using\ 1\ so\ that\ any\ modification\ in\ a\ future\ release\ of\ TclOO\ affecting\ the\ 'my'\ operation\ would\ be\ implemented\ into\ your\ code.\n\nMethod\ 3\ is\ more\ like\ how\ C++\ would\ be\ coded\;\ use\ of\ 'my'\ ensures\ that\ any\ overridden\ method\ of\ the\ base\ class\ is\ called\ by\ methods\ in\ the\ base\ class\ which\ call\ the\ (overridden)\ method.\n\ \n--------------\n**\ How\ to\ http\ \"GET\"\ without\ using\ http\ package\ ?\ **\n\n<Start\ of\ New\ Question>\n\[Kirov\]\ How\ to\ http\ \"GET\"\ without\ using\ http\ package\ ?\n\nfconfigure\ manual\ page\ says\ :\ \"Upon\ output\ (i.e.,\ with\ puts),\ the\ I/O\ system\ translates\ newlines\ to\ the\ external\ end-of-line\ representation.\"\n\nThis\ doesn't\ work\ :\ \n\n======\nproc\ down\ \{args\}\ \{\n\ \ \ \ \ \ \ \ #\ splitting\ first\ arg\ into\ usefull\ components\n\ \ \ \ \ \ \ \ set\ srv\ \[lindex\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 2\]\n\ \ \ \ \ \ \ \ set\ tar\ \[join\ \[lrange\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 3\ end\]\ /\]\n\ \ \ \ \ \ \ \ #\ connecting\ socket\n\ \ \ \ \ \ \ \ set\ s\ \[socket\ \$srv\ 80\]\n\ \ \ \ \ \ \ \ #\ requesting\ target\ url\ via\ http\ protocol\n\ \ \ \ \ \ \ \ puts\ \$s\ \"GET\ /\$tar\ HTTP/1.0\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ puts\ \$s\ \"Host:\ \$srv\\n\\n\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ #\ check\ if\ active\ socket\n\ \ \ \ \ \ \ \ while\ \{\[gets\ \$s\ in\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ data\ handling\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \$in\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ close\ \$s\n\}\ndown\ http://www.tcl.tk/man/tcl8.5/TclCmd/fconfigure.htm\n======\n\nBut\ this\ works\ just\ fine\ :\n\n======\nproc\ down\ \{args\}\ \{\n\ \ \ \ \ \ \ \ #\ splitting\ first\ arg\ into\ usefull\ components\n\ \ \ \ \ \ \ \ set\ srv\ \[lindex\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 2\]\n\ \ \ \ \ \ \ \ set\ tar\ \[join\ \[lrange\ \[split\ \[lindex\ \$args\ 0\]\ /\]\ 3\ end\]\ /\]\n\ \ \ \ \ \ \ \ #\ connecting\ socket\n\ \ \ \ \ \ \ \ set\ s\ \[socket\ \$srv\ 80\]\n\ \ \ \ \ \ \ \ #\ requesting\ target\ url\ via\ http\ protocol\n\ \ \ \ \ \ \ \ puts\ \$s\ \"GET\ /\$tar\ HTTP/1.0\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ puts\ \$s\ \"Host:\ \$srv\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ puts\ \$s\ \"\"\;\ flush\ \$s\n\ \ \ \ \ \ \ \ #\ check\ if\ active\ socket\n\ \ \ \ \ \ \ \ while\ \{\[gets\ \$s\ in\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ data\ handling\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ puts\ \$in\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ close\ \$s\n\}\ndown\ http://www.tcl.tk/man/tcl8.5/TclCmd/fconfigure.htm\n======\n\nMy\ question\ is\ :\ Why\ ?\n<End\ of\ Question>\n\n<Answer>\n\n2011-11-20\ \[AMW\]\nThe\ two\ versions\ do\ NOT\ send\ identical\ requests!\n\nVersion\ 1\ sends\ '''two\ '''empty\ lines\ (three\ newlines)\ after\ the\ last\ HTTP\ header\ line\ (\"Host:\"...):\ two\ newlines\ generated\ by\ \"\\n\\n\",\ a\ third\ being\ added\ by\ the\ '''puts'''\ command\ when\ called\ without\ ''-nonewline''.\n\nVersion\ 2\ correctly\ sends\ just\ '''one'''\ empty\ line.\n\nVersion\ 1\ could\ be\ fixed\ in\ either\ of\ the\ following\ ways:\n======\nputs\ -nonewline\ \$s\ \"Host:\ \$srv\\n\\n\"\nputs\ \$s\ \"Host:\ \$srv\\n\"\n======\n\nBy\ the\ way:\ a\ single\ call\ to\ '''flush\ \$s'''\ after\ sending\ the\ last\ byte\ would\ suffice,\ and\ will\ enhancen\ performance\ on\ connections\ with\ poor\ bandwith.\n\n----\n**\ Too\ many\ initializer's\ errors\ in\ MS\ VS\ 2005\;\ while\ writing\ a\ Tcl\ extension\ for\ C++)**\n\n<Start\ of\ New\ Question>\n\[To\ Many\ Initiallizers\ error\ in\ MS\ VS\ 2005\]\nHello\ everyone,\ \nI\ am\ trying\ to\ write\ a\ Tcl\ extension\ for\ C++.\ Below\ is\ my\ code.\n\nint\ DLLEXPORT\ \nLitePoint_Init(Tcl_Interp\ *interp)\n\{\n\ \ \ if\ (Tcl_InitStubs(interp,TCL_VERSION,0)==NULL)\ \{\ \ \n\ \ \ \ \ \ \ \ \ \ return\ TCL_ERROR\;\n\ \ \ \ \ \ \ \ \}\n\ \ \ if\ (Tcl_PkgProvide(interp,\ \"Hello\",\ \"1.0\")\ ==\ TCL_ERROR)\ \{\n\ \ \ \ \ \ \ \ \ return\ TCL_ERROR\;\n\ \ \ \ \ \}\n\n\ \ \ Tcl_Command\ Tcl_CreateObjCommand(interp,\ \"connect\",\ ConnectSystem\ ,\ NULL,\ NULL)\;\n\ \ \ return\ TCL_OK\;\n\}\n\ \ \nBelow\ is\ the\ ConnectSystem\ proc.\n\nstatic\ int\ ConnectSystem(ClientData\ clientData,\ Tcl_Interp\ *interp,\ int\ objc,\ Tcl_Obj\ *\ const\ objv\[\])\n\{\n\ \ \ \ \ \ \ \ int\ LP_InitTester(char\ *ipAddress)\;\n\ \ \ \ \ \ \ \ return\ TCL_OK\;\n\}\n\nConnectSystem\ is\ calling\ another\ function\ LP_InitTester().\ I\ am\ using\ MS\ VC++\ 2005.\ When\ i\ try\ to\ build\ it,\ it's\ giving\ me\ \"\ Too\ many\ initiallizers\ \"\ pointing\ at\ Tcl_Command\ Tcl_CreateObjCommand().\ How\ do\ i\ resolve\ this.\n\nThanks\n<End\ of\ Question>\n<Answer>\nTcl_CreateObjCommand(interp,\ \"connect\",\ ConnectSystem\ ,\ NULL,\ NULL)\;\n\ndoes\ not\ require\ the\ type\ of\ its\ return\ argument\ (Tcl_Command)\ to\ be\ declared\ too.\ Compiler\ gets\ that\ from\ the\ tcl.h\ file.\ just\ omit\ Tcl_Command\ from\ your\ code.\n\n---------------\n**\ Increasing\ the\ number\ of\ elements\ in\ a\ graph\ option\ **\n\n\[KESHAV\]\ -\ 2010-08-19\ 00:37:40:\ HI,\ I\ am\ using\ a\ graph\ command\ from\ \[BLT\]/TK.\nThe\ -xdata\ and\ -ydata\ options\ takes\ only\ 349524\ elements.\ \ Is\ there\ any\ way\ to\nincrease\ it?\ \ Or\ any\ settings\ to\ overcome\ this\ limitation?\ \ Please\ help\n\n\ \[gold\]\ 2010-10-11,\ found\ ref.\ \n\ \ http://www.usenix.org/events/tcl98/tcl98/full_papers/howlett/howlett_html/howlett.html\n\n----\n**\ Problem\ with\ the\ thrashcan\ object\ for\ canvas\ on\ Canvas\ Object\ Movement\ **\ \n\ \ \n\[gold\]\ 2Aug2010:\ I\ loaded\ a\ thrashcan\ object\ for\ canvas\ on\ Canvas\ Object\ Movement\ Example,\ [\;Canvas\ Object\ Movement\ Example\].\ \ This\ trashcan\ is\ sticking\ a\ little,eg\ sometimes\ the\ object\ does\ not\ disappear\ over\ the\ X\ on\ the\ first\ move\ or\ entry.\ \ Can\ somebody\ fix\ this\ item?\ Thanks.\ The\ deep\ patch\ appears\ to\ be:\n\ \ \ \ \ \ \ if\ \{\ \$y\ >=\ 20\ &&\ \$y\ <=\ 70\ \}\n\ \ \ \ \ \ \ \{\ if\ \{\ \$x\ >=\ 20\ &&\ \$x\ <=\ 70\ \}\n\ \ \ \ \ \ \ \{\$w\ delete\ obj_\$tilex\ \}\ \}\ #maybe\ should\ \[lindex\ obj_\$tilex\ 1\ \]etc\ ?\n\n----\n**\ Drawing\ a\ new\ series\ or\ new\ dataplot\ using\ Tklib\ Plotchart\ **\n\[JULY\]\ -\ 2010-07-30\n\nQuestion:\ Hi,\ I\ am\ using\ TKlib\ Plotchart.\ Once\ I\ have\ drawn\ a\ plot,\ say\ an\ xyplot,\ I\ want\ to\ clear\ it\ and\ draw\ a\ new\ series\ or\ new\ dataplot.\ I\ am\ unable\ to\ find\ any\ command\ to\ clear\ the\ plots\ and\ draw\ a\ new\ one.\ I\ tried\ using\ the\ destroy\ command,\ but\ it\ doesn't\ work.\n\nI\ don't\ want\ to\ destroy\ the\ whole\ canvas\ to\ plot\ all\ over\ again.\ Any\ suggestions/comments\ are\ appreciated!\n\n----\n\[gold\]\ Possible\ to\ 1)raise\ or\ lower\ the\ previous\ work\ on\ the\ canvas,\ 2)raise\ a\ncovering\ object\ (white\ rectangle)\ or\ 3)write\ on\ top?\ \ I\ installed\ a\ raise\ or\nlower\ button\ in\ \[Chinese\ Xianqi\ Chessboard\].\ \ grid\ is\ a\ tag\ on\ created\ objects\ in\ canvas.\n\n\ \ \ \ \ \ \ \ .cv\ itemconfigure\ grid\ -fill\ blue\ \n\ \ \ \ \ \ \ \ if\ \{\ \$state2\ ==\ 1\ \}\ \{\ .cv\ raise\ grid\ \;\}\ \n\ \ \ \ \ \ \ \ if\ \{\ \$state2\ ==\ 2\ \}\ \{\ .cv\ lower\ grid\ \;\}\ \n\nand\ \[Simple\ Canvas\ Demo\]\ Also,\ look\ at\ my\ \[gold\]\ \ \ perambulations\ with\ \$c\naddtag\ point\ withtag\ \$item\ &\ \$w\ addtag\ selected\ withtag\ current\ on\ \[Ask,\ and\ it\ shall\ be\ given\ #\ 7\].\ If\ you\ can\ add\ a\ tag\ to\ current\ and\ selected\ plot_1\ like\ \$w\ addtag\ plot_1\ withtag\ current,\ you\ can\ raise\ or\ lower\ plot_1\ with\ .c\ raise\ plot_1\ or\ .c\ lower\ plot_1.(or\ .c\ lower\ all?)\n\n----\n**\ Low\ volume\ level\ for\ a\ 24\ bit\ wave\ file\ using\ snack\ **\n\nSergey,\ 10\ july\ 2010\n\nI\ have\ a\ problem\ with\ snack,\ which\ i\ can't\ find\ solution\ for.\n\nIf\ i\ open\ a\ 24\ bit\ wave\ file\ using\ snack\ and\ try\ to\ save\ it,\ resulting\ wave\ file\ has\ extremely\ low\ volume\ level,\ but\ if\ file\ is\ 16\ or\ 32\ bit,\ everything\ goes\ fine.\ Same\ thing\ happens\ in\ wavesurfer,\ so\ it's\ likely\ to\ be\ snack\ bug.\n\nDoes\ anyone\ know\ about\ this\ bug?\ Is\ there\ any\ workaround?\nThanks\ in\ advance.\n\n----\n**\ Making\ a\ tk\ image\ from\ a\ tk\ widget\ **\n\[ARR\]\ -\ 2010-06-30\n\nQuestion\ 1:\ Hello\ specialists,\ how\ can\ I\ make\ a\ tk\ image\ from\ a\ tk\ widget?\n\nAnswer\ 1:\ use\ the\ image\ command:\ '''image\ create\ photo\ widget_image\ -format\ window\ -data\ \$widget'''\n\nQuestion\ 2:\ This\ is\ fine,\ but\ the\ widget\ must\ be\ fully\ visible.\ So,\ how\ can\ I\ make\ an\ image\ from\ a\ withdrawn\ widget?\ Any\ ideas\ anybody?\n\nAnswer\ 2:\ ???\n\n----\n**\ Errors\ with\ tests\ for\ enable\ threads\ **\ \n\n\[rhinerfeld\]\ -\ 2009-09-02\ 18:56:28\n\nI\ have\ just\ downloaded\ the\ TK8.5.7\ build.\ \ I\ am\ using\ Linux\ Fedora\ Core\ 10\ as\ an\ OS.\ \ I\ configure\ for\ --enable-threads\ and\ then\ make\ test.\ \ I\ receive\ a\ number\ of\ errors\ from\ the\ tests\ that\ are\ run.\n\n\ Tests\ ended\ at\ Wed\ Sep\ 02\ 18:45:24\ EDT\ 2009\n\ all.tcl:\ \ \ \ \ \ \ \ Total\ \ \ \ \ \ \ \ 8788\ \ \ \ \ \ \ \ Passed\ \ \ \ \ \ \ \ 7776\ \ \ \ \ \ \ \ Skipped\ \ \ \ \ \ \ \ 945\ \ \ \ \ \ \ \ Failed\ \ \ \ \ \ \ \ 67\n\ Sourced\ 87\ Test\ Files.\n\ Files\ with\ failing\ tests:\ canvText.test\ entry.test\ filebox.test\ font.test\ scrollbar.test\ spinbox.test\ text.test\ textDisp.test\ textImage.test\ textTag.test\ textWind.test\ unixEmbed.test\ unixFont.test\ unixSelect.test\ unixWm.test\ wm.test\n\ Number\ of\ tests\ skipped\ for\ each\ constraint:\n\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ altDisplay\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ aqua\n\ \ \ \ \ \ \ \ 16\ \ \ \ \ \ \ \ colorsFree\n\ \ \ \ \ \ \ \ 3\ \ \ \ \ \ \ \ colorsLeftover\n\ \ \ \ \ \ \ \ 21\ \ \ \ \ \ \ \ defaultPseudocolor8\n\ \ \ \ \ \ \ \ 10\ \ \ \ \ \ \ \ emptyTest\n\ \ \ \ \ \ \ \ 139\ \ \ \ \ \ \ \ fonts\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ havePseudocolorVisual\n\ \ \ \ \ \ \ \ 6\ \ \ \ \ \ \ \ knownBug\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ memory\n\ \ \ \ \ \ \ \ 103\ \ \ \ \ \ \ \ nonPortable\n\ \ \ \ \ \ \ \ 33\ \ \ \ \ \ \ \ nt\n\ \ \ \ \ \ \ \ 5\ \ \ \ \ \ \ \ pseudocolor8\n\ \ \ \ \ \ \ \ 72\ \ \ \ \ \ \ \ secureserver\n\ \ \ \ \ \ \ \ 11\ \ \ \ \ \ \ \ testmetrics\n\ \ \ \ \ \ \ \ 7\ \ \ \ \ \ \ \ testwinevent\n\ \ \ \ \ \ \ \ 141\ \ \ \ \ \ \ \ textfonts\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ unthreaded\n\ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ userInteraction\n\ \ \ \ \ \ \ \ 310\ \ \ \ \ \ \ \ win\n\ \ \ \ \ \ \ \ 51\ \ \ \ \ \ \ \ winSend\n\nIs\ this\ normal?\n\n----\n**\ Errors\ in\ a\ Hello\ world\ code\ (attempting\ to\ make\ an\ IDE\ in\ C)\ **\n\n\[arin\]\ -\ 2010-06-09\ 02:10:43\n\nhi,\ i\ am\ working\ on\ an\ ubuntu\ system.\ My\ aim\ is\ to\ basically\ make\ an\ IDE\ in\ C\ language\ using\ GUI\ tools\ from\ TCL/TK.\ I\ installed\ tcl\ 8.4,\ tk8.4,\ tcl8.4-dev,\ tk8.4-dev\ and\ have\ the\ tk.h\ and\ tcl.h\ headers\ file\ in\ my\ system.\ But,\ when\ I\ am\ running\ a\ basic\ hello\ world\ program\ it's\ showing\ a\ hell\ lot\ of\ errors.\n\n\ #include\ \"tk.h\"\n\ #include\ \"stdio.h\"\n\ void\ hello()\ \{\n\ \ \ \ \ \ puts(\"Hello\ C++/Tk!\")\;\n\ \}\n\ int\ main(int,\ char\ *argv\[\])\n\ \{\ \ \ \ \ init(argv\[0\])\;\n\ \ \ \ \ \ button(\".b\")\ -text(\"Say\ Hello\")\ -command(hello)\;\n\ \ \ \ \ \ pack(\".b\")\ -padx(20)\ -pady(6)\;\n\ \}\n\nSome\ of\ the\ errors\ are\ \n\n\ tkDecls.h:644:\ error:\ expected\ declaration\ specifiers\ before\ ‘EXTERN’\n\ \n\ /usr/include/libio.h:488:\ error:\ expected\ ‘)’\ before\ ‘*’\ token\n\ \n\ In\ file\ included\ from\ tk.h:1559,\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ from\ new1.c:1:\n\ tkDecls.h:1196:\ error:\ storage\ class\ specified\ for\ parameter\ ‘TkStubs’\n\ tkDecls.h:1201:\ error:\ expected\ ‘=’,\ ‘,’,\ ‘\;’,\ ‘asm’\ or\ ‘__attribute__’\ before\ ‘*’\ token\n\ \n\ /usr/include/stdio.h:145:\ error:\ storage\ class\ specified\ for\ parameter\ ‘stdin’\n\ \n\ tk.h:1273:\ error:\ declaration\ for\ parameter\ ‘Tk_PhotoHandle’\ but\ no\ such\ parameter\n\nCan\ anyone\ please\ tell\ me\ how\ can\ I\ rectify\ these\ errors?\ Please\ help...\n\n\[AM\]\ A\ better\ place\ to\ ask\ such\ questions\ is\ comp.lang.tcl\n\n----\n**\ Getting\ rid\ of\ a\ console\ window\ for\ a\ game\ listed\ at\ the\ bottom\ of\ Mahjong\ Style\ Deletion\ page\ 99\n\n\[gold\]\ 5jun2010.\ I\ have\ some\ starter\ code\ for\ a\ game\ listed\ at\ the\ bottom\ of\ Mahjong\ Style\ Deletion\ page.\n\nwhen\ i\ drop\ the\ cheap_poker.tcl\ into\ etcl,\ i\ get\ a\ console\ window\ that\ i\ don't\ want.\ I\ have\ a\ statement\ for\ console\ hide\ but\ doesn't\ seem\ to\ work.\ How\ do\ i\ get\ rid\ of\ console\ window?\ thanks,\[gold\]\n\n\[AMG\]:\ \[\[\[console\]\ hide\]\]\ works\ just\ fine\ for\ me.\ \ I\ don't\ know\ what\ your\ problem\ could\ be.\ \ I'm\ not\ familiar\ with\ \[eTcl\]\;\ maybe\ it's\ been\ customized\ somehow.\n\nBy\ the\ way,\ do\ you\ realize\ your\ last\ edit\ deleted\ this\ page?\ \ Please\ be\ more\ careful\ in\ the\ future!\n\n\[gold\]\ Problem\ gone.\ \ I'll\ close\ out\ this\ question.\ Have\ rewritten\ code\ leaving\ out\ some\ upvar\ and\ canvas\ name\ substitutions.\ Problem\ gone.\n\n\n\ \ \ \ \ rewritten\ code\ left\ at\ \[Mahjong_Style_Deletion\]\n\n----\n**\ Running\ \"cd\"\ ,\ \"source\ <script>\"\ etc.\ commands\ using\ a\ GUI\ running\ all\ shell\ command\ **\n\n\[raja\]\ May\ 11\ 2010:\ Hi,\ I\ have\ created\ one\ simple\ GUI\ application\ using\ tcl\ with\ one\ \"entry\"\ widget\ and\ \"Run\"\ button.My\ intention\ is\ to\ use\ this\ GUI\ to\ run\ all\ shell\ commands\ (like\ \"cd\"\ and\ other\ commands(I\ will\ enter\ command\ using\ \"entry\"\ widget\ and\ click\ on\ \"Run\"\ button\ to\ execute).\ i\ am\ able\ to\ run\ few\ commands\ like\ \"ls\",\"date\",\ \"cat\"\ etc..\ but\ i\ couldn't\ run\ \"cd\"\ ,\ \"source\ <script>\"\ etc.\ commands.\ \ Could\ some\ one\ please\ help\ me\ in\ this?\n\nThanks\ for\ your\ time.\n\n\[LV\]\ \[cd\]\ is\ not\ a\ normal\ command.\ It\ has\ to\ take\ action\ on\ the\ current\ process,\ but\ programs\ like\ you\ describe\ typically\ invoke\ exec\ or\ an\ opened\ pipe\ to\ execute\ commands\ in\ a\ second\ process.\ This\ means\ that\ things\ work\ something\ like\ this:\n\n===\nProcess\ A:\ User\ logged\ into\ system\nProcess\ B:\ User's\ tk\ program\nProcess\ C:\ User\ types\ in\ \"cd\ /tmp\"\ and\ tk\ program\ invokes\ \"exec\ cd\ /tmp\"\n===\n\nWhen\ Process\ C\ completes,\ it\ goes\ away,\ and\ user\ is\ back\ in\ Process\ B.\n\nThe\ way\ to\ handle\ this\ is\ to\ add\ some\ code\ in\ your\ program\ that\ looks\ at\ the\ string\ before\ executing\ it.\ If\ the\ string\ begins\ with\ \"cd\ \",\ then\ don't\ use\ exec,\ but\ call\ cd\ with\ the\ rest\ of\ the\ line\ as\ an\ argument.\n\nThat\ should\ take\ care\ of\ this\ problem.\ Depending\ on\ what\ platform\ and\ shell\ you\ are\ using,\ there\ are\ probably\ some\ additional\ commands\ you\ will\ end\ up\ having\ to\ add\ special\ code\ for\ as\ well.\n\n\[RAJA\]\ May\ 12\ 2010:\ Thank\ you\ very\ much\ for\ your\ response.\ \ i\ have\ tried\ your\ suggestion\ but\ still\ i\ am\ getting\ error\ like\ \"couldn't\ execute\ \"cd\":\ permission\ denied\ \[\[for\ setenv\ commands\ i\ am\ getting\ \"\ couldn't\ execute\ \"setenv\":\ no\ such\ file\ or\ directory\ \"\ error\]\].\ \ I\ believe\ only\ shell\ built-in\ command\ i\ am\ getting\ errors.\ \ All\ other\ commands\ (ls\ ,\ date\ ,\ pwd\ etc..)\ are\ working\ fine.\n\nhere\ is\ my\ \"Run\"\ procedure.\n\n\ button\ .top.quit\ -text\ Quit\ -command\ exit\ \ \;\ \n\ set\ but\ \[button\ .top.run\ -text\ \"Run\ it\"\ -command\ Run\]\ \;\n\ pack\ .top.quit\ .top.run\ -side\ right\ \ \;\ \n\ \n\ label\ .top.l\ -text\ Command:\ -padx\ 0\ \ \;\ \n\ entry\ .top.cmd\ -width\ 20\ -relief\ sunken\ -textvariable\ command\ \ \;\n\ proc\ Run\ \{\}\ \{\n\ \ \ \ \ \ \ \ \ global\ command\ input\ log\ but\n\ \ \ \ \ \ \ \ \ if\ \[catch\ \{open\ \"|\$command\ |&\ cat\"\}\ input\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$input\\n\n\ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fileevent\ \$input\ readable\ Log\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$command\\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$but\ config\ -text\ Stop\ -command\ Stop\n\ \ \ \ \ \ \ \ \ \}\n\ \}\n\nI\ have\ added\ all\ other\ required\ things\ into\ my\ application.\ \"log\"\ in\ the\ above\ code\ is\ text\ widget\ to\ log\ the\ output.\n\nI\ have\ added\ another\ if\ statement\ in\ the\ above\ \"Run\"\ procedure\ to\ tackle\ \"cd\"\ command\ but\ didnt\ work.\ Please\ help\ me\ in\ this\ issue.\n\nMy\ hardware\ config\ is\ :\ Linux\ 2.6.9-67.ELlargesmp\ x86_64\ x86_64\ x86_64\ GNU/Linux\ (from\ \"uname\"\ command)\n\n\[AMG\]:\ cd\ isn't\ the\ only\ command\ that\ modifies\ the\ shell's\ internal\ state\;\ setenv\ is\ another.\ \ Both\ are\ shell\ built-in\ commands,\ which\ means\ they\ aren't\ actual\ executable\ files\ on\ disk.\ \ (Unless\ you're\ using\ \[execline\].)\n\nOne\ approach\ is\ to\ create\ a\ single\ instance\ of\ the\ shell\ and\ feed\ it\ a\ sequence\ of\ command\ lines,\ rather\ than\ start\ a\ new\ shell\ for\ each\ command.\ \ The\ shell\ can\ internally\ decide\ whether\ the\ command\ line\ is\ a\ program\ on\ disk\ or\ a\ built-in,\ and\ it\ can\ remember\ all\ its\ state\ changes.\ \ At\ this\ point\ you\ will\ have\ reimplemented\ \[xterm\],\ at\ a\ very\ basic\ level.\n\nAnother\ approach\ is\ to\ handle\ cd\ and\ all\ other\ built-in\ commands\ yourself\ (like\ \[LV\]\ suggests),\ and\ only\ \[\[\[exec\]\]\]\ or\ \[\[\[open\]\ |\]\]\ external\ programs.\ \ At\ this\ point\ you\ will\ have\ reimplemented\ the\ shell.\ \ If\ you\ go\ this\ route,\ you\ will\ have\ to\ decide\ what\ set\ of\ built-ins\ you\ want\ and\ what\ their\ syntax\ should\ be.\ \ If\ your\ built-in\ commands\ are\ equal\ to\ or\ a\ superset\ of\ the\ Tcl\ commands,\ you\ will\ basically\ be\ reimplementing\ \[Tkcon\],\ which\ already\ falls\ back\ on\ external\ programs\ when\ the\ Tcl\ interpreter\ can't\ internally\ handle\ a\ command.\n\n\[raja\]\ May\ 12\ 2010:\ Thank\ you\ AMG.\ so\ in\ short,\ I\ have\ 2\ options\ one\ is\ to\ implement/create\ xterm\ or\ create/handle\ built-in\ commands\ on\ my\ own\ using\ Tkcon.I\ am\ just\ beginner\ in\ Tcl.\ so\ i\ didn't\ have\ a\ idea\ of\ Tkcon.\ Can\ we\ just\ modify\ below\ code\ to\ handle\ shell\ build-in\ commands.\ BTM\ how\ can\ we\ create\ a\ new\ shell\ using\ this\ GUI/Tcl\ code\ (i.e\ using\ buttons\ and\ entry\ and\ Run\ procedure).\ \ I\ would\ appreciate\ your\ help.\ \n\n\ proc\ Run\ \{\}\ \{\n\ \ \ \ \ \ \ \ \ global\ command\ input\ log\ but\n\ \ \ \ \ \ \ \ \ if\ \[catch\ \{open\ \"|\$command\ |&\ cat\"\}\ input\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$input\\n\n\ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fileevent\ \$input\ readable\ Log\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$log\ insert\ end\ \$command\\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$but\ config\ -text\ Stop\ -command\ Stop\n\ \ \ \ \ \ \ \ \ \}\n\ \}\n\nThank\ you.\n\n\[LV\]\ Sorry,\ but\ that\ proc\ is\ not\ easily\ modified\ to\ do\ what\ you\ want.\n\n\[raja\]\ May\ 14\ 2010:\ i\ tried\ below\ code\ to\ get\ my\ application\ working.But\ it\ didnt.\ Now\ i\ have\ to\ create\ a\ single\ instance\ of\ the\ shell\ and\ feed\ it\ a\ sequence\ of\ commands\ in\ tcl.right\ now\ i\ dont\ have\ any\ clue\ how\ to\ create\ this\ but\ i\ will\ try.\ \ \n\n======\nif\ \{\ \[string\ first\ \"cd\"\ \[string\ tolower\ \$getcommand\]\]\ !=\ -1\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \[catch\ \{exec\ \"\$getcommand\ |&\ cat\"\}\ input\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ pwd\ \[pwd\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cd\ \$pwd\ \ \ \ \ \ \ \ \ #as\ a\ example\ cd\ to\ pwd\ \ \ #cd\ is\ a\ tcl\ built\ in\ command\n\ \ \ \ \ \ \ \ \ \}\n======\n\nor\n\n======\nif\ \{\ \[string\ first\ \"cd\"\ \[string\ tolower\ \$getcommand\]\]\ !=\ -1\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ pwd\ \[pwd\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cd\ \$pwd\ \ #cd\ is\ a\ tcl\ built\ in\ command\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #exec\ \"cd\ \$pwd\"\n\ \ \ \ \ \ \ \ \ \}\n======\n\[AMG\]:\ That's\ not\ how\ comments\ work.\ \ Unless\ #\ is\ the\ first\ character\ of\ a\ command,\ it\ has\ no\ special\ meaning.\ \ Either\ put\ it\ on\ a\ line\ by\ itself,\ or\ put\ a\ semicolon\ (\;)\ before\ it,\ as\ in\ \"cd\ \$pwd\ \;#\ cd\ is\ a\ tcl\ built\ in\ command\".\n\nTo\ create\ a\ single\ instance\ of\ the\ shell,\ use\ \[\[\[open\]\ |\]\],\ like\ you\ did\ in\ your\ first\ code\ sample,\ but\ the\ command\ you\ open\ is\ the\ shell.\ \ The\ shell\ will\ execute\ commands\ it\ receives\ on\ stdin,\ and\ it\ will\ direct\ the\ output\ of\ the\ commands\ to\ stdout.\ \ I\ assume\ you're\ using\ \[csh\]\ because\ you\ mentioned\ setenv.\n\nHere's\ code!\n\n======\npackage\ require\ Tk\nset\ shell\ csh\nproc\ log\ \{text\ \{tags\ \{\}\}\}\ \{\n\ \ \ \ .output\ configure\ -state\ normal\n\ \ \ \ .output\ insert\ end\ \$text\ \$tags\n\ \ \ \ .output\ configure\ -state\ disabled\n\ \ \ \ .output\ see\ end\n\}\nproc\ transmit\ \{\}\ \{\n\ \ \ \ global\ chan\n\ \ \ \ log\ \"\\\$\ \[.input\ get\]\\n\"\ input\n\ \ \ \ puts\ \$chan\ \[.input\ get\]\n\ \ \ \ .input\ delete\ 0\ end\n\}\nproc\ receive\ \{\}\ \{\n\ \ \ \ global\ chan\n\ \ \ \ log\ \[read\ \$chan\]\n\}\nentry\ .input\nscrollbar\ .scroll\ -orient\ vertical\ -command\ \{.output\ yview\}\ntext\ .output\ -state\ disabled\ -yscrollcommand\ \{.scroll\ set\}\n.output\ tag\ configure\ input\ -background\ gray\npack\ .input\ -fill\ x\ -side\ bottom\npack\ .scroll\ -fill\ y\ -side\ right\npack\ .output\ -fill\ both\ -expand\ 1\nfocus\ .input\nset\ chan\ \[open\ |\$shell\ a+\]\nfconfigure\ \$chan\ -buffering\ line\ -blocking\ 0\nfileevent\ \$chan\ readable\ receive\nbind\ .input\ <Return>\ transmit\n======\n\nIf\ I\ understand\ what\ you're\ asking\ for,\ the\ above\ code\ does\ what\ you\ want,\ and\ we\ should\ move\ this\ discussion\ to\ its\ own\ Wiki\ page.\n\nUnfortunately,\ this\ code\ only\ handles\ the\ shell's\ stdin\ and\ stdout\;\ it\ ignores\ stderr.\ \ I\ haven't\ figured\ out\ how\ to\ effectively\ and\ portably\ handle\ stderr.\ \ Right\ now\ the\ only\ thing\ I\ can\ think\ of\ is\ to\ use\ \[exec\]\ to\ run\ mknod\ \[http://linux.die.net/man/1/mknod\]\ to\ make\ a\ FIFO,\ open\ the\ FIFO\ for\ reading,\ monitor\ it\ in\ the\ same\ way\ \$chan\ is\ monitored,\ and\ redirect\ the\ shell's\ stderr\ to\ that\ FIFO\ using\ '''2>'''\ notation.\ \ I'd\ like\ to\ do\ this\ all\ in\ \[pure-Tcl\]\ with\ reflected\ channels,\ but\ this\ is\ not\ possible\ at\ the\ moment.\n\n\[raja\]\ 17-05-10\ Thank\ you\ very\ much\ AMG.It\ is\ working\ fine\ now.\ The\ only\ problem\ I\ am\ seeing\ now\ is\ when\ I\ source\ any\ file(file\ with\ multiple\ commands)\ it\ is\ not\ working\ properly\ but\ when\ I\ execute\ commands\ one\ by\ one\ then\ it\ is\ working\ fine.\ Some\ times\ it\ is\ showing\ \"ctrl-m\"\ characters\ (after\ and\ before\ filename)\ while\ i\ am\ executing\ \"ls\"\ command.\n\n\[AMG\]:\ Sounds\ like\ a\ DOS/Unix\ line\ ending\ problem.\ \ Are\ you\ using\ a\ Windows\ text\ editor\ to\ create\ files\ you're\ reading\ on\ Unix?\ \ Check\ if\ there\ are\ ctrl-m\ (carriage\ return)\ characters\ in\ the\ file\ you're\ sourcing.\ \ I\ assume\ you're\ asking\ csh\ to\ do\ the\ sourcing,\ not\ Tcl.\n\nHere's\ a\ version\ of\ the\ code\ that\ separately\ handles\ stdout\ and\ stderr.\ \ It\ turns\ out\ this\ ''is''\ possible\ in\ \[pure-Tcl\],\ if\ you\ have\ Tcl\ 8.6.\ \ For\ fun,\ I\ threw\ in\ some\ \[apply\]\ magic\ to\ demonstrate\ how\ to\ make\ \[fileevent\]\ and\ anonymous\ \[lambda\]s\ instead\ of\ named\ \[proc\]s.\ \ Also\ I\ switched\ to\ the\ \[Ttk\]\ widgets\ and\ the\ \[chan\]\ \[ensemble\]\ commands,\ and\ I\ added\ end-of-file\ detection.\n\n======\npackage\ require\ Tcl\ 8.6\npackage\ require\ Tk\nset\ shell\ \[list\ csh\]\nproc\ log\ \{text\ \{tags\ \{\}\}\}\ \{\n\ \ \ \ .output\ configure\ -state\ normal\n\ \ \ \ .output\ insert\ end\ \$text\ \$tags\n\ \ \ \ .output\ configure\ -state\ disabled\n\ \ \ \ .output\ see\ end\n\}\nttk::entry\ .input\nttk::scrollbar\ .scroll\ -orient\ vertical\ -command\ \{.output\ yview\}\ntext\ .output\ -state\ disabled\ -yscrollcommand\ \{.scroll\ set\}\n.output\ tag\ configure\ input\ -background\ gray\n.output\ tag\ configure\ error\ -background\ red\npack\ .input\ -fill\ x\ -side\ bottom\npack\ .scroll\ -fill\ y\ -side\ right\npack\ .output\ -fill\ both\ -expand\ 1\nfocus\ .input\nlassign\ \[chan\ pipe\]\ rderr\ wrerr\nset\ stdio\ \[open\ |\[concat\ \$shell\ \[list\ 2>@\ \$wrerr\]\]\ a+\]\nforeach\ \{chan\ tags\}\ \[list\ \$stdio\ \"\"\ \$rderr\ error\]\ \{\n\ \ \ \ chan\ configure\ \$chan\ -buffering\ line\ -blocking\ 0\n\ \ \ \ chan\ event\ \$chan\ readable\ \[list\ apply\ \{\{chan\ tags\}\ \{\n\ \ \ \ \ \ \ \ log\ \[chan\ read\ \$chan\]\ \$tags\n\ \ \ \ \ \ \ \ if\ \{\[chan\ eof\ \$chan\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ log\ EOF\ error\n\ \ \ \ \ \ \ \ \ \ \ \ .input\ state\ disabled\n\ \ \ \ \ \ \ \ \ \ \ \ chan\ close\ \$chan\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\}\ \$chan\ \$tags\]\n\}\nbind\ .input\ <Return>\ \[list\ apply\ \{\{chan\}\ \{\n\ \ \ \ log\ \[.input\ get\]\\n\ input\n\ \ \ \ chan\ puts\ \$chan\ \[.input\ get\]\n\ \ \ \ .input\ delete\ 0\ end\n\}\}\ \$stdio\]\n======\n\nI\ really\ think\ it's\ time\ to\ move\ this\ to\ a\ new\ page!\ :^)\n\n----\n**\ Expect\ question\ (Re:\ Automating\ the\ login\ to\ a\ remote\ machine)**\n\n\[pcam\]\ -\ 2010-04-27\ 08:30:00\n\nI\ am\ trying\ to\ automate\ as\ much\ as\ possible\ the\ login\ to\ a\ remote\ machine.\nFrom\ my\ Solaris\ box\ I\ manually\ I\ am\ doing\ the\ following:\n\n\ \ \ 1.\ In\ a\ teminal\ establish\ a\ SSH\ tunnel\ ssh\ -l\ <username>\ -L\ 5988:localhost:5901\ <ip_address>\n\n\ \ \ 2.\ In\ ANOTHER\ terminal\ launch\ vncviewer\ :5988\n\n\ \ \ 3.\ Login\ from\ the\ vnc\ GUI\ login\ prompt\ (a\ step\ not\ required\ to\ be\ scripted/automatic)\n\n\nI\ can\ do\ both\ bits\ independently,\ but\ cannot\ manage\ with\ one\ expect\ session.\ \n\nI\ thought\ about\ using\ fork\ \n\nbut\ I\ am\ unsure\ and\ suspect\ this\ is\ not\ the\ best\ way\ to\ go\ about\ that.\nAny\ ideas\ or\ pointers\ ?\n\n----\n**\ Cross-compiling\ Tcl\ on\ arm-linux\ **\n\n\[Smarak\]\ -\ 2010-04-23\ 04:44:40\n\nHi\nI\ am\ using\ ubuntu\ 8.04.\ I\ have\ a\ arm-linux\ installed\ on\ to\ this\ ubuntu.\ My\ gumstix\ supports\ arm-angstrom-linux-gnueabi-gcc.\ Now\ my\ problem\ is\ I\ want\ to\ cross\ compile\ tcl\ on\ arm-linux.\ But\ I\ am\ confused\ with\ configure,make\ and\ make\ install.\ My\ overo-oe\ is\ in\ the\ folder\ named\ gumstix\ and\ tcl84.19-src.tar\ extracted\ in\ another\ folder\ named\ DTN2.\ Now\ i\ don't\ know\ how\ to\ use\ the\ below\ commands\n\n\n======\n'''''PATH=\ \$PATH:/usr/local/arm/oe/bin'''''\n\n'''''export\ CROSS_COMPILE=arm-linux'''''\n'''''export\ CC=arm-linux-gcc'''''\n\nexport\ tcl_cv_type'''bold\ text'''_64bit=\"long\ long\"\nexport\ ac_cv_c_bigendian=no\nexport\ tcl_cv_strtod_buggy=1\nexport\ ac_cv_func_strstr=yes\nexport\ ac_cv_func_opendir=yes\nexport\ ac_cv_func_strtod=yes\nexport\ tcl_cv_strtod_buggy=1\n\n./configure\ ../..\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--prefix=/home/zhepeng/Desktop/tcl-for-arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-tcl=/home/zhepeng/Desktop/tcl-for-arm/lib/tcl8.4\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm-linux\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--build=i386-pc-linux\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ --with-endianness=little\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-cc=arm-linux-gcc\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-ar=arm-linux-ar\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-install-prefix=../'''''..\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ --with-cflags=\"-O2\"\ \n\nexport\ tcl_cv_type_64bit=\"long\ long\"\nexport\ ac_cv_c_bigendian=no\nexport\ tcl_cv_strtod_buggy=1\nexport\ ac_cv_func_strstr=yes\nexport\ ac_cv_func_opendir=yes\nexport\ ac_cv_func_strtod=yes\nexport\ tcl_cv_strtod_buggy=1\n\n./configure\ ../..\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--prefix=/home/zhepeng/Desktop/tcl-for-arm\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-tcl=/home/zhepeng/Desktop/tcl-for-arm/lib/tcl8.4\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--host=arm-linux\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ --build=i386-pc-linux\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ --with-endianness=little\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-cc=arm-linux-gcc\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-ar=arm-linux-ar\ \\'''''\n\ \ \ \ \ \ \ \ \ \ \ \ '''''--with-install-prefix=../..'''''\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ --with-cflags=\"-O2\"\ \n======\n\nPls\ help!!!\nthanks\ in\ advance\n\n\[Steve\ Bennett\]\ I'm\ not\ sure\ what\ you\ have\ planned\ for\ Tcl,\ but\ you\ might\ want\ to\ check\ out\ \[Jim\].\ It\ is\ very\ compatible\ with\ Tcl,\ smaller\ and\ easy\ to\ cross\ compile.\n\n\ \$\ \ ./configure\ --host=arm-linux\n\ \ ...\n\ checking\ extension\ aio...\ enabled\ (default)\n\ checking\ extension\ array...\ enabled\ (default)\n\ checking\ extension\ bio...\ not\ enabled\n\ checking\ extension\ clock...\ enabled\ (default)\n\ checking\ extension\ eventloop...\ enabled\ (default)\n\ checking\ extension\ exec...\ enabled\ (default)\n\ checking\ extension\ file...\ enabled\ (default)\n\ checking\ extension\ glob...\ enabled\ (default)\n\ checking\ extension\ load...\ enabled\ (default)\n\ checking\ extension\ nvp...\ not\ enabled\n\ checking\ extension\ package...\ enabled\ (default)\n\ checking\ extension\ posix...\ enabled\ (default)\n\ checking\ extension\ readdir...\ enabled\ (default)\n\ checking\ extension\ regexp...\ enabled\ (default)\n\ checking\ extension\ signal...\ enabled\ (default)\n\ checking\ extension\ stdlib...\ enabled\ (default)\n\ checking\ extension\ syslog...\ enabled\ (default)\n\ checking\ extension\ tclcompat...\ enabled\ (default)\n\ checking\ extension\ tree...\ not\ enabled\n\ Jim\ extensions:\ aio\ array\ clock\ eventloop\ exec\ file\ glob\ load\ package\ posix\ readdir\ regexp\ signal\ stdlib\ syslog\ tclcompat\n\ configure:\ creating\ ./config.status\n\ config.status:\ creating\ Makefile\n\ config.status:\ creating\ jimautoconfext.h\n\ config.status:\ creating\ jimautoconf.h\n\ \$\ make\ &&\ make\ DESTDIR=/tmp/installdir\ install\n\n----\n**RFC5322\ compliant\ mails\ with\ tcllib\ mime\ package\;\ Tcllib\ reveice\ emails**\n\n\[Linkel\ Stephan\]\ -\ 2010-04-08\ 05:38:28\n\nmoved\ the\ question/answer\ to\ page\ \[RFC5322\ compliant\ mails\ with\ tcllib\ mime\ package\].\ Please\ have\ a\ look\ there.\ Thx\n\n----\n**Tcl\ and\ memory\ mapped\ files\ question\ **\n\n\[plap\]\ 2010.03.12\n\nIs\ it\ possible\ to\ communicate\ with\ a\ Windows\ application\ via\ a\ \"memory\ mapped\ file\"\ \n(commands\ such\ as\ CreateFileMapping())\ ?\nI\ see\ that\ mmap\ is\ sort\ of\ available\ but\ it\ doesn't\ seem\ to\ be\ the\ same\ thing.\nAny\ ideas?\n\n----\n**\ Coroutine\ names\ in\ the\ \[info\]\ procs\ list?\n\n\[jbr\],\ May\ 5\ 2010:\ Coroutine\ names\ don't\ appear\ in\ the\ \[info\]\ procs\ list?\n\n\[AMG\]:\ See\ \[coroutine\]\ for\ the\ answer.\n\n----\n**Dont\ brace\ your\ expressions**\n\n\[GeoffM\]:\ Problem\ with\ braced\ expressions.\ \[Brace\ your\ expressions\]\ recommends\ always\ bracing\ your\ expressions.\ \ Here\ is\ a\ counter\ example\ where\ I\ wish\ to\ evaluate\ an\ expression\ created\ as\ a\ string.\n\n\ \ proc\ sqr\ \{a\}\ \{return\ \[expr\ \{sqrt(\$a)\}\]\}\n\ \ proc\ tn\ \{a\}\ \{\ return\ \"2*tan(\[sqr\ \$a\])\"\}\n\nThen\ the\ command\ \"sqr\ 8\"\ and\ \"expr\ \{\[\[sqr\ 8\]\]\}\"\ returns:\ 2.8284271247461903.\nAnd\ 'tn\ 2'\ returns\ \"2*tan(1.4142135623730951)\"\n\nHowever:\n\n\ \ expr\ \[tn\ 2\]\ returns:\ 12.668238334084391\n\ \ expr\ \{\[tn\ 2\]\}\ returns:\ 2*tan(1.4142135623730951)\n\nDon't\ brace\ your\ expr-essions?\n\n\[Lars\ H\]:\ Why\ didn't\ you\ simply\n\ \ proc\ tn\ \{a\}\ \{\ return\ \[expr\ \{2*tan(\[sqr\ \$a\])\}\]\}\n?\ Then\ \[\[tn\ 2\]\]\ will\ return\ the\ wanted\ result,\ with\ no\ need\ for\ a\ surrounding\ \[expr\].\n\nBut\ in\ general:\ Yes,\ if\ you're\ constructing\ \[expr\]essions\ dynamically,\ then\ you\ do\ want\ ordinary\ substitution\ to\ take\ place\ in\ the\ argument\ of\ the\ \[expr\]\ command,\ and\ therefore\ cannot\ brace\ it.\ (\[expr\]\ is\ just\ like\ \[eval\]\ in\ this\ respect.)\ \ The\ price\ for\ doing\ so\ is\ speed,\ since\ each\ dynamic\ reconstruction\ of\ such\ an\ expression\ must\ be\ parsed\ anew.\ In\ your\ \"expr\ \[\[tn\ 2\]\]\"\ example,\ this\ happens\ every\ time\ it\ is\ used,\ and\ there\ is\ furthermore\ shimmering\ going\ on\ since\ the\ 1.4142135623730951\ is\ (under\ the\ hood)\ first\ converted\ double->string,\ then\ pasted\ into\ a\ larger\ string,\ \ cut\ out\ from\ that\ string\ by\ the\ \[expr\]\ parser,\ and\ finally\ converted\ back\ string->double\ by\ \[tan\].\ Lots\ of\ unnecessary\ work,\ so\ you'd\ be\ better\ off\ bracing\ your\ expr-esssions.\n\n\[GeoffM\]:\nActually\ my\ proc\ is\ a\ little\ more\ complex\ than\ my\ example.\ Proc\ tn\ defines\ a\ formula\;\ but\ if\ some\ constants\ of\ the\ formula\ are\ not\ defined\ (there\ are\ values\ other\ than\ the\ argument\ \"a\"\ used\ in\ evaluation\ the\ result\ is\ an\ algebraic\ manipulation\ of\ the\ best\ values\ so\ far)\ then\ tn\ returns\ the\ formula\ with\ as\ many\ variables\ substituted\ as\ possible.\ Finally\ if\ the\ result\ can\ become\ a\ number\ I\ expr\ it\;\ if\ this\ fails\ then\ I\ retain\ the\ formula\ for\ printing/debugging.\ It\ should\ however\ be\ possible\ for\ each\ component\ of\ the\ formula\ tn\ to\ be\ 'expr'd\ before\ returning\ its\ value.\ However\ I\ will\ need\ to\ do\ the\ expr\ finally\ to\ evaluate\ all\ the\ terms\ in\ the\ formula.\ \n\nIs\ there\ a\ test\ for\ 'would\ this\ value\ (string)\ evaluate\ to\ a\ numerical\ value'?\ I\ have\ used\ \n\ \ if\ \{\[catch\ \{return\ \[expr\ \[tn\ 2\]\]\}\]\}\ \{return\ \[tn\ 2\]\}\nbut\ I\ think\ the\ catch\ has\ significant\ overhead.\n\n\[Lars\ H\]:\ That's\ pretty\ much\ it,\ but\ the\ \[return\]\ in\ there\ will\ make\ your\ test\ misbehave,\ since\n\ \ catch\ \{return\ something\}\nalways\ has\ the\ value\ 2\ (\[catch\]\ catches\ \[return\]\ too).\ You're\ probably\ looking\ for\n\ \ set\ formula\ \[tn\ 2\]\n\ \ if\ \{\[catch\ \{expr\ \$formula\}\ val\]\}\ then\ \{return\ \$formula\}\ else\ \{return\ \$val\}\nWhether\ this\ (relying\ on\ that\ the\ string\ representation\ of\ a\ number\ is\ also\ a\ valid\ \[expr\]ession,\ which\ takes\ on\ the\ same\ value)\ is\ Good\ Style\ is\ another\ matter.\ Programming-wise,\ you\ might\ be\ better\ off\ using\ a\ \[apply%|%lambda%|%\]\ or\ \[command\ prefix\]\ than\ a\ dynamically\ generated\ \[expr\]ession.\n\n----\n**\ Event\ loop\ in\ tclsh\ **\n\n\[ero\]\ -\ 2010.02.26:\ event\ loop\ in\ tclsh\n\nThe\ following\ test\ code\ works\ correclty\ using\ Tk\ (wish):\n\n\ proc\ pp\ \{\}\ \{\n\ \ global\ x\n\ \ puts\ \$x\n\ \ if\ \{\$x\ >\ 10000\}\ \{return\}\n\ \ incr\ x\n\ \ after\ 10\ \[list\ pp\]\n\ \}\n\ #\n\ set\ ::x\ 1\n\ pp\n\nTo\ use\ the\ same\ proc\ in\ Tcl\ (tclsh)\ I\ added\ the\ vwait\ command\ (to\ trigger\ the\ event\ loop):\n\n\ proc\ pp\ \{\}\ \{\n\ \ global\ x\n\ \ puts\ \$x\n\ \ if\ \{\$x\ >\ 10000\}\ \{return\}\n\ \ incr\ x\n\ \ after\ 10\ \[list\ pp\]\n\ \ vwait\ x\n\ \}\n\nbut\ after\ 500\ dummy\ lines\ I\ got:\n\nerror\ in\ background\ error\ handler:\ntoo\ many\ nested\ evaluations\ (infinite\ loop?)\ \ while\ executing\n\"::tcl::Bgerror\ \{too\ many\ nested\ evaluations\ (infinite\ loop?)\}\ \n\{-code\ 1\ -level\ 0\ -errorcode\ NONE\ -errorinfo\ \{too\ many\ nested\ evaluations\ (infinite\ loop...\"\n\nWhy\ this\ happens?\ How\ start\ the\ event\ loop\ correctly\ in\ tclsh?\nThanks.\n\n\[Lars\ H\]:\ Don't\ call\ \[vwait\]\ inside\ '''pp''',\ but\ instead\ once\ after,\ like\ so:\n\ proc\ pp\ \{\}\ \{\n\ \ global\ x\n\ \ puts\ \$x\n\ \ if\ \{\$x\ >\ 10000\}\ \{set\ ::done\ 1\;\ return\}\n\ \ incr\ x\n\ \ after\ 10\ \[list\ pp\]\n\ \}\n\ #\n\ set\ ::x\ 1\n\ pp\n\ vwait\ ::done\nThis\ is\ what\ most\ closely\ corresponds\ to\ the\ Wish\ case,\ since\ there\ your\ script\ is\ being\ run\ from\ within\ a\ surrounding\ event\ loop.\n\n----\n**Problem\ running\ a\ starpack'd\ app\ on\ Fedora**\ \n\n\[MG\]\ A\ friend\ trying\ to\ run\ a\ starpack'd\ app\ on\ Fedora\ has\ run\ into\ an\ issue:\ using\ the\ 8.5.8\ Tclkit\ from\ the\ http://code.google.com/p/tclkit/downloads/list?can=3%|%Google\ Code\ site%|%,\ he\ gets\ an\ error\ \"error\ while\ loading\ shared\ libraries:\ libstdc++.so.5:\ cannot\ open\ shared\ object\ file:\ No\ such\ file\ or\ directory.\".\ According\ to\ Fedora's\ Add/Remove\ Software\ dialog,\ libstdc++\ is\ installed/available.\ The\ 8.5.2\ Tclkit\ (from\ http://www.equi4.com/tclkit/download.html%|%equi4.com%|%),\ which\ is\ the\ last\ build\ version\ I\ used\ for\ my\ app,\ works\ fine.\ Does\ anyone\ have\ any\ ideas/fixes\ that\ might\ help?\n\n----\n**How\ can\ I\ stop\ my\ TCL\ app\ from\ taking\ focus\ and\ moving\ to\ the\ top\ (over\ TPlayer)\ if\ it\ is\ clicked?**\n\n\[Beware\]:\ Here's\ a\ strange\ one,\ hopefully\ with\ an\ easy\ answer...\ \ I\ want\ to\ write\ an\ app\ that\ is\ a\ full\ black\ screen.\ \ It\ then\ loads\ another\ (already\ compiled)\ app\ (called\ TPlayer\ -\ google\ is\ your\ friend).\ \ The\ reason\ is\ I\ don't\ want\ to\ see\ my\ desktop\ while\ using\ TPlayer\ (looks\ more\ professional\ at\ a\ gig,\ as\ Tplayer\ is\ a\ DJ\ app).\ \ All\ easy\ enough\ so\ far,\ but\ how\ can\ I\ stop\ my\ TCL\ app\ from\ taking\ focus\ and\ moving\ to\ the\ top\ (over\ TPlayer)\ if\ it\ is\ clicked?\ (Tplayer\ has\ very\ few\ options).\ \ Secondly,\ how\ can\ I\ link\ the\ two\ apps\ so\ if\ the\ user\ closes\ TPlayer,\ the\ TCL\ closes,\ and\ vice-versa?\n\nAny\ hints/tips\ much\ appreciated.\n\nPS.\ Windows\ XP.\ I'd\ rather\ not\ use\ extensions\ if\ possible,\ as\ I\ like\ a\ nice\ easy\ freewrap\ compile\ :)\n\n\[Beware\](the\ next\ day):\ Using\ a\ program\ called\ PowerMenu,\ I\ can\ make\ TPlayer\ always\ on\ top.\ \ This\ works\ well,\ but\ is\ there\ a\ TCL\ solution?\n\n\[MG\]\ I'm\ not\ aware\ of\ any\ Pure-Tcl\ one.\ While\ you\ can\ easily\ position\ .\ to\ fill\ the\ screen\ and\ then\ use\ 'exec\ \$app\ \;\ exit'\ to\ launch\ the\ app\ (the\ \[exec\]\ call\ won't\ return\ until\ your\ app\ closes,\ then\ running\ the\ \[exit\]),\ the\ .\ window\ will\ still\ take\ focus\ on\ click,\ and\ appear\ to\ Windows\ to\ have\ hung.\ There\ might\ be\ an\ extension\ that\ would\ let\ you\ easily\ embed\ another\ app\ into\ a\ Tk\ window,\ though?\n\n\[Duoas\]\ There\ isn't\ any\ simple\ way\ to\ do\ this\ without\ extensions.\ You\ can\ get\ kind\ of\ close,\ though,\ with\ standard\ Tcl/Tk\ by\ configuring\ your\ main\ window\ as\ \"disabled\"\ and\ using\ the\ XP\ Pro\ utility\ \"tasklist\"\ to\ watch\ for\ when\ TPlayer\ closes.\ If\ you\ don't\ have\ XP\ Pro,\ you'll\ have\ to\ get\ a\ copy\ of\ tasklist.exe\ from\ online.\n\nKeep\ in\ mind\ that\ this\ is\ a\ ''very''\ simple\ solution\ --\ but\ it\ satisfies\ your\ requirements.\ You\ can\ still\ switch\ things\ around\ with\ Alt-Tab\ and\ other\ stuff,\ so\ if\ anything\ goes\ wrong\ just\ Alt-Tab\ back\ to\ your\ application.\n\nAlso\ remember\ that\ tasklist\ is\ another\ application\ that\ gets\ loaded\ and\ unloaded\ each\ time\ it\ is\ used.\ That\ is\ a\ lot\ of\ overhead\ just\ to\ watch\ a\ child.\ You\ would\ be\ better\ off\ using\ an\ extension\ like\ \[Ffidl\]\ to\ track\ the\ child's\ status.\n\nHere's\ what\ I\ wrote:\n\ #\ dj.tcl\n\ #\ 2009\ Michael\ Thomas\ Greer\n\ #\ Released\ to\ the\ Public\ Domain\n\n\ #-----------------------------------------------------------------------------\n\ #\ Modify\ these\ to\ the\ appropriate\ values.\n\ #\ \n\ #\ COMMAND\ is\ the\ full\ path\ and\ any\ command\ arguments\ to\ the\ program\ to\ run.\n\ #\ IMAGE\ \ \ is\ the\ x,y\ position\ and\ name\ of\ the\ image\ to\ display\ in\ the\n\ #\ \ \ \ \ \ \ \ \ background.\ You\ can\ give\ an\ empty\ list\ if\ you\ desire\ no\ image\ to\n\ #\ \ \ \ \ \ \ \ \ display.\n\ #\ \ \ \ \ \ \ \ \ The\ x\ value\ may\ be\ a\ pixel\ coordinate\ (as\ in\ \"100\"),\ a\ percentage\n\ #\ \ \ \ \ \ \ \ \ (as\ in\ \"20%\"),\ the\ value\ \"left\",\ or\ the\ value\ \"right\".\n\ #\ \ \ \ \ \ \ \ \ The\ y\ value\ may\ also\ be\ a\ pixel\ coordinate,\ a\ percentage,\ or\ the\n\ #\ \ \ \ \ \ \ \ \ values\ \"top\"\ or\ \"bottom\".\n\ #\ \ \ \ \ \ \ \ \ Remember,\ the\ image\ file\ must\ be\ a\ BMP\ or\ a\ GIF.\n\ #\ TIMEOUT\ The\ number\ of\ milliseconds\ to\ wait\ before\ checking\ to\ see\ if\ the\n\ #\ \ \ \ \ \ \ \ \ COMMAND\ has\ terminated\ yet\ or\ not.\n\ #\n\ set\ COMMAND\ \{Notepad.exe\ dj.tcl\}\n\ set\ IMAGE\ \ \ \[list\ right\ 50%\ C:/WINDOWS/system32/ntimage.gif\]\n\ set\ TIMEOUT\ 500\n\n\ #-----------------------------------------------------------------------------\n\ #\ The\ following\ is\ the\ main\ program\n\ #\n\ package\ require\ Tcl\ 8.5\n\ package\ require\ Tk\ \ 8.5\n\n\ proc\ position\ \{value\ dimension\ image\}\ \{\n\ \ \ \ set\ d\ \[expr\ \{\[winfo\ screen\$dimension\ .\]\ -\ \[image\ \$dimension\ \$image\]\}\]\n\ \ \ \ switch\ -glob\ -nocase\ --\ \$value\ \{\n\ \ \ \ \ \ *%\ \ \ \ \ \ \{\ return\ \[expr\ \{\$d\ *\ \[string\ range\ \$value\ 0\ end-1\]\ /\ 100\}\]\ \}\n\ \ \ \ \ \ c*\ \ \ \ \ \ \{\ return\ \[expr\ \{\$d\ /\ 2\}\]\ \}\n\ \ \ \ \ \ l*\ -\ t*\ \{\ return\ 0\ \}\n\ \ \ \ \ \ r*\ -\ b*\ \{\ return\ \$d\ \}\n\ \ \ \ \ \ default\ \{\ return\ \$value\ \}\n\ \ \ \ \}\n\ \}\n\n\ proc\ initialize_gui\ \{\}\ \{\n\n\ \ \ \ .\ configure\ -background\ black\ -bd\ 0\ -highlightthickness\ 0\n\n\ \ \ \ wm\ attributes\ .\ -fullscreen\ true\n\ \ \ \ wm\ title\ \ \ \ \ \ .\ \{DJ\ Background\}\n\n\ \ \ \ lassign\ \$::IMAGE\ x\ y\ imagefile\n\ \ \ \ if\ \{\$imagefile\ ne\ \{\}\}\ \{\n\ \ \ \ \ \ \ \ set\ image\ \[image\ create\ photo\ -file\ \$imagefile\]\n\ \ \ \ \ \ \ \ set\ x\ \[position\ \$x\ width\ \ \$image\]\n\ \ \ \ \ \ \ \ set\ y\ \[position\ \$y\ height\ \$image\]\n\n\ \ \ \ \ \ \ \ label\ .image\ -image\ \[image\ create\ photo\ -file\ \$imagefile\]\ -bd\ 0\ -highlightthickness\ 0\n\ \ \ \ \ \ \ \ place\ .image\ -x\ \$x\ -y\ \$y\n\ \ \ \ \}\n\n\ \ \ \ update\n\n\ \ \ \ wm\ attributes\ .\ -disabled\ true\n\ \}\n\n\ proc\ check\ pid\ \{\n\ \ \ \ set\ tasklist\ \[open\ \"|\ tasklist\ /fi\ \\\"pid\ eq\ \$pid\\\"\"\]\n\ \ \ \ set\ data\ \[read\ \$tasklist\]\n\ \ \ \ if\ \{\[catch\ \{close\ \$tasklist\}\ err\]\}\ \\\n\ \ \ \ \ \ then\ \{\ exit\ \}\ \\\n\ \ \ \ \ \ else\ \{\ after\ \$::TIMEOUT\ check\ \$pid\ \}\n\ \}\n\n\ proc\ main\ \{\}\ \{\n\n\ \ \ \ initialize_gui\n\n\ \ \ \ if\ \{\[catch\ \{open\ \"|\ \$::COMMAND\"\}\ pipe\]\}\ \{\n\ \ \ \ \ \ \ \ tk_messageBox\ -message\ \"Could\ not\ execute:\ \$::COMMAND\"\n\ \ \ \ \ \ \ \ exit\ 1\n\ \ \ \ \}\n\ \ \ \ set\ pid\ \[pid\ \$pipe\]\n\n\ \ \ \ after\ \$::TIMEOUT\ check\ \$pid\n\ \}\n\n\ main\nYou'll\ have\ to\ change\ the\ COMMAND\ of\ course.\ I\ don't\ know\ if\ your\ PC\ has\ that\ IMAGE\ on\ it\ (it\ should),\ but\ my\ ActiveState\ Tk\ 8.5\ couldn't\ load\ the\ windows\ Bliss.bmp\ as\ an\ example.\n\nHope\ this\ helps.\n\n----\n**\ Strange\ behaviour\ with\ \[text\]\ widget\ \[bind\]ings\ **\ \n\n\[MG\]\ has\ just\ discovered\ some\ behaviour\ with\ \[text\]\ widget\ \[bind\]ings\ that\ seem\ a\ little\ strange.\ If\ you\ do:\n\n\ \ pack\ \[text\ .t\]\n\ \ .t\ insert\ end\ foo\ bar\n\ \ foreach\ x\ \[list\ Enter\ Leave\ ButtonPress-1\ ButtonRelease-1\]\ \{\n\ \ \ bind\ .t\ <\$x>\ \[list\ puts\ \"Widget\ \$x\"\]\n\ \ \ .t\ tag\ bind\ bar\ <\$x>\ \[list\ puts\ \"Tag\ \$x\"\]\n\ \ \}\n\nThen\ move\ the\ mouse\ over\ the\ 'foo'\ text,\ hold\ down\ the\ left\ button,\ drag\ the\ mouse\ out\ of\ the\ text\ widget,\ and\ then\ release\ the\ mouse\ button.\ The\ \"tag\"\ binding\ doesn't\ trigger\ a\ Leave\ event\ until\ after\ the\ button\ is\ released,\ but\ the\ \"widget\"\ binding\ triggers\ both\ the\ moment\ the\ mouse\ leaves\ the\ widget\ (as\ I\ would've\ expected),\ and\ then\ again\ when\ the\ button\ is\ released.\ This\ is\ on\ Win\ XP\ with\ an\ 8.5.7\ Tclkit.\ Can\ anyone\ confirm\ and\ tell\ me\ whether\ or\ not\ this\ is\ a\ bug?\ (I\ would\ expect\ both\ the\ tag\ and\ widget\ bindings\ to\ fire\ just\ once,\ when\ the\ mouse\ moves\ outside\ the\ text/widget\ boundaries.)\ Any\ help\ is\ greatly\ appreciated.\n\n----\n**\ Accessing\ UNIX\ filters\ from\ TCL\ **\n\nI\ use\ UNIX\ filters\ every\ day,\ almost\ every\ thing\ I\ type\ at\ the\ command\ line\ is\ a\ filter.\ \ How\ can\ I\ access\ these\ filters\ from\ Tcl?\n\n\[How\ can\ I\ run\ data\ through\ an\ external\ filter?\]\n\n\[jbr\]\n\n-----\n**Basic\ code\ for\ the\ switch\ function:\ Running\ two\ procedures\ and\ a\ cancel**\n\nKeith\ Sarandon\ 2009-11-05\ I\ am\ asking\ a\ very\ simple\ question\ re:\ the\ \[switch\]\ function.\ See\ on\ top\ of\ the\ \[switch\]\ page.\ Tx.\ \n\n(\[aricb\]\ moved\ the\ question\ back\ here.)\n\nNovember\ 5th\ 2009\ by\ Keith\ Sarandon\n\nI\ need\ some\ very\ basic\ code\ for\ the\ switch\ function.\ If\ the\ user\ clicks\ on\ Item\ a\ in\ the\ window,\ proc\ open.a\ runs\ and\ conversely\ if\ he\ clicks\ on\ item\ b\ in\ the\ window\ proc\ open.b\ runs.\ There\ is\ also\ a\ third\ item:\ Cancel.\ Tx\ for\ the\ help.\n\n\[Duoas\]\ You\ don't\ need\ '''switch'''\ for\ that.\ Instead\ you\ should\ \[bind\]\ on\ the\ button\ press\ to\ do\ the\ right\ thing.\ In\ your\ case,\ your\ bindings\ may\ be\ as\ simple\ as\n\ \ \ \ bind\ .a\ <ButtonPress>\ open.a\n\ \ \ \ bind\ .b\ <ButtonPress>\ open.b\n\ \ \ \ bind\ .c\ <ButtonPress>\ cancelproc\ \ \;#\ whatever\ your\ cancel\ proc\ does\nHope\ this\ helps.\n\n-----\n**Way\ to\ trace\ changes\ to\ a\ font**\n\n\[Duoas\]\ 2009-11-03:\ Is\ there\ any\ way\ to\ '''trace'''\ changes\ to\ a\ font?\n\nI\ ask,\ because\ I\ want\ to\ avoid\ a\ full\ set\ of\ traces\ on\ the\ '''font'''\ command\ itself...\nI\ am\ currently\ playing\ with\ zooming\ fonts,\ and\ it\ would\ be\ nice\ for\ changes\ to\ the\ font\ that\ the\ user\ supplied\ to\ be\ automagically\ reflected\ in\ the\ local\ fonts\ that\ I\ scale\ and\ display.\ Would\ a\ trace\ like\ that\ prove\ burdensome\ to\ the\ application's\ running\ time?\n\n\n-----\n**\ Question\ regarding\ creating\ a\ directory\ **\nSteven,\ October\ 22nd\ 2009:\ I\ put\ a\ simple\ question\ here\ in\ regards\ to\ creating\ a\ directory.\ \[Directory,\ General\ Questions\]\;\ \ Thanks\ for\ your\ help!\n\n----\n**\ Problem\ with\ coding\ several\ different\ grid-layouts\ on\ the\ same\ window.**\ \ \n\ \n\[HJG\]\ 2009-09-27:\ I\ want\ several\ different\ grid-layouts\ on\ the\ same\ window.\ \ \nE.g.\ a\ table\ as\ in\ the\ example\ on\ the\ page\ for\ \[grid\],\ and\ below\ the\ table\ a\ set\ to\ buttons,\ using\ a\ new\ grid:\n======\n\ \ \ \ foreach\ field\ \{Name\ Address\ City\ State\ Phone\}\ \{\n\ \ \ \ \ \ \ \ set\ l\ \[label\ .lab\$field\ -text\ \$field\]\n\ \ \ \ \ \ \ \ set\ e\ \[entry\ .ent\$field\ -justify\ right\]\n\ \ \ \ \ \ \ \ grid\ \$l\ \$e\ -padx\ 4\ -pady\ 4\n\ \ \ \ \ \ \ \ grid\ \$l\ -sticky\ e\n\ \ \ \ \ \ \ \ grid\ \$e\ -sticky\ ew\n\ \ \ \ \}\n\ \ \ \ button\ .b1\ -text\ New\n\ \ \ \ button\ .b2\ -text\ Search\n\ \ \ \ button\ .b3\ -text\ Delete\n\ \ \ \ button\ .b4\ -text\ Exit\n\ \ \ \ grid\ .b1\ .b2\ .b3\ .b4\ \ \ \;#\ !!\ uses\ same\ grid-layout\ as\ table\ above\n======\nIt\ seems,\ there\ is\ no\ command\ to\ reset/finish\ one\ grid\ and\ start\ another.\nAlso,\ packing\ a\ grid\ inside\ a\ frame\ does\ not\ work\ as\ expected,\ \nand\ the\ docs\ have\ no\ info\ about\ how\ to\ use\ \[Geometry\ managers\]\ like\ grid\ and\ \[pack\]\ together.\n\n\[HE\]\ 2009-09-28:\ You\ need\ to\ put\ different\ layouts/geometry\ managers\ into\ different\ frames:\n\n======\n\ frame\ .f1\n\ foreach\ field\ \{Name\ Address\ City\ State\ Phone\}\ \{\n\ \ \ \ \ \ \ \ set\ l\ \[label\ .f1.lab\$field\ -text\ \$field\]\n\ \ \ \ \ \ \ \ set\ e\ \[entry\ .f1.ent\$field\ -justify\ right\]\n\ \ \ \ \ \ \ \ grid\ \$l\ \$e\ -padx\ 4\ -pady\ 4\n\ \ \ \ \ \ \ \ grid\ \$l\ -sticky\ e\n\ \ \ \ \ \ \ \ grid\ \$e\ -sticky\ ew\n\ \ \ \ \}\n\n\ frame\ .f2\n\ button\ .f2.b1\ -text\ New\ \ \ \ \n\ button\ .f2.b2\ -text\ Search\ \ \ \ \n\ button\ .f2.b3\ -text\ Delete\ \ \ \ \n\ button\ .f2.b4\ -text\ Exit\ \ \ \ \n\ grid\ .f2.b1\ .f2.b2\ .f2.b3\ .f2.b4\ \n\ pack\ .f1\ .f2\ -side\ top\n======\n\n----\n**\ Using\ re-entrant\ procedures\ **\n\n\[lannet\]\ 06\ Aug\ 09\ -\ \[Am\ I\ heading\ for\ trouble\ if\ I\ use\ re-entrant\ procedures?\]\n\n----\n**\ Problems\ with\ list\ handling\ in\ connection\ with\ the\ \"unknown\"\ proc\ **\n\n\[lannet\]\ 23\ Jul\ 09\ -\ \[Problems\ with\ list\ handling\ in\ connection\ with\ the\ \"unknown\"\ proc\]\n\n----\n**Separate\ spec\ and\ body\ source\ files**\ \n\n\[LGT\]\ Jul\ 13\ 2009\ -\ \[itcl\ :\ Is\ it\ recommended\ to\ have\ separate\ spec\ and\ body\ source\ files\ ?\]\n\n----\n**Silly\ link!!!**\n\n\[tehbrozor\]\ Jul\ 7\ 2009\ -\ \[My\ question\ is\ listed\ here--Please\ help!!!\]\n\n----\n**\ Working\ with\ button\ press\ with\ a\ ttk::treeview\ widget\ **\n\n\[MG\]\ Jun\ 16\ 2009\ -\ I\ have\ a\ ttk::treeview\ widget\ set\ up\ along\ these\ lines:\n\n\ \ set\ image\ \[image\ create\ photo\ -file\ \$path\]\n\ \ pack\ \[ttk::treeview\ .t\]\n\ \ set\ id\ \[.t\ insert\ \{\}\ end\ -text\ Foo\ -image\ \$image\]\n\ \ .t\ insert\ \$id\ end\ -text\ Bar\ -image\ \$image\n\ \ .t\ insert\ \$id\ end\ -text\ Baz\ -image\ \$image\n\nI'd\ like\ to\ do\ something\ particular\ when\ a\ ButtonPress\ occurs\ over\ the\ image\;\ anyone\ know\ if\ this\ is\ possible?\ I\ had\ a\ look\ at\ the\ bindings\ in\ treeview.tcl\ and\ found\ an\ undocumented\n\ \ \$treeview\ identify\ \$x\ \$y\ncommand,\ but\ (at\ least\ in\ the\ usage\ in\ treeview.tcl,\ and\ from\ my\ quick\ test\ of\ it)\ it\ doesn't\ seem\ to\ return\ anything\ special\ for\ the\ image.\ Is\ there\ another\ way?\n\nWhat\ I'm\ trying\ to\ create\ is\ something\ akin\ to\ the\ MS\ installers\ which\ show\ a\ tree\ of\ program\ components\ grouped\ together,\ with\ a\ checkbutton\ for\ each\ group/component.\ I\ was\ planning\ to\ use\ different\ images\ (empty\ box,\ box\ with\ tick,\ greyed\ out\ box\ with\ tick)\ to\ simulate\ a\ tri-state\ checkbutton,\ and\ alter\ the\ image/state\ when\ the\ image\ is\ clicked.\ Would\ be\ interested\ to\ hear\ any\ suggestions\ for\ a\ better/different\ way\ to\ go\ about\ it,\ too.\n\nThanks\ for\ your\ help.\n\n----\n**Problem\ using\ bindvariables\ with\ oratcl\ 4.4**\n\n\[HE\]\ June\ 7\ 2009\ -\ I\ have\ a\ problem\ to\ use\ \[bindvariables\ with\ oratcl\ 4.4\].\ Something\ like\ a\ memoryleak.\n\n----\n**Transferring\ files\ of\ using\ ftp\ over\ TLS**\n\[Hai\ Vu\]\ June\ 1\ 2009\ -\ How\ do\ I\ \[Transfer\ Files\ of\ Using\ ftp\ over\ TLS\]?\ I\ often\ need\ to\ do\ this,\ so\ am\ thinking\ of\ a\ way\ to\ automate\ it.\n\n----\n**\ Problems\ using\ Tile/Ttk\ **\ \n\n\[MG\]\ May\ 12\ 2009\ -\ I'm\ having\ some\ (more)\ issues\ with\ Tile,\ explained\ at\ \[Problems\ using\ Tile/Ttk\],\ and\ would\ greatly\ appreciate\ any\ help.\n\n----\n**\ General\ question\ regarding\ Undo\ **\n\[ARA\]\ (May\ 2\ 2009)\ My\ question\ has\ been\ placed\ in\ a\ new\ page\ called:\ \[Undo,\ a\ few\ pointers\ at\ how\ to\ code\ the\ Undo\ function\ for\ a\ text\ editor\].\ Please\ have\ a\ look\ there.\ Tx.\ \n\n----\n**\ Coding\ recognizable\ radio/checkbuttons\ in\ Tk8.5\ menus\ **\ \n\n\[Schnexel\]\ (May\ 5\ 2009)\ Is\ it\ possible\ to\ have\ radio/checkbuttons\ in\ Tk8.5\ menus\ that\ are\ recognizable\ as\ such\ even\ if\ not\ checked?\ I\ don't\ want\ to\ change\ much\ of\ my\ old\ 8.4\ code.\ See\ new\ page:\ \[Tk8.5\ menu\ radio/checkbutton\ without\ information\ loss?\].\ Tx.\ \n\n-----\n**\ Uploadable\ images\ to\ a\ Teclers'\ wiki\ page\ instead\ of\ a\ link\ out\ to\ a\ remote\ site**\n\n\[why\ can't\ wiki\ have\ uploadable\ images\ ?\]\ I\ just\ want\ to\ have\ a\ picture\ included\ with\ a\ wiki\ page.\ I\ don't\ wan't\ it\ to\ link\ out\ to\ a\ remote\ web\ site.\ Is\ this\ possible\ yet\ ?\ thanks.\ Art\n\n-----\n**Implementation\ of\ a\ command\ with\ an\ ensemble**\n\nI'm\ finding\ many\ cases\ where\ the\ \"obvious\"\ implementation\ of\ a\ command\ is\ with\ an\ ensemble,\ but\ the\ command\ is\ actually\ a\ method\ on\ an\ object.\ I\ can\ hack\ up\ an\ implementation,\ but\ it's\ very\ ugly.\ Any\ suggestions\ as\ to\ a\ better\ way\ to\ do\ it?\ Does\ anybody\ else\ want\ to\ do\ this\ too?\ Thanks,\ Paul\ \[Object\ method\ ensemble\]\n\n----\n**Talking\ to\ a\ device\ using\ RS\ 232\;\ Developing\ a\ GUI\ which\ can\ send\ and\ receive\ strings\ from\ the\ device**\n\ \ \n\[ADESH\]\ -\ 2009-09-15\ 15:03:26\n\nI\ am\ trying\ to\ talk\ to\ a\ device\ using\ RS\ 232\ and\ my\ programming\ platform\ is\ Tcl/Tk\ in\ ubuntu.\ I\ need\ to\ be\ able\ to\ develop\ a\ GUI\ which\ can\ send\ and\ receive\ strings\ from\ the\ device.\ To\ start\ with,\ I\ ran\ the\ following\ piece\ of\ codes\ to\ open\ the\ serial\ port,\ then\ send\ the\ string\ MN\ to\ the\ device.\ and\ to\ get\ the\ output\ from\ the\ device\ :\n\n======\n\ set\ serial\ \[open\ /dev/ttyUSB0\]\n\ fconfigure\ \$serial\ -mode\ \"9600,n,8,1\"\n\ fconfigure\ \$serial\ -blocking\ 0\ -buffering\ none\n\ puts\ -nonewline\ \$serial\ \"MN\\r\"\n\ puts\ \"Modem\ echo:\ \[read\ \$serial\]\"\n======\n\nI\ have\ connected\ the\ device\ to\ my\ computer\ via\ RS\ 232\ and\ a\ USB.\ When\ I\ wish\ the\ above\ command\ containing\ file\ I\ get\ the\ following\ response\;\n\n======\nError\ in\ startup\ script:\ channel\ \"file6\"\ wasn't\ opened\ for\ writing\n\ \ \ \ while\ executing\n\"puts\ -nonewline\ \$serial\ \"MN\\r\"\"\n\ \ \ \ (file\ \"tt.tcl\"\ line\ 8)\n======\n\nPlease\ help\ me\ get\ rid\ of\ the\ problem.\n\nThanks\ in\ advance\nAdesh\n\n----\n\[LV\]\ Have\ you\ read\ the\ wiki\ page\ for\ \[open\]?\ In\ your\ code\ above,\ you\ don't\ provide\ an\ indicator\ of\ whether\ you\ are\ opening\ for\ read\ or\ for\ write.\nAlso,\ be\ certain\ to\ read\ the\ information\ about\ setting\ appropriate\ fconfigure\ value\ if\ you\ need\ to\ send\ or\ receive\ binary\ data\ over\ the\ device.\n\n----\n**\ Tool\ implemented\ in\ expect\ that\ sends\ commands\ to\ remote\ node\ **\ \ \n\[srinadh\]\ -\ 2009-10-03\ 11:22:46\n\nI\ have\ a\ tool\ implemented\ in\ expect\ that\ sends\ commands\ to\ remote\ node\ (I\ spawn\ telnet\ session\ to\ the\ node)\ and\ parses\ its\ output.\ \n\nBut\ when\ I\ launch\ the\ tool\ from\ a\ small\ window,\ the\ command\ that\ is\ being\ sent\ by\ the\ tool\ is\ getting\ stripped\ at\ the\ beginning\ so\ node\ cannot\ understand\ the\ command\ and\ fails\ to\ respond,\ my\ tool\ stops.\ \n\nTo\ fix\ this\ issue,\ I\ added\ \"stty\ rows\ 50\ columns\ 120\"\ before\ it\ sends\ command\ to\ the\ node.\ \nIt\ works\ fine\ but\ when\ I\ run\ the\ tool\ in\ background,\ it\ goes\ to\ suspended\ mode:\ \"\[1\]\ \ +\ Suspended\ (tty\ output)\ \ \ \ \ \ ./console_logs\ -l\ tmp\".\ \nI\ need\ to\ type\ 'fg'\ explicitly\ for\ the\ tool\ to\ resume\ its\ operation..\ \n\nI\ cannot\ use\ stty???\ If\ not,\ please\ suggest\ me\ a\ better\ way\ to\ be\ able\ to\ run\ the\ tool\ from\ smaller\ windows..\n\n\[HJG\]\ That\ looks\ like\ a\ task\ for\ \[expect\].\n\n----\n**Problems\ with\ developing\ a\ GUI\ in\ VTCL**\n\[plasma\]\ -\ 2009-11-02\ 23:20:57\n\nI\ am\ developing\ a\ GUI\ in\ VTCL\ that\ involves\ drag\ and\ drop\ of\ widgets.\ These\ are\ the\ components\ in\ my\ GUI:\n\n\ \ \ *\ a\ tree\ with\ nodes\ and\ child\ nodes\n\ \ \ *\ an\ 'Insert'\ button\n\ \ \ *\ A\ Separator\ widget\n\nWhen\ I\ select\ a\ node\ and\ click\ on\ Insert,a\ widget\ should\ get\ inserted\ in\ the\ Separator.The\ widget\ can\ be\ either\ a\ button\ or\ a\ labelentry,having\ the\ name\ of\ the\ selected\ node\ as\ the\ text\ value.The\ purpose\ is\ that\ once\ the\ widget\ comes\ in\ the\ Separator,\ it\ should\ be\ dragable\ inside\ the\ Separator.\nOn\ the\ Wiki,I\ was\ told\ that\ the\ button\ widget\ cannot\ be\ made\ dragable,\ so\ now\ I\ insert\ a\ LabelEntry\ widget\ instead,which\ being\ a\ BWidget,has\ an\ option\ to\ be\ made\ dragable.\n\nI\ have\ done\ the\ insertion\ part\ using\ the\ following\ code:\n\n======\n#############################################################################\n##\ Procedure:\ \ insertElement\n\nproc\ ::insertElement\ \{\}\ \{\nglobal\ widget\nset\ sep\ \$::widget(Separator1)\nset\ tr\ \$::widget(Tree1)\n\nset\ sel_element\ \[\$tr\ selection\ get\]\nif\ \{\ \$sel_element\ !=\ \"\"\}\ \{\n\ set\ lb\ \[LabelEntry\ \$sep\[incr\ ::my_data::count\]\ -label\ \"\"\ -text\ \"\$sel_element\"\ \\\n\ \ \ \ \ \ \ \ -relief\ \"raised\"\ -justify\ \"center\"\ -width\ \"15\"\ -editable\ \"No\"\ \\\n\ \ \ \ \ \ \ \ -font\ \{-family\ helvetica\ -size\ 10\ -weight\ \"bold\"\}\ \\\n\ \ \ \ \ \ \ \ -dragenabled\ 1\ -dragevent\ 1\]\n\ place\ \$lb\ -in\ \$sep\ -x\ \$::my_data::x_pos\ -y\ \[incr\ ::my_data::y_pos\ 30\]\n\}\ else\ \{\n\ tk_messageBox\ -title\ \"Error\"\ -message\ \"Please\ select\ an\ element\"\ -type\ ok\n\}\nif\ \{\ \$::my_data::y_pos\ >\ 180\ \}\ \{\ \n\ incr\ ::my_data::x_pos\ 60\n\ set\ ::my_data::y_pos\ 0\n\}\nif\ \{\ \$::my_data::x_pos\ >\ 550\ \}\ \{\n\ set\ ::my_data::x_pos\ 50\n\}\n\}\n#############################################################################\n======\n\nNow\ the\ separator\ has\ to\ be\ registered\ as\ a\ drop\ site\ for\ the\ labelentrty\ widget\ using\ DropSite::regsiter.\ Please\ tell\ me\ how\ to\ write\ the\ dropendcmd\ for\ the\ separator.\nEDIT:\ JOB\ has\ posted\ a\ code\ for\ making\ a\ button\ dragable\ \[http://wiki.tcl.tk/16126\]here.\ Is\ it\ possible\ to\ change\ the\ position\ of\ a\ widget\ in\ real\ time\ by\ dragging?\n\n-----\n**Problems\ writing\ a\ small\ Tcl\ extension\ that\ makes\ driver\ specific\ ioctl()\ calls\ on\ files\ that\ are\ otherwise\ handled\ by\ the\ normal\ Tcl\ file\ commands**\n\n\[filker0\]\ -\ 2009-11-04\ 18:50:46\nI\ am\ attempting\ to\ write\ a\ small\ Tcl\ extension\ that\ makes\ driver\ specific\ ioctl()\ calls\ on\ files\ that\ are\ otherwise\ handled\ by\ the\ normal\ Tcl\ file\ commands.\ \ (This\ is\ to\ be\ used\ in\ an\ embedded\ environment.)\ \ An\ example\ of\ usage\ would\ be:\n\n======\n#############################################################################\npackage\ require\ fldr\n#\ The\ device\ node\ opens\ an\ IPC\ channel\ between\ two\ CPU\ boards\ using\ a\ special\n#\ minor\ device\ number\ (the\ main\ purpose\ of\ the\ driver\ is\ a\ different\ type\ of\n#\ domain\ specific\ IPC\ not\ being\ used\ for\ remote\ ROM\ access)\nproc\ update_remote_if_needed\ \{remote\ local\}\ \{\n\ \ if\ \{!\[file\ exists\ \$local\]\}\ \{\n\ \ \ \ puts\ stderr\ \"Local\ file\ \$local\ does\ not\ exist\"\n\ \ \ \ return\ 0\n\ \ \}\n\ \ if\ \{!\[file\ exists\ \$remote\]\}\ \{\n\ \ \ \ puts\ stderr\ \"Remote\ file\ \$remote\ does\ not\ exist\"\n\ \ \ \ return\ 0\n\ \ \}\n\ \ set\ localSize\ \[file\ size\ \$local\]\n\ \ set\ rfd\ \[open\ remote\ rw\]\n\ \ set\ limit\ \[fldr::getLimit\ \$rfd\]\ \ #\ performs\ an\ ioctl()\ and\ returns\ a\ long\ integer\ value\n\ \ if\ \{\$limit\ <\ \$localSize\}\ \{\n\ \ \ \ puts\ stderr\ \"Local\ file\ \$local\ (\$localSize\ bytes)\ exceeds\ limit\ for\ \$remote\ (\$limit\ bytes)\"\n\ \ \ \ close\ \$rfd\n\ \ \ \ return\ 0\n\ \ \}\n\n\ \ set\ lfd\ \[open\ \$local\ r\]\n\ \ fconfigure\ \$rfd\ -translation\ binary\ -encoding\ binary\n\ \ fconfigure\ \$lfd\ -translation\ binary\ -encoding\ binary\n\ \ seek\ \$rfd\ 20\n\ \ seek\ \$lfd\ 20\n\ \ set\ remote_version\ \[read\ \$rfd\ 32\]\n\ \ set\ local_version\ \[read\ \$lfd\ 32\]\n\ \ if\ (\$remote_version\ ==\ \$local_version)\ \{\n\ \ \ \ puts\ stdout\ \"Remote\ file\ is\ up\ to\ date\"\n\ \ \ \ close\ \$lfd\n\ \ \ \ close\ \$rfd\n\ \ \ \ return\ 1\n\ \ \}\n\ \ seek\ \$lfd\ 0\n\ \ seek\ \$rfd\ 0\n\ \ puts\ stdout\ \"Erasing\ at\ least\ \$localSize\ bytes\ of\ remote\ flash\"\n\ \ if\ \{\[fldr::eraseFileArea\ \$rfd\ \$localSize\]\ <\ 0\}\ \{\n\ \ \ \ puts\ stderr\ \"Error\ when\ erasing\ \$localSize\ bytes\ on\ remote\ file\ \$remote\"\n\ \ \ \ close\ \$lfd\n\ \ \ \ close\ \$rfd\n\ \ \ \ return\ 0\n\ \ \}\n\ \ puts\ stdout\ \"Copying\ \$localSize\ bytes\ of\ data\ from\ local\ file\ \$local\ to\ remote\ file\ \$remote\"\n\ \ set\ remain\ \$localSize\n\ \ set\ chunk\ \ 2048\n\ \ while\ \{\$remain\ >\ 0\}\ \{\n\ \ \ \ if\ \{\$chunk\ >\ \$remain\}\ \{\n\ \ \ \ \ \ set\ chunk\ \$remain\n\ \ \ \ \}\n\ \ \ \ set\ copyBuff\ \[read\ \$lfd\ \$chunk\]\n\ \ \ \ puts\ -nonewline\ \$rfd\ \$copyBuff\n\ \ \ \ set\ remain\ \[expr\ \$remain\ -\ \$chunk\]\n\ \ \ \ puts\ -nonewline\ stdout\ .\n\ \ \}\n\ \ close\ \$lfd\n\ \ close\ \$rfd\n\ \ puts\ stdout\ \"\"\n\ \ puts\ stdout\ \"Copy\ successful\"\n\ \ return\ 1\n\}\n#############################################################################\n======\n\nNote\ that\ the\ above\ code\ is\ not\ the\ real\ thing\;\ there\ are\ things\ done\ between\ each\ write\ and\ the\ following\ read.\n\nUnfortunately,\ I\ can\ find\ no\ standard\ way\ to\ get\ the\ file\ descriptor\ for\ the\ open\ channel\ (Tcl_Channel\ being\ a\ pointer\ to\ an\ incomplete\ type),\ and\ there\ is\ no\ uniformity\ between\ the\ Windows,\ Mac\ and\ Unix\ ports\ as\ to\ the\ name\ of\ the\ system\ specific\ channel\ information\ and\ the\ names\ of\ the\ fields.\ \ The\ Unix\ specific\ header\ file\ is\ not\ visible\ to\ apps\ using\ an\ installed\ version\ of\ Tcl\ (I\ have\ to\ use\ the\ 8.2\ that\ is\ provided\ by\ the\ embedded\ OS\ vendor,\ and\ the\ sources\ for\ their\ port\ are\ not\ provided).\n\nAm\ I\ overlooking\ something?\ \ Is\ there\ a\ standard\ (and\ portable)\ way\ for\ extensions\ to\ access\ the\ POSIX\ style\ file\ descriptor\ for\ a\ Tcl_Channel\ object?\ \ I've\ written\ several\ Tcl\ extensions\ in\ the\ past,\ but\ none\ of\ them\ had\ to\ deal\ with\ Tcl_Channels\ at\ this\ level.\n\n----\n**\ Call\ to\ discussion\ regarding\ the\ Semantics\ of\ the\ oo::class\ command\ **\ \nmpdanielson\ would\ like\ to\ discuss\ the\ \[Semantics\ of\ the\ oo::class\ command\],\ wrt\ the\ interaction\ with\ packages\n\n----\n**Finding\ a\ faster\ a\ faster\ reaching\ a\ particular\ line\ number\ N\ in\ a\ file\ than\ by\ looping\ on\ \"gets\ \$f\"\ for\ lines\ before\ it**\n\n\[\[m\]\]\ -\ 2009-11-28\ 12:27:47\n\nIs\ there\ a\ faster\ way\ of\ reaching\ a\ particular\ line\ number\ N\ in\ a\ file\ than\ by\ looping\ on\ \"gets\ \$f\"\ for\ lines\ before\ it?\ In\ my\ case,\ the\ file\ is\ 2GB\ in\ size,\ ASCII\ content,\ with\ varying\ number\ of\ characters\ per\ line.\ It\ takes\ about\ 5\ minutes\ just\ to\ reach\ line\ 5000000\ (N),\ and\ only\ then\ does\ the\ actual\ processing\ begin.\ I\ can't\ use\ \"seek\"\ because\ number\ of\ bytes\ before\ line\ N\ is\ not\ known.\n\n\[EG\]\ You\ can\ combine\ \[chan\ read\],\ \[chan\ gets\]\ and\ \[split\]\ to\ build\ reasonably-sized\ lists\ of\ one\ element\ per\ line,\ and\ iterate\ over\ the\ file\ until\ you\ reach\ the\ line\ you\ want.\n\n======\n#\ pure\ gets\nproc\ UsingGets\ \{fname\ linenumber\}\ \{\n\ \ \ \ set\ fd\ \[open\ \$fname\]\n\ \ \ \ for\ \{set\ i\ 1\}\ \{\$i\ <=\ \$linenumber\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ chan\ gets\ \$fd\ data\n\ \ \ \ \}\n\ \ \ \ chan\ close\ \$fd\n\ \ \ \ return\ \$data\n\}\n\n#\ using\ read\ plus\ gets\ for\ the\ remaining\ chars\n#\ chunk\ is\ the\ chunk\ size\ to\ read\ in\ one\ go\nproc\ UsingRead\ \{fname\ linenumber\ \{chunk\ 100000\}\}\ \{\n\ \ \ \ set\ fd\ \[open\ \$fname\]\n\ \ \ \ set\ line\ 0\n\ \ \ \ while\ 1\ \{\n\ \ \ \ \ \ \ \ set\ data\ \[chan\ read\ \$fd\ \$chunk\]\n\ \ \ \ \ \ \ \ append\ data\ \[chan\ gets\ \$fd\]\n\ \ \ \ \ \ \ \ set\ sdata\ \[split\ \$data\ \\n\]\n\ \ \ \ \ \ \ \ set\ nl\ \[llength\ \$sdata\]\n\ \ \ \ \ \ \ \ if\ \{\$line\ +\ \$nl\ <\ \$linenumber\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ incr\ line\ \$nl\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ chan\ close\ \$fd\n\ \ \ \ \ \ \ \ \ \ \ \ return\ \[lindex\ \$sdata\ \[expr\ \{\$linenumber\ -\ \$line\ -\ 1\}\]\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n\n#\ this\ is\ a\ big_but_not_THAT_big\ file\ on\ my\ system\nset\ f\ /var/log/messages.1\nset\ linenumber\ 13500\n\nputs\ \"Pure\ gets:\ \[time\ \{puts\ \[UsingGets\ \$f\ \$linenumber\]\}\]\"\nputs\ \"Read-gets:\ \[time\ \{puts\ \[UsingRead\ \$f\ \$linenumber\]\}\]\"\n======\n\nOn\ my\ system,\ the\ output\ is\n\n======\n\$\ tclsh8.6\ reading.tcl\nNov\ 26\ 17:07:24\ merlot\ kernel:\ sd\ 6:0:0:0:\ \[sdc\]\ ASC=0x24\ ASCQ=0x0\nPure\ gets:\ 153451\ microseconds\ per\ iteration\nNov\ 26\ 17:07:24\ merlot\ kernel:\ sd\ 6:0:0:0:\ \[sdc\]\ ASC=0x24\ ASCQ=0x0\nRead-gets:\ 67498\ microseconds\ per\ iteration\n======\n\nTry\ testing\ several\ values\ of\ the\ chunk\ parameter\ to\ find\ the\ optimal\ for\ your\ system.\nNote\ that\ I've\ not\ tested\ the\ behaviour\ with\ another\ line\ ending\ than\ \\n\ (Unix\ system).\n\n\[dcd\]\ -\ 2009-12-30\n\ \ \ I'm\ assuming\ you\ don't\ care\ about\ the\ first\ part\ of\ the\ file\ before\ line\ N\ (although\ even\ \n\ \ \ if\ you\ do,\ I\ think\ I'm\ proposing\ a\ faster\ line\ counter.)\ Given\ that,\ regexp\ is\ pretty\ fast\n\ \ \ and\ you\ don't\ need\ to\ malloc\ for\ lines\ you\ don't\ care\ about.\ ok,\ untested\ code\ alert...\n\n\ \ \ set\ N\ 5000000\ #\ or\ whatever\n\ \ \ set\ n\ 0\n\ \ \ set\ eolre\ \{\\n\}\ #\ or\ whatever\n\ \ \ set\ f\ \[open\ file\]\n\ \ \ set\ lines\ \[read\ \$f\ \$chunksize\]\n\ \ \ while\ \{!\ \[eof\ \$f\]\}\ \{\n\ \ \ \ \ \ incr\ n\ \[regexp\ -all\ \$eolre\ \$lines\]\n\ \ \ \ \ \ if\ \{\$n\ >=\ \$N\}\ \{break\}\n\ \ \ \ \ \ set\ lines\ \[read\ \$f\ \$chunksize\]\n\ \ \ \}\n\ \ \ #\ deal\ with\ what's\ in\ \$lines\ and\ go\ on\n\n\[dcd\]\ -\ a\ little\ later\n\ \ \ I\ tested\ a\ variant\ of\ my\ implementation\ against\ \[EG\]s\ and\ on\ a\ reasonably\ large\ file\ mine\ lost.\n\ \ \ we\ have:\n\ \ \ \$\ ls\ -l\ bigfile.txt\n\ \ \ -rw-r--r--\ 1\ dcd\ Domain\ Users\ 876275714\ Dec\ 30\ 16:59\ bigfile.txt\n\ \ \ \$\ time\ wc\ -l\ bigfile.txt\n\ \ \ 6085879\ bigfile.txt\n\n\ \ \ real\ \ \ \ 0m4.187s\n\ \ \ user\ \ \ \ 0m2.343s\n\ \ \ sys\ \ \ \ \ 0m1.421s\n\n\ \ \ so,\ I\ tried,\ in\ tkcon\n\ \ \ %\ time\ \{UsingRead\ bigfile.txt\ 5000000\}\ 1\n\ \ \ 12592066\ microseconds\ per\ iteration\n\ \ \ vs\ a\ version\ of\ my\ code\ above\n\ \ \ %\ time\ \{readto\ \$f\ 5000000\ 100000\}\ 1\n\ \ \ 28341788\ microseconds\ per\ iteration\n\n\ \ \ near\ as\ I\ can\ tell,\ this\ means\ that\ tcl\ can\ allocate\ space\ and\ split\ on\ lines\ about\ twice\ as\ \n\ \ \ fast\ as\ regexp\ can\ walk\ through\ a\ buffer\ counting\ matches\ of\ a\ single\ character.\ whoda\ thunk\ it?\n\n\ \ \ %\ puts\ \$tcl_version\n\ \ \ 8.6\n\n----\n**\ Invoking\ tclsh\ for\ interactive\ execution,\ but\ specify\ file(s)\ to\ be\ sourced\ before\ issuing\ the\ first\ command\ prompt\ **\n\n\[Lavin\],\ 2009-12-24\ 12:58:52:\ How\ can\ I\ invoke\ tclsh\ for\ interactive\ execution,\ but\ specify\ file(s)\ to\ be\ sourced\ before\ issuing\ the\ first\ command\ prompt?\ \ TIA,\ \ --\ Mark\n\n\[AMG\]:\ See\ \[tclshrc\]\ for\ the\ answer.\n\n----\n**\ Resizable\ text\ widget\ **\n\n\[gasty\]\ -\ 2009-12-29\ 09:34:04\n\nHi\ all!\ I\ need\ a\ resizable\ text\ widget.\ Using\ pack\ as\ geometry\ manager\ works\ well:\n\n======\npack\ .t\ -expand\ 1\ -fill\ both\n======\n\nHowever\ I\ want\ to\ use\ grid:\n\n======\ngrid\ .t\ -row\ 0\ -column\ 0\ -sticky\ nwes\n======\n\nbut\ the\ widget\ do\ not\ \"expand\"\ when\ I\ change\ the\ size\ of\ their\ container.\ I\ also\ tried\ with\ rowconfigure\ and\ columnconfigure\ for\ this\ widget\ to\ set\ the\ weight\ parameter,\ but\ the\ results\ are\ the\ same.\nWhich\ can\ be\ the\ problem?\ I\ need\ some\ other\ option\ in\ the\ command\ above?\ Thanks\ in\ advance\ for\ any\ tip.\n\n\[Duoas\]\ 2009-12-29\ 10:28\ \ What\ did\ you\ set\ the\ weight\ as?\ The\ following\ should\ work\ just\ fine:\n\ \ grid\ .t\ -row\ 0\ -column\ 0\ -sticky\ news\n\ \ grid\ rowconfigure\ \ \ \ .\ .t\ -weight\ 1\n\ \ grid\ columnconfigure\ .\ .t\ -weight\ 1\nHope\ this\ helps.\n\n\[gasty\]\ I\ was\ using\ rowconfigure\ and\ columnconfigure\ incorrectly...\ Thanks!\n\n----\n**\ How\ to\ execute\ an\ application\ in\ the\ background\ while\ being\ able\ to\ know\ when\ that\ application\ has\ ended.**\ \ \n\ \n\[OK\]\ -\ 2010\ -1-25\ 10:36\n\nHi\ all,\nI'm\ new\ to\ tcl\ and\ need\ to\ find\ out\ how\ to\ exec\ an\ application\ in\ the\ background\ but\ be\ able\ to\ know\ when\ that\ application\ has\ ended.\ \ \n\nSo\ far,\ I\ browsed\ different\ sources\ and\ know\ I\ can\ execute\ in\ the\ background\ with\ &,\ but\ are\ not\ able\ to\ find\ how\ to\ known\ when\ this\ application\ has\ ended.\n\nexec\ cmd\ /c\ \"path_to_exec/prog.exe\ /123q\"\ &\n\nPeople\ recommended\ using\ wait,\ but\ I\ can't\ find\ an\ example\ of\ how\ to\ implement\ this.\ \ Please\ advise.\n\n\[AMG\]:\ Use\ \[\[\[open\]\ |cmdline\]\]\ to\ create\ \[pipeline\]s.\ \ \[\[\[wait\]\]\]\ is\ a\ \[TclX\]\ command.\n\n\[Hai\ Vu\]\ See\ this\ thread:\ http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/f8ccd018858026a0/e109d759a3debcb2?lnk=gst&q=exec+wait#e109d759a3debcb2\n\n----\n**\ Problem\ with\ the\ documentation\ that\ comes\ with\ critcl,\ i.e.\ the\ file\ critcl.tkd.**\ \ \n\n\[sdwillingham\]\ 2010.02.12:\n\nI'm\ having\ trouble\ with\ the\ documentation\ that\ comes\ with\ critcl,\ i.e.\ the\ file\ critcl.tkd.\ \ I've\ tried\ several\ versions\ of\ Wikit,\ both\ as\ regulars\ scripts\ and\ using\ tclkit\ on\ two\ different\ Windows\ XP\ computers\ with\ ActiveTCL\ 8.4\ and\ 8.5.\ \ The\ problem\ is\ that\ the\ the\ first\ page\ loads\ up\ and\ renders\ fine,\ but\ when\ I\ click\ on\ links,\ most\ pages\ are\ nearly\ empty\ with\ just\ a\ character\ or\ two.\ \ Using\ wikitool.tcl,\ I\ can\ see\ that\ the\ information\ is\ intact\ within\ critcl.tkd,\ but\ other\ than\ that,\ I\ am\ stumped\ on\ how\ to\ fix\ the\ problem.\n\n----\n**\ Problem\ with\ using\ tcom\ to\ interface\ with\ into\ the\ SAPI\ COM\ object\ for\ Text\ To\ Speech\ **\n\[notlistening\]\ 2010.02.27\n\nI\ am\ using\ tcom\ to\ interface\ with\ into\ the\ SAPI\ COM\ object\ for\ Text\ To\ Speech.\ I\ am\ trying\ to\ get\ SAPI\ to\ pass\ back\ an\ audio\ stream\ for\ use\ within\ my\ tcl\ script.\ I\ have\ come\ up\ short\ on\ a\ problem\ with\ iDispatch\ on\ tcom.\ I\ was\ hoping\ that\ someone\ could\ begin\ to\ explain\ where\ i\ need\ to\ look\ to\ make\ the\ nessesary\ changes\ to\ make\ ole32\ to\ implement\ iDispatch\ or\ suggest\ some\ ideas\ on\ how\ I\ can\ get\ the\ audio\ stream\ directly\ into\ my\ app.\ The\ test\ code\ that\ I\ have\ so\ far\ is:\n\n======\npackage\ require\ tcom\n\n\ \ \ \ \ \ \ #\ ::tcom::configure\ -concurrency\ multithreaded\n\ \ \ \ \ \ \ set\ voice\ \[::tcom::ref\ createobject\ Sapi.SpVoice\]\n\ \ \ \ \ \ \ set\ APO\ \[::tcom::ref\ createobject\ Sapi.SpCustomStream\]\n\ \ \ \ \ \ \ set\ GI\ \[::tcom::ref\ createobject\ \ Sapi.SPStream\]\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ set\ GIC\ \[\$GI\ -call\ CreateStreamOnHGlobal\]\;\ #\ At\ the\ moment\ the\ code\ errors\ here\ with\ -\ object\ does\ not\ implement\ IDispatch\n\n\ \ \ \ \ \ \ \[\$GIC\ hGlobal\ NULL\]\n\ \ \ \ \ \ \ \[\$GIC\ fDeleteOnRelease\ True\]\n\ \ \ \ \ \ \ \[\$GIC\ ppstm\ \$GI\]\n\n\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ set\ APOBS\ \[\$APO\ BaseStream\]\n\ \ \ \ \ \ \ set\ \$APOBS\ \$GI\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ set\ VAOS\ \[\$voice\ AudioOutputStream\]\ \n\ \ \ \ \ \ \ set\ \$VAOS\ \$APO\n\ \ \ \ \ \ \ \ \n\n\ \ \ \ \ \ \ \$voice\ Speak\ \"Welcome!\"\n\ \ \ \ \ \ \ while\ \{1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \[\$APO\ Read\ \$GI\ 100\]\n\ \ \ \ \ \ \ \ \ \ \ puts\ \$test\n\ \ \ \ \ \ \ \}\n======\n\nAny\ suggestions\ on\ how\ i\ can\ go\ about\ getting\ this\ to\ work\ in\ tcl\ /\ tcom\ /\ other\ would\ be\ great.\ I\ am\ not\ afraid\ of\ doing\ the\ hard\ work\ in\ the\ background\ but\ am\ a\ little\ bit\ unclear\ how\ to\ start.\ I\ have\ very\ little\ to\ no\ knowledge\ of\ COM\ objects\ and\ mechanisms\ in\ Windows\ but\ I\ am\ willing\ to\ learn.\ Ideally\ a\ quick\ dirty\ hack\ would\ suffice\ but\ beggars\ can\ not\ be\ choosers.\n\n----\ \ \n**\ How\ to\ make\ the\ frame\ with\ the\ data\ to\ fill\ both\ vertical\ and\ horizontal\ with\ BWidget\ ScrollableFrame\ **\ \n\[ICU\]\ -\ 2010-03-01\ 06:59:59\ \n\nI\ added\ scrollbar\ to\ http://wiki.tcl.tk/14901%|%simple\ Tktable%|%\ with\ the\ help\ of\ BWidget\ ScrollableFrame.\ It\ works\ BUT\ I\ just\ can't\ figure\ out\ how\ to\ make\ the\ frame\ with\ the\ data\ to\ fill\ both\ vertical\ and\ horizontal.\ I\ can\ make\ it\ work\ with\ ScrollableFrame\ -width/-height\ commands,\ but\ it\ would\ be\ better\ if\ the\ frame\ would\ resize\ itself.\ \n\nHere\ is\ the\ code\ where\ the\ table\ is\ being\ built.\ I\ would\ appreciate\ if\ someone\ could\ help\ me\ at\ where\ I'm\ going\ wrong.\n\n\ \ \ \ \ \ \ \ destroy\ \$pathName\n\ \ \ \ \ \ \ \ frame\ \$pathName\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ set\ r\ 0\;\ set\ c\ 0\n\ \ \ \ \ \ \ \ set\ w\ \[ScrolledWindow\ \"\$pathName.r\$\{r\},\$c\"\]\n\ \ \ \ \ \ \ \ pack\ \$w\ -fill\ both\ -expand\ true\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ set\ t\ \[ScrollableFrame\ \$w\$pathName\ -height\ 650\ -width\ 650\]\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \$w\ setwidget\ \$t\n\ \ \ \ \ \ \ \ set\ uf\ \[\$t\ getframe\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ for\ \{set\ r\ 0\}\ \{\$r\ <\ \$A(-rows)\}\ \{incr\ r\}\ \{\n\ \ \ \ \ \ \ \ for\ \{set\ c\ 0\}\ \{\$c\ <\ \$A(-cols)\}\ \{incr\ c\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ w\ \"\$uf.r\$\{r\},\$c\"\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$r\ <\ \$A(-titlerows)\ ||\ \$c\ <\ \$A(-titlecols)\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ \{\ \$::tcl_platform(platform)\ eq\ \"windows\"\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ bg\ SystemDisabledText\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ bg\ darkgrey\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ label\ \$w\ \ -textvariable\ \$A(-variable)\\(\$r,\$c\\)\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ flat\ -bg\ \$bg\ -fg\ white\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ elseif\ \{\[lsearch\ \$A(-readonlyrows)\ \$r\]\ !=\ -1\ ||\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lsearch\ \$A(-readonlycols)\ \$c\]\ !=\ -1\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ label\ \$w\ -textvariable\ \$A(-variable)\\(\$r,\$c\\)\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ sunken\ -bd\ 0\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$w\ config\ -font\ \[lindex\ \[\$w\ config\ -font\]\ 3\]\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ entry\ \$w\ -textvariable\ \$A(-variable)\\(\$r,\$c\\)\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -relief\ sunken\ -bd\ 2\ -justify\ center\ -width\ 0\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #if\ \{\[info\ exists\ A(-vcmd)\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\$w\ config\ -validate\ key\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -vcmd\ \[list\ \$A(-vcmd)\ \$r\ \$c\ %P\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ grid\ \$uf.r\$\{r\},\$c\ -row\ \$r\ -column\ \$c\ -sticky\ ew\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \}\n\n\[ICU\]\nI\ was\ able\ to\ solve\ it.\n\n\[Fro\]\ -\ 2010-04-06\ 17:28:34\n\nThanks\ for\ the\ reply,\ I\ got\ it\ working.\n\n----\n**\ Problem\ with\ info\ hostname\ **\n\n\[MaheshD\]\ -\ 2010-04-08\ 05:38:28\n\[info\ hostname\]\ issue\n\nHelp\ needed\ with\ the\ following\ issue\ :\n\[ambiguous\ result\ with\ \"info\ hostname\ \"\]\n\n----\n**\ Problem\ in\ namespace\ scope\ of\ variables\ **\n\n\[MaheshD\]\ -\ 2010-04-14\ 04:40:12\n\nProblem\ in\ namespace\ scope\ of\ variables\n\nWrite\ a\ TCL\ file\ with\ a\ namespace\ definition\ in\ it\ as\ :\n\nfile\ \"a.tcl\"\n\n\ \ namespace\ eval\ nse\ \{\n\ \ \ \ set\ WorkDir\ \"/home/sj/name\"\n\ \ \}\n\nUnder\ TCL\ prompt,\ do\ the\ following\ :\n\n\ %\ set\ WorkDir\ \"asdf\"\n\ asdf\n\ %\ source\ a.tcl\n\ /home/sj/name\n\ %\ puts\ \$nse::WorkDir\n\ can't\ read\ \"nse::WorkDir\":\ no\ such\ variable\n\ %\n\nWhy\ is\ this\ behaviour,\ why\ are\ the\ variable\ names\ in\ global\ scope\ clashing\ with\ the\ one\ in\ namespace\ \"nse\"\n\nPlease\ help\ ?\n\n\[Martyn\ Smith\]\ 14\ Apr\ 2010\ There\ is\ not\ a\ clash\ your\ namespace\ eval\ only\ executes\ the\ code\ in\ the\ namespace\ fo\ your\ WorkingDir\ variable\ is\ destroyed\ at\ the\ end\ of\ the\ namespace\ eval.\ \ What\ you\ are\ looking\ for\ is\n\n\ \ namespace\ eval\ nse\ \{\n\ \ \ \ variable\ WorkDir\ \"/home/sj/name\"\n\ \ \}\n\nWhich\ creates\ a\ variable\ in\ the\ nse\ namespace\ and\ initialises\ it.\ Then\ to\ access\ you\ variable\ in\ another\ procedure\ you\ use\n\ \ variable\ WorkDir\n\n\[Lars\ H\]:\ While\ Martyn's\ fix\ is\ correct,\ I\ think\ his\ explanation\ is\ wrong.\ Namespace\ variables\ don't\ get\ destroyed\ when\ a\ \[namespace\ eval\]\ ends,\ this\ is\ rather\ an\ example\ of\ the\ \[dangers\ of\ creative\ writing\]:\ the\ namespaced\ \[set\]\ chose\ to\ update\ the\ existing\ ::WorkDir\ variable\ rather\ than\ the\ ::nse::WorkDir\ that\ would\ have\ to\ be\ created.\n\n----\n**Help\ with\ tcltest\ harness\ **\n\n18MAR2010\n\nHi\ all,\ I'm\ new\ to\ tcltest\ but\ not\ completely\ green\ with\ tcl\ in\ general.\ \ I'm\ trying\ to\ get\ my\ head\ around\ the\ use\ of\ the\ tcltest\ harness.\ \ We\ tend\ to\ write\ multiple\ .tcl\ files\ as\ part\ of\ a\ Component-level\ test\ (CSC\ test).\ \ So\ I\ think\ what\ I\ would\ do\ is\ write\ an\ individual\ .test\ file\ for\ each\ software\ Component,\ which\ would\ have\ some\ number\ of\ calls\ to\ tcltest::test\ in\ order\ to\ run\ each\ script\ file\ that\ makes\ up\ the\ whole\ set\ of\ functionality\ tests\ for\ a\ given\ Component.\n\nBelow\ is\ the\ high-level\ 'master'\ tcl\ that\ whould\ run\ all\ lower-level\ '.test'\ tcl\ files,\ and\ then\ one\ sample\ .test\ file\ for\ a\ Component\ named\ CSC_foo.\ \ \n\nI\ guess\ I\ have\ 2\ questions:\n1)\ Am\ I\ understanding\ all\ this\ correctly\ as\ far\ as\ what\ goes\ in\ each\ type\ of\ file\ (.tcl,\ .test),\ and\ \n2)\ Where\ I\ need\ to\ use\ a\ raw\ 'filename.tcl'\ vs.\ a\ 'source\ filename.tcl'\ call\ in\ order\ to\ have\ individual\ .tcl\ files\ get\ run.\ (this\ stems\ from\ the\ man\ page\ text\ talking\ about\ -setup,\ -cleanup,\ and\ -body.\ For\ example,\ for\ -setup,\ it\ says\ \"The\ optional\ -setup\ attribute\ indicates\ a\ ''script''\",\ I'm\ not\ sure\ if\ the\ -setup\ syntax\ is\ \"-setup\ filename.tcl\"\ or\ if\ it\ would\ be\ \"-setup\ source\ filename.tcl\".)\n\nThanks\ very\ much\ in\ advance.\n\n-\ Jeff\n\n======\n#\ FILENAME:\ CSCI.tcl\n#\ Top-level\ script\ (usually\ named\ all.tcl)\ to\ run\ all\ tests\ defined\ in\n#\ .test\ files\ \n#\ \n\npackage\ require\ Tcl\npackage\ require\ tcltest\nnamespace\ import\ tcltest::*\nconfigure\ \{*\}\$argv\ -testdir\ \[file\ dir\ \[info\ script\]\]\nrunAllTests\n\n#\ end\ CSCI.tcl\n\n#\ FILENAME:\ CSC_foo.test\n#\ \ \ \ \ \ \ \ \ \ \ \n#\ There's\ one\ of\ these\ .test\ files\ for\ each\ CSC.\n#\ A\ CSC\ test\ may\ have\ multiple\ .tcl\ files\ associated\ with\ it.\n#\ \ \n#\ \ e.g.\ \ As\ part\ of\ CSC\ foo,\ there\ may\ be\ the\ following\ script\ files\n#\ \ \ \ \ \ \ \ to\ segregate\ testing\ into\ logical\ chunks:\ \n#\n#\ \ \ \ \ \ \ \ foo_mode_tests.tcl\ \n#\ \ \ \ \ \ \ \ foo_parameter_tests.tcl\n#\ \ \ \ \ \ \ \ foo_fault_tests.tcl\n#\npackage\ require\ tcltest\neval\ ::tcltest::configure\ \$argv\npackage\ require\ CSC_foo\nnamespace\ eval\ ::CSC_foo::test\ \{\n\ \ \ namespace\ import\ ::tcltest::*\n\ \ \ testConstraint\ X\ \[expr\ \{...\}\]\n\ \ \ variable\ SETUP\ \{FQT_TC_Setup.tcl\}\n\ \ \ variable\ CLEANUP\ \{FQT_TC_Cleanup.tcl\}\n\n\ \ \ #\ Run\ all\ 3\ test\ cases\ for\ CSC_foo\n\n\ \ \ test\ CSC_foo-mode_tests\ \{runs\ foo_mode_tests.tcl\ script\}\ \n\ \ \ \ \ \ -setup\ \$SETUP\ \n\ \ \ \ \ \ -constraints\ X\ \n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_mode_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\n\ \ \ test\ CSC_foo-param_tests\ \{runs\ foo_param_tests.tcl\ script\}\ \n\ \ \ \ \ \ -setup\ \$SETUP\ \n\ \ \ \ \ \ -constraints\ X\ \n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_parameter_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\n\ \ \ test\ CSC_foo-fault_tests\ \{runs\ foo_fault_tests.tcl\ script\}\ \n\ \ \ \ \ \ -setup\ \$SETUP\ \n\ \ \ \ \ \ -constraints\ X\ \n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_fault_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\n\ \ \ cleanupTests\ #\ this\ is\ a\ tcltest\ function,\ it\ prints\ the\ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ PASS/FAIL/SKIP\ info\ #\ among\ other\ things\n\n\}\ #\ end\ namespace\ eval\ ::CSC_XYZ::test\n\nnamespace\ delete\ ::CSC_foo::test\n\n#\ end\ CSC_foo.test\n======\n\n\[hv\]\ Here\ are\ what\ I\ notice:\ \ (1)\ Yes,\ you\ understood\ correctly.\ By\ default,\ the\ *.test\ files\ will\ be\ included\ in\ the\ test\ suite.\ (2)\ The\ arguments\ to\ -setup\ and\ -cleanup\ are\ just\ a\ block\ of\ code.\ For\ example:\n\n\ \ \ \ set\ SETUP\ \{\n\ \ \ \ \ \ \ \ set\ x\ 1\ \n\ \ \ \ \ \ \ \ set\ s\ \"some\ string\"\n\ \ \ \ \}\ \ \ \n\n\ \ \ \ test\ testName\ \{description\}\ -setup\ \$SETUP\ -body\ \{\n\ \ \ \ \ \ \ \ #\ Body\ of\ test\ ...\n\ \ \ \ \}\ -result\ \{expected\ result\}\n\nSimilarly,\ you\ can\ define\ a\ variable\ and\ pass\ that\ to\ the\ -cleanup\ flag.\ Note\ that\ if\ you\ don't\ fit\ everything\ into\ one\ line,\ you\ have\ to\ use\ line\ contiuation\ (\\),\ the\ only\ exception\ is\ the\ open\ brace\ \{:\n\n\ \ \ test\ CSC_foo-mode_tests\ \{runs\ foo_mode_tests.tcl\ script\}\ \\\n\ \ \ \ \ \ -setup\ \$SETUP\ \\\n\ \ \ \ \ \ -constraints\ X\ \\\n\ \ \ \ \ \ -body\ \{\n\n\ \ \ \ \ \ \ \ \ source\ foo_mode_tests.tcl\ \ #\ this\ needs\ to\ return\ a\ value\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ to\ compare\ with\ -result\ \{\}\n\n\ \ \ \}\ -cleanup\ \$CLEANUP\ -result\ \{#expected\ results\}\n\nAs\ a\ personal\ preference,\ I\ structure\ my\ tests\ as:\n\n\ \ \ \ test\ testName\ \{\n\ \ \ \ \ \ \ \ Test\ description\ goes\ here\n\ \ \ \ \}\ -setup\ \$SETUP\ -cleanup\ \$cLEANUP\ -body\ \{\n\ \ \ \ \ \ \ \ #\ test\ body\ goes\ here\n\ \ \ \ \}\ -result\ \{expected\ result\}\n\n\n\[Fro\]\ Thanks\ for\ the\ reply\ hv,\ I\ was\ able\ to\ get\ it\ working.\ \n\n----\n**\ How\ to\ return\ a\ list\ of\ arguments\ from\ a\ procedure\ **\n\[mreister\]\ -\ 2010-05-26\ 23:18:42\n\nOk\ so\ I\ am\ pretty\ new\ to\ TCL\ and\ I\ am\ using\ it\ for\ scripting\ a\ command\ line\ (modelsim\ for\ anyone\ who\ cares)\ but\ anyways\ I\ am\ having\ trouble\ figuring\ out\ how\ i\ can\ return\ a\ string\ of\ arguements\ from\ a\ precudure.\ As\ i\ understand\ it\ when\ a\ procedure\ i\ wrote\ executes\ its\ return\ value\ get\ executed\ on\ the\ command\ line.\ So\ I\ am\ able\ to\ return\ a\ command\ with\ a\ singal\ word\ but\ when\ i\ try\ to\ return\ a\ command\ with\ multiple\ words\ tcl\ seems\ to\ only\ try\ to\ read\ the\ first\ word\ of\ the\ command\ and\ when\ i\ put\ it\ return\ command\ in\ quotes\ it\ seems\ that\ the\ command\ line\ interprets\ the\ return\ value\ in\ quotes\"\".\ For\ example:\n\nproc\ set_f\ \{cycle_number\}\ \{\n\ \ \ \ \n\ \ \ \ switch\ \ \$cycle_number\ \{\n\ \ \ \ \ \ \ \ 1\{\n\ \ \ \ \ \ \ \ \ \ \ \ return\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ 2\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"force\ -freeze\ sim:/uart/reset\ 0\ 0\"\ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ default\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"hello\"\ \ \ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \n\ \ \ \ return\ force\ -freeze\ sim:/uart/reset\ 1\ 0\n\}\n\nIn\ this\ situation\ its\ seems\ to\ try\ to\ return\ force\n\nBut\ when\ I\ do\ this:\n\nproc\ set_f\ \{cycle_number\}\ \{\n\ \ \ \ \n\ \ \ \ switch\ \ \$cycle_number\ \{\n\ \ \ \ \ \ \ \ 1\{\n\ \ \ \ \ \ \ \ \ \ \ \ return\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ 2\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"force\ -freeze\ sim:/uart/reset\ 0\ 0\"\ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ default\{\n\ \ \ \ \ \ \ \ \ \ \ \ puts\ \"hello\"\ \ \ \n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \n\ \ \ \ return\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\n\}\n\nIt\ seems\ to\ retrun\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\ to\ the\ command\ line\ rather\ than\ force\ -freeze\ sim:/uart/reset\ 1\ 0.\ Which\ is\ what\ I\ want.\ So\ my\ question\ is\ how\ can\ i\ return\ the\ line\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\ to\ the\ command\ line\ WITHOUT\ the\ quotes?\n\n\[AM\]\ You\ do\ not\ describe\ the\ code\ that\ gets\ this\ returned\ string\ and\ needs\ to\ deal\ with\ the\ multiple\ returned\ strings.\ I\ will\ make\ a\nguess:\ \"force\ -freeze\ sim:/uart/reset\ 1\ 0\"\ is\ meant\ as\ an\ external\ program\ with\ arguments.\ If\ so,\ then:\n\n(if\ you\ use\ Tcl\ 8.5)\n\n\ \ \ \ set\ command\ \[set_f\ \$cycle_number\]\n\ \ \ \ exec\ \{*\}\$command\n\n(or\ if\ you\ use\ Tcl\ 8.4\ or\ previous)\n\n\ \ \ \ set\ command\ \[set_f\ \$cycle_number\]\n\ \ \ \ eval\ exec\ \$command\n\nwill\ run\ the\ program\ \"force\"\ with\ the\ individual\ arguments\ -freeze,\ sim:/uart/reset,\ 1\ and\ 0.\n\nThe\ expansion\ operator\ \[\{*\}\]\ expands\ a\ list\ into\ individual\ arguments\ and\ the\ command\ eval\ re-interprets\ the\ entire\ list\ of\ arguments\ as\ a\ string.\ (Note\ the\ eval\ command\ should\ actually\ be\ more\ complicated\ to\ avoid\ nasty\ stuff\ with\ embedded\ \[\[\]\]\ and\ the\ like\ -\ the\ very\ reason\ for\nthe\ introduction\ of\ \{*\}).\n\nSo,\ it\ is\ the\ caller\ that\ needs\ to\ deal\ with\ the\ multiple\ arguments,\ not\ the\ callee.\n\nFurthermore:\ if\ you\ want\ to\ return\ multiple\ pieces,\ it\ is\ best\ to\ use\ a\ list:\n\n\ \ \ \ return\ \[list\ force\ -freeze\ sim:/uart/reset\ 1\ 0\]\n\nas\ then\ the\ individual\ pieces\ are\ well\ defined\ and\ protected\ against\ haphazard\ conversions.\n\n----\n**\ How\ to\ copy\ drawings\ from\ the\ canvas\ and\ paste\ into\ Word\ or\ PowerPoint\ **\n\n\[Beware\],\ 5th\ June\ 2010:\ Where\ can\ I\ find\ some\ information\ on\ 'general'\ Windows\ copy\ and\ paste?\ \ I'd\ quite\ like\ to\ be\ able\ to\ copy\ drawings\ from\ the\ canvas\ and\ paste\ into\ Word\ or\ PowerPoint,\ where\ they\ would\ become\ Office\ drawings.\n\nI\ can't\ find\ any\ useful\ information\ through\ Microsoft.\n\n\[Lars\ H\]:\ The\ -type\ option\ of\ \[clipboard\]\ is\ probably\ relevant,\ but\ I\ don't\ know\ what\ might\ be\ meaningful\ values\ on\ \[Microsoft\ Windows\].\ The\ likeliest\ place\ to\ find\ an\ answer\ to\ this\ is\ probably\ some\ sort\ of\ Windows/Tk\ FAQ,\ as\ this\ is\ an\ area\ where\ the\ Tk\ manpages\ are\ very\ \[X\]-centric.\ I\ also\ notice\ the\ Wiki\ \[clipboard\]\ page\ has\ some\ pointers\ regarding\ bitmap\ copy\ and\ paste\ on\ Windows.\n\n\[MG\]\ \[Copy\ image\ to\ and\ from\ the\ Windows\ clipboard\]\ may\ be\ of\ some\ use.\n\n----\n**\ Problem\ with\ directories\ which\ are\ to\ be\ checked\ **\n\[maheshd\]\ -\ 2010-06-30\ 08:44:06\n\nThe\ command\ \[file\ writable\]\ was\ used\ to\ know,\ if\ a\ certain\ directory\ has\ write\ permissions\ for\ a\ certain\ user.\nThe\ command\ is\ written\ as\ a\ TCL\ script\ which\ is\ then\ remotely\ executed\ onto\ the\ slave\ machine\ from\ the\ master.\nNow,\ the\ problem\ is,\ the\ directories\ which\ are\ to\ be\ checked\ for\ write\ permissions\ are\ automounted\ on\ slave.\nAs\ is\ the\ case\ with\ auto\ mount,\ until\ and\ unless\ the\ mount\ partition\ is\ used,\ the\ partition\ remains\ unmounted.\nHence\ the\ command\ \"file\ writable\ <DirectoryName>\"\ fails,\ i.e\ it\ reports\ that\ <DirectoryName>\ has\ no\ write\ permissions.\nBut,\ if\ the\ remote\ directory\ <DirectoryName>\ is\ visited\ once,\ i.e\ a\ \"cd\ <Directoryname>\ and\ ls\",\ it\ results\ in\ the\npartition\ being\ mounted\ and\ from\ then\ on\ the\ TCL\ script\ containing\ '''file\ writable'''\ command\ works\ fine.\n\n'''The\ question'''\ :\ Is\ there\ any\ way\ to\ check\ for\ the\ same\ without\ actually\ hard\ mounting\ the\ partition\ and\ without\ visiting\ the\ directory\ (not\ even\ once).\n\n\[AMG\]:\ This\ isn't\ a\ Tcl\ question.\ \ It's\ very\ OS-specific.\n\nI\ suspect\ the\ answer\ is\ \"no\"\ because\ (if\ I\ read\ you\ right)\ you're\ trying\ to\ figure\ out\ the\ permissions\ of\ the\ root\ directory\ of\ a\ filesystem\ without\ mounting\ that\ filesystem.\ \ It's\ impossible\ to\ read\ the\ permissions\ bits\ without\ reading\ the\ filesystem,\ and\ the\ only\ sensible\ way\ to\ do\ this\ is\ to\ mount\ it.\n\n----\nDoes\ anyone\ have\ a\ simple\ TK\ C\ callback\ Example?\n\nstevieb\ -\ 2011-07-17\ 21:54:00\n\nI\ am\ new\ to\ TCL/TK,\ I\ have\ some\ C\ code\ and\ I\ want\ to\ put\ a\ TK\ front\ end\ on\ it,\ can\ anyone\ get\ me\ started\ by\ providing\ a\ simple\ example\ of\ a\ TK\ GUI\ that\ invokes\ a\ C\ callback,\ it\ could\ be\ as\ simple\ as\ the\ HelloWorld.c\ example,\ where\ you\ click\ a\ button\ and\ the\ C\ function\ is\ called\ by\ TK\ to\ write\ out\ Hello\ World!\n\nThanks\n\nstevieb\ \ \n\n\[RLE\]\ (2011-07-17):\ You\ may\ want\ to\ take\ a\ look\ at\ the\ \[Critcl\]\ and\ \[Critcl\ 2\]\ pages,\ as\ well\ as\ search\ for\ other\ wiki\ pages\ relating\ to\ Critcl.\ \ It\ provides\ a\ very\ easy\ way\ to\ interface\ C\ code\ into\ Tcl\ code.\n\n\n\n<<categories>>\ Discussion\ |\ Development} CALL {my revision {Ask, and it shall be given # 8}} CALL {::oo::Obj952621 process revision/Ask%2C+and+it+shall+be+given+%23+8} CALL {::oo::Obj952619 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