July 2010
Intermediate to advanced
588 pages
13h 25m
English
In some cases, you may decide not to use any additional packages, yet you will need to save some data for future usage. In Tcl, it is easy to store data structures like lists or dictionaries in flat text file.
First, let's demonstrate how to write to and read from a list:
set book1 [list {Learning Nagios 3.0} 978-1-847195-18-0]
set book2 [list {Tcl Network Programming} 978-1-849510-96-7]
set books [list $book1 $book2]
puts [lindex [lindex $books end] 0]
set channel [open data.txt w]
puts $channel $books
close $channel
set channel [open data.txt r]
set books [read $channel]
close $channel
puts [lindex [lindex $books end] 0]
books variable is a list of two lists, each one containing the title and ISBN number, respectively. ...
Read now
Unlock full access