From: krithiga c. <kri...@ya...> - 2005-12-29 00:18:44
|
hi I have a question about arrays. Basically I have a config file format is # # [DATA FIELDS] #Field_name Display_title Format Format Description sys_part Data here..... ............. [SCREEN_DEFINITIONS] # Data here.... [PRODUCT CODES} data here I need to read these into global arrays one for each section I am able to read teh first part whichis DATA FIELDS and then the next part how do I read between DATA_FIELDS and SCREEN_DEFINITIONS. My code so far: set prodcfg trav_product.cfg puts "I am reading product config file" if { ![catch {set file [open $prodcfg]}] } { set data1 [read $file] close $file set lines [split $data1 "\n"] foreach line $lines { set ptr [string first $line "#"] set arg4 [string range $line $ptr end] set args [string range $line 0 [expr $ptr -1]] set arglist [lindex [split $line :] ] set var [lindex $arglist 0] puts $var set var1 [lindex $arglist 1] set var2 [lindex $arglist 2] set var3 [lindex $arglist 3] if {[regexp SCREEN_DEFINITIONS $arglist]} { break } Please review and let me know what I need to do for the next iteration Thanks krithiga --------------------------------- Yahoo! Photos Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever. |