Hi Kai.

For "the most elegant way" I would direct you to Gabriele ;-).

A workable way would be:
given the ini file

name1="value1"
name2=640
name3=SVGA

Let's assume we are looking for the value of name3:

We need to convert the ini file into something that can be conveniently 
processed under REBOL, for instance a block.  The final expression could 
look something like this:

select make block! replace/all read %IniFile.ini "=" " " 'name3

1. We read the contents of the file IniFile.ini  
... read %IniFile.ini
The percent sign is needed to tell REBOL IniFile.ini is a file name.
'read returns  a string.

2. Since we will want to use select (see help select for details) we 
want to rid of the '=' signs and replace them by a space.
... replace/all ... "=" " "
(see help replace for details on replace/all)

3. We use the string returned by replace to create a block.
... make block!  replace/all ...

4. Now we can retrieve the value associated with name3 by using select:
select  make block! ... 'name3
Note that we must use the literal word 'name3  We cannot use name3, 
since REBOL would believe it to be a word, and attempt to look up the 
value of name3.
Hope this helps.

Elan



Kai Peters wrote:

>Hi all ~
>
>just stumbled upon REBOL yesterday and have started writing my first min-app
>and the following questions
>have come up thus far:
>
>what is the most elegant way to read a value out of an ini file?
>
>tried to find some docs on error handling but thus far have not succeeded -
>is there anything out there?
>
>how do i know that a read from ftp succeeds and how do i know which error
>occured if it fails?
>
>Thanks for all input
>
>Kai
>
>  
>


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to