Skip to content
Tcl Source Code Artifact [53e3d3bbb1]
Login

Artifact [53e3d3bbb1]

Artifact 53e3d3bbb14c247f41fa577236343f2bcf36c9dc:

Ticket change [53e3d3bbb1] - New ticket [217994ffffffffff|217994ffff] <i>Null expressions</i>. by nobody on 2000-10-26 00:51:47.
D 2000-10-26T00:51:47
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s639\sBug\nVersion:\s8.0\nSubmitDate:\s'1998-05-25'\nLastModified:\s'1999-08-14'\nSeverity:\sMED\nStatus:\sClosed\nSubmitter:\shershey\nChangedBy:\shobbs\nOS:\sAll\nOSVersion:\sNA\nMachine:\sNA\nFixedDate:\s'2000-10-25'\nFixedInVersion:\sNA\nClosedDate:\s'1999-08-14'\n\n\nConsider\sthe\sfollowing\scommands\sin\sTCL\s8.0p2:\n\n%\sexpr\s8\s+\s""\nsyntax\serror\sin\sexpression\s"8\s+\s"\n%\sexpr\s""\s+\s8\n8\n%\n%\sexpr\s""\s>\s10\nsyntax\serror\sin\sexpression\s"\s>\s10"\n%\sif\s{\s""\s>\s10\s}\s{\sputs\strue\s}\s\selse\s{\sputs\sfalse\s}\nfalse\n\n\nGranted,\sthe\sabove\scode\sis\ssomewhat\sstrange,\sbut\srealize\sthat\sthe\s""\ncould\sbe\sthe\sreturn\sresult\sof\sany\sother\scommand\ssuch\sas:\n\nif\s{\s[\smyCustomCmd\sarg1\sarg2\s]\s>\s10\s}\s{\sputs\strue\s}\n\n\nIn\sgeneral,\sthe\sfact\sthat\sTCL\sdoes\snot\shandle\sNULL\svalues\sin\sits\nexpression\sevaluation\scauses\stremendous\sheadaches.\n\nTCL\shandles\sNULL\sSTRINGS\ssuch\sas:\n\nstring\sindex\s""\s9\n\nBut\sreturns\serrors\swhenever\sa\sNULL\svalue\sis\sencountered\sin\san\nexpression.\n\nMany\slanguages\swill\ssimply\sreturn\sNULL\sif\san\sexpression\ncontains\sany\stype\sof\sNULL\svalue\sin\sit.\s\sIt\swould\sbe\svery\snice\sif\nTCL\swould\sdo\sthe\ssame.\n\nI\shave\screated\sa\sGUI\sbuilder\sthat\suses\sTCL\sas\sits\sscripting\nlanguage.\s\sEach\sfield\son\smy\sscreen\scan\shave\sTCL\smethods\sassociated\nwith\sit.\s\sWe\shave\sextended\sTCL\sto\sprovide\sa\s"getfld"\sand\sa\n"setfld"\scommand\sthat\sretrieves/sets\sthe\svalue\scontained\sin\sthe\sfield\non\sthe\sscreen.\sWe\swould\slike\sto\ssimply\swrite\scode\sas\sappears\sbelow:\n\nsetfld\sField1\s[\sexpr\s[\sgetfld\sField2\s]\s+\s[\sgetfld\sField3\s]\s]\n\nUnfortunately,\swe\shad\sto\screate\sanother\scommand\scalled\s"checkfld"\nthat\sfirst\smakes\ssure\sthe\sfield\sis\snot\sNULL\sbefore\sattempting\sto\nevaluate\sthe\sexpression:\n\nif\s{\s[checkfld\sField2\sField3]\s}\s{\n\s\s\ssetfld\sField1\s[\sexpr\s[\sgetfld\sField2\s]\s+\s[\sgetfld\sField3\s]\s]\n}\nelse\s{\n\s\s\ssetfld\sField1\s""\n}\n\nThis\smight\snot\sseem\stoo\sbad\sbut\sits\salot\sof\swork\sto\ssimply\sadd\n2\snumbers\stogether\sand\sit\smeans\sthat\severy\ssingle\stime\swe\nrefer\sto\sa\sfield\son\sour\sGUI\swe\sneed\sto\sfirst\smake\ssure\sits\snot\nNULL.\n\nWe\scould\smodify\sour\scode\sto\snot\sallow\sNULL\svalues\son\sour\sscreen\nand\sforce\sall\snumeric\sfields\sto\szero\sbut\sthis\swould\snot\smake\sa\nvery\sfriendly\sGUI\s-\syou\sneed\sto\sallow\sblank\snumeric\sfields\son\nany\sGUI.\n\nWe\shave\salso\snoticed\sthat\sthe\sexpr\s""\s+\s8\scommand\sbehaves\sdifferently\nbetween\sTCL\s7.3\sand\sTCL\s8.0.\n\nSo\smy\squestion\sis:\n\nWhy\snot\schange\sthe\sexpr\scommand\sto\sreturn\sa\sNULL\svalue\swhen\sany\nargument\sin\sits\sexpression\slist\sis\sNULL?\s\sOther\scommands\sthat\ntake\sexpressions\ssuch\sas\s"if\s{\sexpression\s}\s"\scould\seasily\nbe\swritten\sto\smake\sNULL\sexpressions\sbehave\sthe\ssame\sas\sFALSE\nexpressions.\n\nThank\syou\sfor\sreading\sthis\sfar.\s\sPlease\slet\sme\sknow\sif\sthere\sis\nany\shope\sfor\sthis\srequest.\n\n\nChris\sHandorf\n602-914-8116\nMotorola\sSPS\nPhoenix,\sAZ\[email protected]\n\nThese\sare\sprogramming\smisunderstandings.\s\sThe\schanges\sto\sexpr\nare\swell\sdefined\sin\sthe\sporting\sdocs,\sand\sexpr\sexpressions\sshould\nnow\salways\sbe\s{}ed\sfor\sproper\sevaluation\s(and\sspeed).\nThe\serror\sreporting\sis\scorrect.\s\sFor\seach\scase:\n\n\s\s%\sexpr\s8\s+\s""\n\s\ssyntax\serror\sin\sexpression\s"8\s+\s"\n\nHere\sthe\suser\sreceives\san\serror\sbecause\sthe\sbinary\sop\s+\sis\sunsatisfied\n\n\s\s%\sexpr\s""\s+\s8\n\s\s8\n\nHere\sthe\suser\sisn't\susing\sbraces,\sso\sthe\sTcl\slevel\sof\seval\sconverts\nthis\sto\sjust\s"+\s8",\sand\sthen\sexpr\suses\sthe\s+\sas\sa\sunary\sop.\n\n\s\s%\sexpr\s""\s>\s10\n\s\ssyntax\serror\sin\sexpression\s"\s>\s10"\n\n>\sis\snever\sa\sunary\sop...\n\n%\sif\s{\s""\s>\s10\s}\s{\sputs\strue\s}\s\selse\s{\sputs\sfalse\s}\nfalse\n\nThis\sworks,\sbecause\sthe\sinitial\suse\sof\sa\sstring\sis\skicking\sthis\ninto\sthe\sstring\scomparison\smode.\s\sA\scommand\sshould\snot\sbe\sused\nin\sthis\sway\sif\sit\sisn't\sguaranteed\swhat\stype\sof\sarg\swould\sbe\nreceived.\s\sUse\sstring\scompare/equal\sor\sfix\sthe\scommand.\s\n--\s08/14/1999\shobbs
J foundin obsolete:\s8.0
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 69.\sOther
J title Null\sexpressions
J type Bug
K 217994ffffffffffffffffffffffffffffffffff
U nobody
Z 6480a04deb21077f665fe540950251dc