[Gambas-user] config file issue

Rob sourceforge-raindog2 at ...94...
Tue Apr 12 15:36:41 CEST 2005


On Tuesday 12 April 2005 05:31, Thomas Mathiesen wrote:
> I need to get info from a .conf file like this->
> dev tun
> proto tcp
> ...
> To do this, I have been using the backtick and (g)awk.
> This works for some time, but suddenly backtick stops working.

Speaking as the guy who wrote the backtick function (which could 
probably use some refinement), I'd love to see a project where it 
fails to work so I can find the bug in my function.  Could you send 
one?

Also, rather than using awk and backtick, it looks to me like you 
should  really be doing

dim s as string
dim t as string
dim pair as new string[]
dim c as new collection

s = file.load("/path/to/config/file")
for each t in split(s, "\n")
	pair = split(t, " ")
        c[pair[0]] = pair[1]
next

Of course, you'd need to make c a public variable rather than using 
DIM if you want to use it throughout your project.

Rob








More information about the User mailing list