Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Newbie questions

From: rebol:techscribe at: 2-Oct-2003 13:29

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: