# .ini file iterator returning wrong value for repeated keys

**URL:** https://www.finalbuilder.com/forums/t/ini-file-iterator-returning-wrong-value-for-repeated-keys/2732
**Category:** Bugs
**Created:** [December 13, 2006, 6:34am UTC](https://www.finalbuilder.com/forums/t/ini-file-iterator-returning-wrong-value-for-repeated-keys/2732 "2006-12-13T06:34:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [December 13, 2006, 6:34am UTC](https://www.finalbuilder.com/forums/t/ini-file-iterator-returning-wrong-value-for-repeated-keys/2732/1 "2006-12-13T06:34:21Z")

</div>

Say you have an ini file like this:[Section]Key=Value1Otherkey=fooKey=Value2And you iterate over this with nested ini file iterators assigning to variables %key% and %value%, you’ll get these %key%/%value% pairs:Key/Value1Otherkey/fooKey/Value1I don’t know if repeated keys are technically valid, but they sure are handy 🙂 (if they worked correctly :))Steve

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [December 13, 2006, 6:39am UTC](https://www.finalbuilder.com/forums/t/ini-file-iterator-returning-wrong-value-for-repeated-keys/2732/2 "2006-12-13T06:39:36Z")

</div>

Steve,  
  
FYI: INI keys must be unique. If there is more that one key, then when retrieving the value associated with that key, the first listed value is returned. This is standard INI behavior.  
  
The 2 easiest solutions are use unique keys (Key1, Key2, etc) or use a CSV line on a single key (ie Key=Value1,Value2,etc)

---

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [December 14, 2006, 2:27am UTC](https://www.finalbuilder.com/forums/t/ini-file-iterator-returning-wrong-value-for-repeated-keys/2732/3 "2006-12-14T02:27:04Z")

</div>

I understand that they should be unique when requesting a value, but FB is actually happy to iterate over repeated values - it just returns the wrong key value.  
  
I know that I’m horribly abusing what .ini files are for, I’m actually using .ini syntax to write a quasi programming language. I’ll use the first solution above…  
  
Steve

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [December 14, 2006, 3:29am UTC](https://www.finalbuilder.com/forums/t/ini-file-iterator-returning-wrong-value-for-repeated-keys/2732/4 "2006-12-14T03:29:51Z")

</div>

Hi Steve,  
  
If you want that kind of expressability, you may want to look into creating a simple XML file. XML with XPath is perfect for this kind of thing. FinalBuilder has solid support for these technologies, as well.  
  
- Angus
