Yes, this is the fastest. I wrote a function that uses offset() rather extensively.
They both work well, but this one here is about 36% faster. It's also more intuitive 
than mine.
(Note that the line "put 1 into state" below should read "put True into groupFound")

Also thanks to Dave Cragg as well as Phil Davis for your suggestions. I learned 
something from each of your approaches that I didn't know before.

Thanks!
--Leston

>>>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<<<

To:             [EMAIL PROTECTED]
From:           Ruediger zu Dohna ([EMAIL PROTECTED])
Subject:                Re: parsing a INI formatted file

Hi!

I have not tried it, but propably something like the following is the fastest:

function getIniValue theFile,theGroup,theKey
   put false into groupFound
   repeat for each line aLine in url ("file:"&theFile)
     if not groupFound then
       if aLine is "["&theGroup&"]" then
         put 1 into state
       end if
     else
       -- use token here, so whitespace can be ignored.
       if token 1 of aLine is theKey and token 2 of aLine is "=" then
         return token 3 to -1 of aLine
       end if
       if char 1 of aLine is "[" then -- another group!!!
         exit repeat
       end if
     end if
   end repeat
   return empty
end getIniValue


Regards
   R�diger
--------------------------------------------------------------------
| Ruediger zu Dohna   GINIT GmbH   0721-96681-63    [EMAIL PROTECTED] |
| PGP-Fingerprint: F1 BF 9D 95 57 26 48 42 FE F8 E8 02 41 1A EE 3E |
--------------------------------------------------------------------


------------------------------
Leston Drake
LetterPress Software, Inc.
http://www.lpsoftware.com
------------------------------

Reply via email to