Thursday, January 22, 2009

One problem Solved - Deleting item in a TCL list

Last night, I get the solution for deleting tcl list item. Actually this solution can be found in tcl manual. It is my mistake for take things easy and misunderstood the behaviour of lreplace command.

Deleting a list item in a tcl list is actually straight forward. But of course quite confusing.

Originally my procedure to delete list item is like this ( not the right one - of course):

proc ldelete { list item} {

# get the index,ix for item in tcl list
set ix [lsearch -exact $list $item]
#ix is greater then zero if the item is in the lsit
if {$ix>=0} {
# replace the item at index ix until index ix with nothing (aka - delete the item)
lreplace $list $ix $ix
else {
return $list


At around 11.00 pm last night i found out that the error is actually at the command:
"lreplace $list $ix $ix"
The command delete list item at index ix and returns the modified list but without updating it.

So the solution is simply like this.

set list [lreplace $list $ix $ix]

I'm very happy today! More programming !A lot to learn!

BTW, Thanks taufiq for helping me transferring the computers from IP-tech lab to WSN lab.

Wednesday, January 21, 2009

A slow restart

Starting yesterday I start doing serious programming again! But what a very slow restart. Most of my time was spent on looking at my previous coding. And trying to re-understand it!

Its have some bug which I'm trying to solving. Trouble-shooting works take a lot of time. I got a feeling that I can solve it. Let see In this 2, 3 days, can I do it or not!

If given a buggy program which one is your choice?
1. Trouble shoot the program.
2. Get brief idea of what the program intend to do, and write own program.

Make your choice and tell me why.

BTW, TQ sifu taufiq for helping me last night.

Tuesday, January 20, 2009

Start Programming Again!!

My busy schedule hindered me from serious coding for last three months! And now I'm pushing myself to sit in front of my HP Pavilion laptop.

I'm accompanied by:

1. A cup of coffee ( Thanks Abe Su for the 3 in 1 coffee)
2. TCL\TK books - Practical Programming in TCL\TK for my reference
3. Logbook - contains my thought and ideas
4. Used or "conteng-conteng" paper and a pen to layout my thought and ideas
5. My U-Mobile Broadband connection for internet connectivity

Keep looking forward!!