Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Mahjong%5FStyle%5FDeletion?V=40
QUERY_STRINGV=40
CONTENT_TYPE
DOCUMENT_URI/revision/Mahjong_Style_Deletion
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.71.254.191
REMOTE_PORT50062
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR13.58.252.8
HTTP_CF_RAY876fc6861d1b2300-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP13.58.252.8
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 Mahjong_Style_Deletion ***Mahjong_Style_Deletion\ ***\n\ \ \nThis\ page\ is\ under\ development.\ Comments\ are\nwelcome,\ but\ please\ load\ any\ comments\ \nat\ the\ bottom\ of\ the\ page.\ Thanks,\ \[gold\]\n\n----\nThis\ page\ uses\ \[Tcl\]8.5\ for\ \[windows\]\ \nto\ develop\ Mahjong_Style_Deletion\ \ .\ \n(note:\ file\ is\ working\ in\ 8.5,but\ you\nmight\ try\ saving\ in\ ANSCII,\ if\ you\ get\ a\ glyph\ compiler\ error\ \ )\nThis\ original\ code\ was\ provided\ by\ \ \ \[aricb\]\ \ \[aricb\]\ \non\ the\ Wiki\ Ask\ page.\ Probably\ \ncould\ start\ a\ wiki\ page,\ since\ it\ is\na\ good\ baby\ game\ engine\ for\ Mahjong\ style\ games.\nI\ added\ a\ few\ buttons\ at\ the\ bottom\nand\ tried\ to\ keep\ the\ clean\ code\ separate\ uptop.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \nIn\ developing\ a\ computer\ program\ or\ application,\nit\ is\ helpful\ to\ develop\ analogs\ \nfor\ the\ individual\ tasks\ of\ the\ application.\n\ \ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n----\n\n***Pretty\ Print\ Version\ ***\n======\n\ \ \ \ \ \ \ \ #\ test\ indent\ from\ ased\ editor\n\ \ \ \ \ \ \ \ #\ written\ on\ Windows\ XP\ on\ eTCL\n\ \ \ \ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ \n\ \ \ \ \ \ \ \ #!/usr/bin/env\ wish\n\ \ \ \ \ \ \ \ package\ require\ Tk\n\ \ \ \ \ \ \ \ \ proc\ populateCanvas\ \{canvas\ cols\ rows\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ \ \ \ \ \ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ \ \ \ \ \ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ set\ boxwidth\ 50\n\ \ \ \ \ \ \ \ \ \ \ \ set\ boxheight\ 20\n\ \ \ \ \ \ \ \ \ \ \ \ set\ padx\ 3\n\ \ \ \ \ \ \ \ \ \ \ \ set\ pady\ 3\n\ \ \ \ \ \ \ \ \ \ \ \ set\ colors\ \{red\ orange\ yellow\ green\ blue\ purple\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\ \ \ \ \ \ \ \ \ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ rectangle\ \$x1\ \$y1\ \$x2\ \$y2\ -fill\ \$color\ -outline\ black\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ -text\ \$text\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ proc\ clearSelection\ \{canvas\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ #\ if\ there\ is\ an\ existing\ currently\ selected\ box,\ change\ its\ border\ back\ to\n\ \ \ \ \ \ \ \ \ \ \ \ #\ black\;\ set\ variables\ selectedid\ and\ selectedtext\ to\ empty\ strings\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedid\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedtext\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$selectedid\ ne\ \"\"\ &&\ \[\$canvas\ find\ withtag\ \$selectedid\]\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$canvas\ itemconfigure\ \$selectedid\ -outline\ black\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ selectedid\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ set\ selectedtext\ \"\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ proc\ handleSelection\ \{canvas\ id\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ #\ determine\ the\ \"next\ step\"\ by\ comparing\ the\ newly\ selected\ box\ id\ and\ text\n\ \ \ \ \ \ \ \ \ \ \ \ #\ to\ the\ box\ id\ and\ text\ of\ the\ previously\ selected\ box\ (contained\ in\n\ \ \ \ \ \ \ \ \ \ \ \ #\ the\ variables\ \$selectedid\ and\ \$selectedtext)\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ ids\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedid\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedtext\n\ \ \ \ \ \ \ \ \ \ \ \ set\ boxid\ \$ids(\$id)\n\ \ \ \ \ \ \ \ \ \ \ \ lassign\ \$boxes(\$boxid)\ textid\ text\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$boxid\ eq\ \$selectedid\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ user\ has\ selected\ the\ same\ box\ twice\;\ deselect\ the\ box\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ elseif\ \{\$text\ eq\ \$selectedtext\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ user\ has\ selected\ two\ boxes\ with\ the\ same\ text\;\ delete\ both\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$canvas\ delete\ \$boxid\ \$textid\ \$selectedid\ \[lindex\ \$boxes(\$selectedid)\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ user\ has\ selected\ a\ box\ when\ there\ is\ no\ selection,\ or\ user\ has\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ selected\ a\ box\ with\ different\ text\ than\ the\ previously\ selected\ box\;\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ try\ to\ deselect\ the\ previous\ box,\ then\ select\ the\ new\ box\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ selectedid\ \$boxid\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ selectedtext\ \$text\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$canvas\ itemconfigure\ \$boxid\ -outline\ white\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ proc\ processClick\ \{canvas\ x\ y\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ #\ determine\ whether\ the\ user\ has\ clicked\ on\ something\;\ if\ so,\ call\n\ \ \ \ \ \ \ \ \ \ \ \ #\ proc\ handleSelection\n\ \ \ \ \ \ \ \ \ \ \ \ set\ id\ \[\$canvas\ find\ overlapping\ \$x\ \$y\ \$x\ \$y\]\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[llength\ \$id\]\ >\ 0\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ handleSelection\ \$canvas\ \[lindex\ \$id\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ set\ win\ \[toplevel\ .demo\]\n\ \ \ \ \ \ \ \ wm\ title\ \$win\ \"Mahjong-style\ deletion\"\n\ \ \ \ \ \ \ \ set\ canvas\ \[canvas\ \$win.canvas\]\n\ \ \ \ \ \ \ \ pack\ \$canvas\ \ -expand\ 1\ -fill\ both\n\ \ \ \ \ \ \ \ bind\ \$canvas\ <Button-1>\ \[list\ processClick\ %W\ %x\ %y\]\n\ \ \ \ \ \ \ \ set\ state\ 1\n\ \ \ \ \ \ \ \ proc\ mahjongstyle\ \{\ state\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ global\ coloritem\ canvas\ details\n\ \ \ \ \ \ \ \ \ \ \ \ set\ coloritem\ gray\n\ \ \ \ \ \ \ \ \ \ \ \ set\ details\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Mahjong-style\ deletion.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ press\ in\ succession\ two\ tiles\ with\ the\ same\ text.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ both\ tiles\ should\ be\ deleted.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ The\ Mahjong-style\ deletion\ is\ for\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ right\ mouse\ press.\}\n\ \ \ \$canvas\ create\ window\ 15\ 210\ -window\ \[button\ \$canvas.r\ -width\ 10\ -text\ report\ \\\n\ \ \ \ \ \ -bg\ \$coloritem\ \ \ \ -command\ \{tk_messageBox\ -message\ \$details\}\]\n\ \ \ \$canvas\ create\ window\ 30\ 230\ -window\ \[button\ \$canvas.c\ -width\ 10\ -height\ 1\ -text\ exit\ \\\n\ \ \ -bg\ \$coloritem\ \ \ \ \ -command\ \{exit\ \}\]\ \ \ \ \n\ \ \ \ \ \}\n\ \ \ \ \ \ \ \ mahjongstyle\ \{\ \$state\ \}\n\ \ \ \ \ \ \ \ populateCanvas\ \$canvas\ 4\ 5\n\ \ \ \ \ \ \ \ set\ selectedid\ \"\"\n\ \ \ \ \ \ \ \ set\ selectedtext\ \"\"\n\ \ \ \ \ \ \ \ console\ hide\n======\n----\n***Screenshots***\n\n\[WikiDbImage\ TCL_wiki_Mahjong_Style_Deletion.PNG\]\n\n\n\n\n\n\n\[http://farm5.static.flickr.com/4023/4685677488_29f32589be_s.jpg\]\n\n\n\n\n\n\n\[http://farm5.static.flickr.com/4023/4685677488_29f32589be_m.jpg\]\n\n\n**Comments**\nPlease\ place\ any\ comments\ here,\ Thanks.\n\n\[gold\]\ Change:Redundant\ procedure\ ?\ deleted.\ \n\n\ \ \ \ \n----\n**References**\n\ \ \ *\ http://en.wikipedia.org/wiki/calculators\n\ \ \ *\ Search\ on\ google.com\ for\ \"counting\ rods\"\n\ \ \ *\ http://en.mahjong-zone.com/\n\ \ \ *\ http://home.halden.net/vkp/vkp/mac.html\n\ \ \ *\ http://www.tcl.tk/software/plugin/match.html\n\ \ \ *\ http://www.eiu.edu/~philos/retro/dos/games.htm\n\ \ \ *\ http://www.lcdf.org/xmahjongg/\n\ \ \ *\ http://scien.stanford.edu/class/psych221/projects/99/dmerrill/\n\ \ \ *\ http://www.scriptics.com/\n\ \ \ *\ http://www.photomosaic.com/\n\ \ \ *\ http://opencircuitdesign.com/magic/magic7_2.html\n\ \ \ *\ images\ give\ some\ ideas?\ http://opencircuitdesign.com/magic/giffiles/wind3d.gif\n\ \ \ *\ http://www.karlrunge.com/x11vnc/recurse_x11vnc.jpg\n\ \ \ *\ http://e.irigoyen.home.comcast.net/~e.irigoyen/d3kalphablendingdemo2.jpg\n\ \ \ *\ http://linuxshellaccount.blogspot.com/2008_11_01_archive.html\n\ \ \ *\ Programming\ References\ (\ TCL\ &\ C#\ )***\n\ \ \ *\ \[Base\ conversion\]\n\ \ \ *\ Syntax\ \ \[I\ love\ foreach\]\ \[use\ while\ to\ iterate\ over\ a\ list\]\n\ \ \ *\ \[additional\ list\ functions\],\ \[string\ reverse\],\n\ \ \ *\ \[split\],\ \[list\]\n\ \ \ *\ \[recursive\ list\ searching\]\n\ \ \n\n----\ \n**Appendices**\n***Tables***\n***Auxiliary\ Programs***\n***\ mahjong\ style\ deletion\ in\ tcl,jan20,2009\ ***\n\ \ \ \ \nThis\ question\ has\ been\ pretty\ well\ answered\ and\nclosed\ out.\ I\ have\ posted\ the\ answer\ etc\ in\ a\ \nnew\ wiki\ page.\ \ \nThanks,\[gold\]\n\n\ \[aricb\]\ 2009-1-23:\ Does\ the\ following\ code\ do\ what\ you\ have\ in\ mind?\n\n\ \n\[aricb\]\ The\ code\ doesn't\ use\ any\ special\ 8.5\ features.\ \ It\ sounds\ like\ the\ script\ got\ corrupted\ either\ while\ you\ were\ pasting\ it\ or\ when\ you\ converted\ it\ to\ Unicode.\ \ I\ would\ copy\ and\ save\ the\ script\ one\ more\ time\ (I\ assume\ you\ know\ to\ do\ this\ with\ a\ text\ editor\ rather\ than\ a\ word\ processor).\ \ Save\ it\ using\ your\ default\ system\ encoding\ or\ UTF-8\ (don't\ use\ any\ other\ Unicode\ encoding\ than\ UTF-8).\ \ Look\ at\ the\ saved\ code,\ possibly\ with\ a\ different\ program\ than\ the\ editor\ you\ used\ to\ save\ it,\ to\ make\ sure\ it\ hasn't\ been\ corrupted.\n=====\n\ \ proc\ populateCanvas\ \{canvas\ cols\ rows\}\ \{\n\ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ \n\ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ set\ boxwidth\ 50\n\ \ \ \ set\ boxheight\ 20\n\ \ \ \ set\ padx\ 3\n\ \ \ \ set\ pady\ 3\n\ \ \ \ set\ colors\ \{red\ orange\ yellow\ green\ blue\ purple\}\n\ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\ \ \ \ \n\ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ rectangle\ \$x1\ \$y1\ \$x2\ \$y2\ \\\n\ \ \ \ \ \ \ \ \ \ -fill\ \$color\ \\\n\ \ \ \ \ \ \ \ \ \ -outline\ black\]\n\ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ \\\n\ \ \ \ \ \ \ \ \ \ -text\ \$text\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \}\n\ \ \n\ \ proc\ clearSelection\ \{canvas\}\ \{\n\n\ \ \ \ #\ if\ there\ is\ an\ existing\ currently\ selected\ box,\ change\ its\ border\ back\ to\n\ \ \ \ #\ black\;\ set\ variables\ selectedid\ and\ selectedtext\ to\ empty\ strings\n\n\ \ \ \ variable\ selectedid\n\ \ \ \ variable\ selectedtext\n\ \ \ \ \n\ \ \ \ if\ \{\$selectedid\ ne\ \"\"\ &&\ \[\$canvas\ find\ withtag\ \$selectedid\]\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \$canvas\ itemconfigure\ \$selectedid\ -outline\ black\n\ \ \ \ \}\n\ \ \ \ set\ selectedid\ \"\"\n\ \ \ \ set\ selectedtext\ \"\"\n\ \ \}\n\ \ \n\ \ proc\ handleSelection\ \{canvas\ id\}\ \{\n\n\ \ \ \ #\ determine\ the\ \"next\ step\"\ by\ comparing\ the\ newly\ selected\ box\ id\ and\ text\n\ \ \ \ #\ to\ the\ box\ id\ and\ text\ of\ the\ previously\ selected\ box\ (contained\ in\n\ \ \ \ #\ the\ variables\ \$selectedid\ and\ \$selectedtext)\n\n\ \ \ \ variable\ ids\n\ \ \ \ variable\ boxes\n\ \ \ \ variable\ selectedid\n\ \ \ \ variable\ selectedtext\n\ \ \ \ \n\ \ \ \ set\ boxid\ \$ids(\$id)\n\ \ \ \ lassign\ \$boxes(\$boxid)\ textid\ text\n\ \ \ \ if\ \{\$boxid\ eq\ \$selectedid\}\ \{\n\n\ \ \ \ \ \ #\ user\ has\ selected\ the\ same\ box\ twice\;\ deselect\ the\ box\n\n\ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ return\n\ \ \ \ \}\ elseif\ \{\$text\ eq\ \$selectedtext\}\ \{\n\n\ \ \ \ \ \ #\ user\ has\ selected\ two\ boxes\ with\ the\ same\ text\;\ delete\ both\ boxes\n\n\ \ \ \ \ \ \$canvas\ delete\ \$boxid\ \$textid\ \$selectedid\ \[lindex\ \$boxes(\$selectedid)\ 0\]\n\ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ return\n\ \ \ \ \}\ else\ \{\n\n\ \ \ \ \ \ #\ user\ has\ selected\ a\ box\ when\ there\ is\ no\ selection,\ or\ user\ has\n\ \ \ \ \ \ #\ selected\ a\ box\ with\ different\ text\ than\ the\ previously\ selected\ box\;\n\ \ \ \ \ \ #\ try\ to\ deselect\ the\ previous\ box,\ then\ select\ the\ new\ box\n\n\ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ set\ selectedid\ \$boxid\n\ \ \ \ \ \ set\ selectedtext\ \$text\n\ \ \ \ \ \ \$canvas\ itemconfigure\ \$boxid\ -outline\ white\n\ \ \ \ \ \ return\n\ \ \ \ \}\n\ \ \}\n\ \ \n\ \ proc\ processClick\ \{canvas\ x\ y\}\ \{\n\n\ \ \ \ #\ determine\ whether\ the\ user\ has\ clicked\ on\ something\;\ if\ so,\ call\n\ \ \ \ #\ proc\ handleSelection\n\n\ \ \ \ set\ id\ \[\$canvas\ find\ overlapping\ \$x\ \$y\ \$x\ \$y\]\n\ \ \ \ if\ \{\[llength\ \$id\]\ >\ 0\}\ \{\n\ \ \ \ \ \ handleSelection\ \$canvas\ \[lindex\ \$id\ 0\]\n\ \ \ \ \}\n\ \ \}\n\ \ \n\ \ set\ win\ \[toplevel\ .demo\]\n\ \ wm\ title\ \$win\ \"Mahjong-style\ deletion?\"\n\ \ set\ canvas\ \[canvas\ \$win.canvas\]\n\ \ pack\ \$canvas\ -expand\ 1\ -fill\ both\n\ \ bind\ \$canvas\ <Button-1>\ \[list\ processClick\ %W\ %x\ %y\]\n\ \ \n\ \ populateCanv\n\n======\n\n----\n!!!!!!\n<<categories>>\ Games\ |\ Toys\ |\ Calculator\ |\ Example\ |\ Syntax\n%|\ \[Category\ Canvas\]\ |%\n!!!!!!\n---- regexp2} CALL {my render Mahjong_Style_Deletion ***Mahjong_Style_Deletion\ ***\n\ \ \nThis\ page\ is\ under\ development.\ Comments\ are\nwelcome,\ but\ please\ load\ any\ comments\ \nat\ the\ bottom\ of\ the\ page.\ Thanks,\ \[gold\]\n\n----\nThis\ page\ uses\ \[Tcl\]8.5\ for\ \[windows\]\ \nto\ develop\ Mahjong_Style_Deletion\ \ .\ \n(note:\ file\ is\ working\ in\ 8.5,but\ you\nmight\ try\ saving\ in\ ANSCII,\ if\ you\ get\ a\ glyph\ compiler\ error\ \ )\nThis\ original\ code\ was\ provided\ by\ \ \ \[aricb\]\ \ \[aricb\]\ \non\ the\ Wiki\ Ask\ page.\ Probably\ \ncould\ start\ a\ wiki\ page,\ since\ it\ is\na\ good\ baby\ game\ engine\ for\ Mahjong\ style\ games.\nI\ added\ a\ few\ buttons\ at\ the\ bottom\nand\ tried\ to\ keep\ the\ clean\ code\ separate\ uptop.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \nIn\ developing\ a\ computer\ program\ or\ application,\nit\ is\ helpful\ to\ develop\ analogs\ \nfor\ the\ individual\ tasks\ of\ the\ application.\n\ \ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n----\n\n***Pretty\ Print\ Version\ ***\n======\n\ \ \ \ \ \ \ \ #\ test\ indent\ from\ ased\ editor\n\ \ \ \ \ \ \ \ #\ written\ on\ Windows\ XP\ on\ eTCL\n\ \ \ \ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ \n\ \ \ \ \ \ \ \ #!/usr/bin/env\ wish\n\ \ \ \ \ \ \ \ package\ require\ Tk\n\ \ \ \ \ \ \ \ \ proc\ populateCanvas\ \{canvas\ cols\ rows\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ \ \ \ \ \ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ \ \ \ \ \ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ set\ boxwidth\ 50\n\ \ \ \ \ \ \ \ \ \ \ \ set\ boxheight\ 20\n\ \ \ \ \ \ \ \ \ \ \ \ set\ padx\ 3\n\ \ \ \ \ \ \ \ \ \ \ \ set\ pady\ 3\n\ \ \ \ \ \ \ \ \ \ \ \ set\ colors\ \{red\ orange\ yellow\ green\ blue\ purple\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\ \ \ \ \ \ \ \ \ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ rectangle\ \$x1\ \$y1\ \$x2\ \$y2\ -fill\ \$color\ -outline\ black\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ -text\ \$text\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ proc\ clearSelection\ \{canvas\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ #\ if\ there\ is\ an\ existing\ currently\ selected\ box,\ change\ its\ border\ back\ to\n\ \ \ \ \ \ \ \ \ \ \ \ #\ black\;\ set\ variables\ selectedid\ and\ selectedtext\ to\ empty\ strings\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedid\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedtext\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$selectedid\ ne\ \"\"\ &&\ \[\$canvas\ find\ withtag\ \$selectedid\]\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$canvas\ itemconfigure\ \$selectedid\ -outline\ black\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ selectedid\ \"\"\n\ \ \ \ \ \ \ \ \ \ \ \ set\ selectedtext\ \"\"\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ proc\ handleSelection\ \{canvas\ id\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ #\ determine\ the\ \"next\ step\"\ by\ comparing\ the\ newly\ selected\ box\ id\ and\ text\n\ \ \ \ \ \ \ \ \ \ \ \ #\ to\ the\ box\ id\ and\ text\ of\ the\ previously\ selected\ box\ (contained\ in\n\ \ \ \ \ \ \ \ \ \ \ \ #\ the\ variables\ \$selectedid\ and\ \$selectedtext)\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ ids\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedid\n\ \ \ \ \ \ \ \ \ \ \ \ variable\ selectedtext\n\ \ \ \ \ \ \ \ \ \ \ \ set\ boxid\ \$ids(\$id)\n\ \ \ \ \ \ \ \ \ \ \ \ lassign\ \$boxes(\$boxid)\ textid\ text\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\$boxid\ eq\ \$selectedid\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ user\ has\ selected\ the\ same\ box\ twice\;\ deselect\ the\ box\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ elseif\ \{\$text\ eq\ \$selectedtext\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ user\ has\ selected\ two\ boxes\ with\ the\ same\ text\;\ delete\ both\ boxes\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$canvas\ delete\ \$boxid\ \$textid\ \$selectedid\ \[lindex\ \$boxes(\$selectedid)\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ user\ has\ selected\ a\ box\ when\ there\ is\ no\ selection,\ or\ user\ has\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ selected\ a\ box\ with\ different\ text\ than\ the\ previously\ selected\ box\;\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ try\ to\ deselect\ the\ previous\ box,\ then\ select\ the\ new\ box\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ selectedid\ \$boxid\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ selectedtext\ \$text\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$canvas\ itemconfigure\ \$boxid\ -outline\ white\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ proc\ processClick\ \{canvas\ x\ y\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ #\ determine\ whether\ the\ user\ has\ clicked\ on\ something\;\ if\ so,\ call\n\ \ \ \ \ \ \ \ \ \ \ \ #\ proc\ handleSelection\n\ \ \ \ \ \ \ \ \ \ \ \ set\ id\ \[\$canvas\ find\ overlapping\ \$x\ \$y\ \$x\ \$y\]\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[llength\ \$id\]\ >\ 0\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ handleSelection\ \$canvas\ \[lindex\ \$id\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ set\ win\ \[toplevel\ .demo\]\n\ \ \ \ \ \ \ \ wm\ title\ \$win\ \"Mahjong-style\ deletion\"\n\ \ \ \ \ \ \ \ set\ canvas\ \[canvas\ \$win.canvas\]\n\ \ \ \ \ \ \ \ pack\ \$canvas\ \ -expand\ 1\ -fill\ both\n\ \ \ \ \ \ \ \ bind\ \$canvas\ <Button-1>\ \[list\ processClick\ %W\ %x\ %y\]\n\ \ \ \ \ \ \ \ set\ state\ 1\n\ \ \ \ \ \ \ \ proc\ mahjongstyle\ \{\ state\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ global\ coloritem\ canvas\ details\n\ \ \ \ \ \ \ \ \ \ \ \ set\ coloritem\ gray\n\ \ \ \ \ \ \ \ \ \ \ \ set\ details\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Mahjong-style\ deletion.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ press\ in\ succession\ two\ tiles\ with\ the\ same\ text.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ both\ tiles\ should\ be\ deleted.\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ The\ Mahjong-style\ deletion\ is\ for\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ right\ mouse\ press.\}\n\ \ \ \$canvas\ create\ window\ 15\ 210\ -window\ \[button\ \$canvas.r\ -width\ 10\ -text\ report\ \\\n\ \ \ \ \ \ -bg\ \$coloritem\ \ \ \ -command\ \{tk_messageBox\ -message\ \$details\}\]\n\ \ \ \$canvas\ create\ window\ 30\ 230\ -window\ \[button\ \$canvas.c\ -width\ 10\ -height\ 1\ -text\ exit\ \\\n\ \ \ -bg\ \$coloritem\ \ \ \ \ -command\ \{exit\ \}\]\ \ \ \ \n\ \ \ \ \ \}\n\ \ \ \ \ \ \ \ mahjongstyle\ \{\ \$state\ \}\n\ \ \ \ \ \ \ \ populateCanvas\ \$canvas\ 4\ 5\n\ \ \ \ \ \ \ \ set\ selectedid\ \"\"\n\ \ \ \ \ \ \ \ set\ selectedtext\ \"\"\n\ \ \ \ \ \ \ \ console\ hide\n======\n----\n***Screenshots***\n\n\[WikiDbImage\ TCL_wiki_Mahjong_Style_Deletion.PNG\]\n\n\n\n\n\n\n\[http://farm5.static.flickr.com/4023/4685677488_29f32589be_s.jpg\]\n\n\n\n\n\n\n\[http://farm5.static.flickr.com/4023/4685677488_29f32589be_m.jpg\]\n\n\n**Comments**\nPlease\ place\ any\ comments\ here,\ Thanks.\n\n\[gold\]\ Change:Redundant\ procedure\ ?\ deleted.\ \n\n\ \ \ \ \n----\n**References**\n\ \ \ *\ http://en.wikipedia.org/wiki/calculators\n\ \ \ *\ Search\ on\ google.com\ for\ \"counting\ rods\"\n\ \ \ *\ http://en.mahjong-zone.com/\n\ \ \ *\ http://home.halden.net/vkp/vkp/mac.html\n\ \ \ *\ http://www.tcl.tk/software/plugin/match.html\n\ \ \ *\ http://www.eiu.edu/~philos/retro/dos/games.htm\n\ \ \ *\ http://www.lcdf.org/xmahjongg/\n\ \ \ *\ http://scien.stanford.edu/class/psych221/projects/99/dmerrill/\n\ \ \ *\ http://www.scriptics.com/\n\ \ \ *\ http://www.photomosaic.com/\n\ \ \ *\ http://opencircuitdesign.com/magic/magic7_2.html\n\ \ \ *\ images\ give\ some\ ideas?\ http://opencircuitdesign.com/magic/giffiles/wind3d.gif\n\ \ \ *\ http://www.karlrunge.com/x11vnc/recurse_x11vnc.jpg\n\ \ \ *\ http://e.irigoyen.home.comcast.net/~e.irigoyen/d3kalphablendingdemo2.jpg\n\ \ \ *\ http://linuxshellaccount.blogspot.com/2008_11_01_archive.html\n\ \ \ *\ Programming\ References\ (\ TCL\ &\ C#\ )***\n\ \ \ *\ \[Base\ conversion\]\n\ \ \ *\ Syntax\ \ \[I\ love\ foreach\]\ \[use\ while\ to\ iterate\ over\ a\ list\]\n\ \ \ *\ \[additional\ list\ functions\],\ \[string\ reverse\],\n\ \ \ *\ \[split\],\ \[list\]\n\ \ \ *\ \[recursive\ list\ searching\]\n\ \ \n\n----\ \n**Appendices**\n***Tables***\n***Auxiliary\ Programs***\n***\ mahjong\ style\ deletion\ in\ tcl,jan20,2009\ ***\n\ \ \ \ \nThis\ question\ has\ been\ pretty\ well\ answered\ and\nclosed\ out.\ I\ have\ posted\ the\ answer\ etc\ in\ a\ \nnew\ wiki\ page.\ \ \nThanks,\[gold\]\n\n\ \[aricb\]\ 2009-1-23:\ Does\ the\ following\ code\ do\ what\ you\ have\ in\ mind?\n\n\ \n\[aricb\]\ The\ code\ doesn't\ use\ any\ special\ 8.5\ features.\ \ It\ sounds\ like\ the\ script\ got\ corrupted\ either\ while\ you\ were\ pasting\ it\ or\ when\ you\ converted\ it\ to\ Unicode.\ \ I\ would\ copy\ and\ save\ the\ script\ one\ more\ time\ (I\ assume\ you\ know\ to\ do\ this\ with\ a\ text\ editor\ rather\ than\ a\ word\ processor).\ \ Save\ it\ using\ your\ default\ system\ encoding\ or\ UTF-8\ (don't\ use\ any\ other\ Unicode\ encoding\ than\ UTF-8).\ \ Look\ at\ the\ saved\ code,\ possibly\ with\ a\ different\ program\ than\ the\ editor\ you\ used\ to\ save\ it,\ to\ make\ sure\ it\ hasn't\ been\ corrupted.\n=====\n\ \ proc\ populateCanvas\ \{canvas\ cols\ rows\}\ \{\n\ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ \n\ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ set\ boxwidth\ 50\n\ \ \ \ set\ boxheight\ 20\n\ \ \ \ set\ padx\ 3\n\ \ \ \ set\ pady\ 3\n\ \ \ \ set\ colors\ \{red\ orange\ yellow\ green\ blue\ purple\}\n\ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\ \ \ \ \n\ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ rectangle\ \$x1\ \$y1\ \$x2\ \$y2\ \\\n\ \ \ \ \ \ \ \ \ \ -fill\ \$color\ \\\n\ \ \ \ \ \ \ \ \ \ -outline\ black\]\n\ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ \\\n\ \ \ \ \ \ \ \ \ \ -text\ \$text\]\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \}\n\ \ \n\ \ proc\ clearSelection\ \{canvas\}\ \{\n\n\ \ \ \ #\ if\ there\ is\ an\ existing\ currently\ selected\ box,\ change\ its\ border\ back\ to\n\ \ \ \ #\ black\;\ set\ variables\ selectedid\ and\ selectedtext\ to\ empty\ strings\n\n\ \ \ \ variable\ selectedid\n\ \ \ \ variable\ selectedtext\n\ \ \ \ \n\ \ \ \ if\ \{\$selectedid\ ne\ \"\"\ &&\ \[\$canvas\ find\ withtag\ \$selectedid\]\ ne\ \"\"\}\ \{\n\ \ \ \ \ \ \$canvas\ itemconfigure\ \$selectedid\ -outline\ black\n\ \ \ \ \}\n\ \ \ \ set\ selectedid\ \"\"\n\ \ \ \ set\ selectedtext\ \"\"\n\ \ \}\n\ \ \n\ \ proc\ handleSelection\ \{canvas\ id\}\ \{\n\n\ \ \ \ #\ determine\ the\ \"next\ step\"\ by\ comparing\ the\ newly\ selected\ box\ id\ and\ text\n\ \ \ \ #\ to\ the\ box\ id\ and\ text\ of\ the\ previously\ selected\ box\ (contained\ in\n\ \ \ \ #\ the\ variables\ \$selectedid\ and\ \$selectedtext)\n\n\ \ \ \ variable\ ids\n\ \ \ \ variable\ boxes\n\ \ \ \ variable\ selectedid\n\ \ \ \ variable\ selectedtext\n\ \ \ \ \n\ \ \ \ set\ boxid\ \$ids(\$id)\n\ \ \ \ lassign\ \$boxes(\$boxid)\ textid\ text\n\ \ \ \ if\ \{\$boxid\ eq\ \$selectedid\}\ \{\n\n\ \ \ \ \ \ #\ user\ has\ selected\ the\ same\ box\ twice\;\ deselect\ the\ box\n\n\ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ return\n\ \ \ \ \}\ elseif\ \{\$text\ eq\ \$selectedtext\}\ \{\n\n\ \ \ \ \ \ #\ user\ has\ selected\ two\ boxes\ with\ the\ same\ text\;\ delete\ both\ boxes\n\n\ \ \ \ \ \ \$canvas\ delete\ \$boxid\ \$textid\ \$selectedid\ \[lindex\ \$boxes(\$selectedid)\ 0\]\n\ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ return\n\ \ \ \ \}\ else\ \{\n\n\ \ \ \ \ \ #\ user\ has\ selected\ a\ box\ when\ there\ is\ no\ selection,\ or\ user\ has\n\ \ \ \ \ \ #\ selected\ a\ box\ with\ different\ text\ than\ the\ previously\ selected\ box\;\n\ \ \ \ \ \ #\ try\ to\ deselect\ the\ previous\ box,\ then\ select\ the\ new\ box\n\n\ \ \ \ \ \ clearSelection\ \$canvas\n\ \ \ \ \ \ set\ selectedid\ \$boxid\n\ \ \ \ \ \ set\ selectedtext\ \$text\n\ \ \ \ \ \ \$canvas\ itemconfigure\ \$boxid\ -outline\ white\n\ \ \ \ \ \ return\n\ \ \ \ \}\n\ \ \}\n\ \ \n\ \ proc\ processClick\ \{canvas\ x\ y\}\ \{\n\n\ \ \ \ #\ determine\ whether\ the\ user\ has\ clicked\ on\ something\;\ if\ so,\ call\n\ \ \ \ #\ proc\ handleSelection\n\n\ \ \ \ set\ id\ \[\$canvas\ find\ overlapping\ \$x\ \$y\ \$x\ \$y\]\n\ \ \ \ if\ \{\[llength\ \$id\]\ >\ 0\}\ \{\n\ \ \ \ \ \ handleSelection\ \$canvas\ \[lindex\ \$id\ 0\]\n\ \ \ \ \}\n\ \ \}\n\ \ \n\ \ set\ win\ \[toplevel\ .demo\]\n\ \ wm\ title\ \$win\ \"Mahjong-style\ deletion?\"\n\ \ set\ canvas\ \[canvas\ \$win.canvas\]\n\ \ pack\ \$canvas\ -expand\ 1\ -fill\ both\n\ \ bind\ \$canvas\ <Button-1>\ \[list\ processClick\ %W\ %x\ %y\]\n\ \ \n\ \ populateCanv\n\n======\n\n----\n!!!!!!\n<<categories>>\ Games\ |\ Toys\ |\ Calculator\ |\ Example\ |\ Syntax\n%|\ \[Category\ Canvas\]\ |%\n!!!!!!\n----} CALL {my revision Mahjong_Style_Deletion} CALL {::oo::Obj3955524 process revision/Mahjong%5FStyle%5FDeletion} CALL {::oo::Obj3955522 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