Bob X wrote:

I am using 2.4.9.3 on Windows XP with ActiveTcl.

I am creating a simple ticket tracker and I defined my view:

set view [mk::view layout db.tracker "username:S ticket:S recieved:I closed:I problem:S notes:S status:I"]

I then append into the view:

mk::row append $view username "Jeff Walsh" ticket "000001081" recieved "20040419" closed "20040419" problem "Password locked" notes "Reset password to Ellipse" status "0"

I then get errors:

<error>
expected integer but got "000001058" (looks like invalid octal number)
while executing
"mk::row append $view username "Don Lang" ticket "000001058" recieved "20040409" closed "20040409" problem "Application is hanging" notes "Network prob..."
(file "initial_loader.tcl" line 18)
</error>

Yes, leading zero's bite when treating a Tcl string as an integer. I'm assuming the "ticket:S" is actually a "ticket:I" in the example you gave - then it would fail.


The leading zero defaulting to octal mode is a painful idiosyncrasy of Tcl, see
http://mini.net/tcl/498
http://www.tcl.tk/cgi-bin/tct/tip/114.html


I could change it to a String (works that way) but I would like to leave it an Integer. Are the leading zero's causing the problem? I have to have those as the program spitting the data out uses those.

You can't have your cake and eat it in cases like these :) - either you treat values as integers (which have no knowledge of representation, such as leading zero's) or you stick to a string, which is slower and takes up more space.


I tend to use either of two tricks for this:

- add 1000000000 to the value and store that
  (then strip 1st char again on extract to make sure the 0's stay)

- convert to int via ... ticket [scan %d "000001058"] ...
  (and convert back as needed with: "puts [format %9d $value]")

-jcw

_____________________________________________
Metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to