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: Tue Jan 03 2006 - 01:38:59 CET

Gerald
  Thanks for your reply. The config file does not look like the one you
had mentioned. It looks like below
DATA_FIELDS

Field_name Display_title Format Reg expression Format
Description
Data here..............
.............

SCREEN_DEFINTIONS(has 3 fields in this)
Data here...........

PRODUCT CODES
..........

PRODUCT MODELS

Data here............

So I need to put all these 4 sections into 4 arrays and then access
them by the first field which is different for each of the sections. I
did add a code for each of the data to separate the sections but have
to remove this in code as other procedures in the program call by this
name. Without adding a code for each section for the data is there a
way to put these in arrays?

  Also I used parray for lookup but for eg for the first section if I
needed only the third field then I had to create 2 arrays one for
third field and one for fourth field to access them outside the
procedure. If I use lindex it says name is an array. How to use parray
to lookup each of the fields.

This is my code
 set arglist [lindex [split $line :] ]

 if {[regexp DF $arglist]} {

                    set df [lindex $arglist 0]
                                 set df [string trimleft $df "DF "]
                                 set df [string trimright $df]
                                 puts $df
                                  set df1 [lindex $arglist 1]
                                  set df1 [string trimright $df1
                                  ]
                                  set df2 [lindex $arglist 2]
                                  set df2 [string trimright $df2]

                         set df3 [lindex $arglist 3]
                         set df3 [string trimright $df3]

                   set DATF [lappend myarray($df) [list $df1 $df2 $df3]]
             set lookup($df) [list $df2]
             set lookup1($df) [list $df3]

In the lookup I had to create 2 arrays to loop them up by 2nd and third
field. How else would I do this?

Thanks
krithiga
Gerald W. Lester wrote:
> krithiga81@yahoo.com wrote:
> > Gerald
> > Thanks. I checked the inifile package and it is for opening ini
> > files. My config file is a plain text file where there are section
> > which I need to have arrays for each section and then access the
> > elements in the arrays based on an index. Also I need to pass these to
> > another procedure. How do I accomplish this? I have put my code I have
> > so far.
>
> From what you posted, I thought your configuration files look like:
>
> [OPTIONS]
> LASTFILE=0
> LICENSE=yes
> LASTRECORD=.
>
> Is that not correct?
Received on Tue Jan 3 03:10:09 2006