Menu

#49 Bad example given in "Getting started"

open
nobody
None
5
2008-11-05
2008-11-05
No

In "Evaluating a Tcl command from Java" the following code written:

interp.eval("string length \"" + thestr + "\"");

It is very bad because if thestr="str\";bad_command" will cause error 'invalid command name "bad_command"'.

The right code are the following:

interp.setVar("s", TclString.newInstance(thestr), 0);
interp.eval("string length $s");

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.