Re: Arrays
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Arrays

From: <krithiga81@yahoo.com>
Date: Sat Dec 24 2005 - 07:37:48 CET

Hi
  I explained in a previous message how I was reading in the info from
config file I had three sections. Can you suggest how this can be
implemented?

Thanks
krithiga
Bryan Oakley wrote:
> krithiga81@yahoo.com wrote:
> > Hi
> > I also tried this in my code
> >
> > 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 [array get $lines ] {
> > ...
> > It does not come into the foreach loop
>
> lines is not an array; it is a list. Moreover, when you do [array get
> $lines] it looks for an array with the name that matches all of the
> contents of your file.
>
> This will work:
>
> set data1 [read $file]
> close $file
> foreach line [split $data1 \n] {
> <your code here>
> }
Received on Tue Jan 3 03:09:07 2006