Script Library: 1213 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Discussion posts for script parse-ini.r

1
robiandi
3-Feb-2007 15:09
parse-ini-file: it works in the following way:

1.) At the beginning of a new section the last section will be
    appended to the ini-block. But because the last section has no successor
    it will not be appended to it. 
    Therefore the last section of a Windows ini file is lost for the 
    script ( this is a bug).

2.) As explained in the documentation, a Windows ini file has the 
    structure:
    [section-name1]
    keyword1=somevalue

    The following is not allowed:
    [section-name1]
    keyword1 = somevalue
    keyword2= othervalue

    i.e. spaces are not permitted ( not a bug, but not fine )
2
sunanda
4-Feb-2007 14:11
Edited:
sunanda
4-Feb-2007 14:12

Thanks!

[1] Good catch -- now fixed in new version.

[2] Spaces can be more problematic. For example, my live win.ini has this entry....

 [fontsubstitutes]
 Albertus (W1)=Albertus Medium 

....Both the keyword and the value contain spaces.

It may be that the strict spec for an INI entry forbids a trailing space on the keyword, and a leading space on the value.

If so, then this script is being a little more flexible than the strict spec would allow.

3
mikehinson
13-Apr-2009 20:36
Hi,
Newbie here, so sorry if posting in the wrong place.


I am trying to use this script to help me understand the use of parsing 
to extract data from files. If I paste the script into my REBOL/View 
console it pastes in the script ok, but the examples do not work.


This seems very common with a lot of the scripts in this library 
and is a problem I have been fighting with for several days.

This is what I get.
>> ini: parse-ini-file %/c/windows/win.ini
** Script Error: Out of range or past end
** Where: parse-ini-file
** Near: append last current-section parsed-line/1
append
>> 


If anyone can direct me to a better place to ask questions it would 
be appreciated. I have tried to use AltME but I don't know of any 
way to get invited to the REBOL world.

Thanks, Mike
4
mikehinson
13-Apr-2009 21:55
5
sunanda
15-Apr-2009 8:31

Apologies for the bug. sqlab did a quick analysis and showed I'd failed to properly consider comment lines.

He also contributed the fix so (thanks to him again) the version in the Libary is now updated and should work better.

The full discussion of the bug is on the REBOL3 AltME world: here  and here. 

Notes