Today's task is now completed. Its now possible to inquire what groups are present in the .ini file and what they keynames are. The final step is to remove entries and to close any open files. The next steps are to review the syntax and to add the documentation.
Here's the test-script:
#---------------
# test-keyfile.tcl
#---------------
# William J Giddings, 28/12/2010
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"
package require Gnocl
set kf1 [gnocl::keyFile load sample_config.ini]
puts "1 [$kf1 get value -group Person -key name]"
puts "2 [$kf1 get value -key name -group Person ]"
puts "3 [$kf1 get value -group Person -key name]"
puts "4 [$kf1 get value -key name -group Person ]"
puts "5 [$kf1 get integer -key age -group Person ]"
puts "6 [$kf1 get value -key sex -group Person ]"
puts "6 [$kf1 get value -key sex -group Person -locale UK ]"
puts "7 [$kf1 get comment -group Person -key name ]"
$kf1 set comment -group Person -key name -value "HIDI HI, HO DI HO!! HEHE"
$kf1 set value -group NEW -key ENTRY -value HAPPY_CHRISTMAS
puts [$kf1 write sample_config.ini]
puts GROUPS>>[$kf1 get groups]
puts KEYS>>[$kf1 get keys -group Person]
puts KEYS>>[$kf1 get keys -group "Another Group"]
set name [$kf1 get value -group Person -key name]
gnocl::window -setSize 0.25 -child [gnocl::label -textVariable name]
# remove functionality
$kf1 remove group NEW
$kf1 remove group NEW -key ENTRY
$kf1 remove comment Person -key name
$kf1 set comment -group Person -key sex -value "THIS IS A NEW COMMENT"
puts [$kf1 write sample_config.ini]
Here's the test-script:
#---------------
# test-keyfile.tcl
#---------------
# William J Giddings, 28/12/2010
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"
package require Gnocl
set kf1 [gnocl::keyFile load sample_config.ini]
puts "1 [$kf1 get value -group Person -key name]"
puts "2 [$kf1 get value -key name -group Person ]"
puts "3 [$kf1 get value -group Person -key name]"
puts "4 [$kf1 get value -key name -group Person ]"
puts "5 [$kf1 get integer -key age -group Person ]"
puts "6 [$kf1 get value -key sex -group Person ]"
puts "6 [$kf1 get value -key sex -group Person -locale UK ]"
puts "7 [$kf1 get comment -group Person -key name ]"
$kf1 set comment -group Person -key name -value "HIDI HI, HO DI HO!! HEHE"
$kf1 set value -group NEW -key ENTRY -value HAPPY_CHRISTMAS
puts [$kf1 write sample_config.ini]
puts GROUPS>>[$kf1 get groups]
puts KEYS>>[$kf1 get keys -group Person]
puts KEYS>>[$kf1 get keys -group "Another Group"]
set name [$kf1 get value -group Person -key name]
gnocl::window -setSize 0.25 -child [gnocl::label -textVariable name]
# remove functionality
$kf1 remove group NEW
$kf1 remove group NEW -key ENTRY
$kf1 remove comment Person -key name
$kf1 set comment -group Person -key sex -value "THIS IS A NEW COMMENT"
puts [$kf1 write sample_config.ini]
Comments