LavishSettings iterate through settings

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
alsdk
Non-Subscriber
Posts: 4
Joined: Fri Jan 11, 2008 5:32 pm

LavishSettings iterate through settings

Post by alsdk » Sun Apr 11, 2010 9:54 am

Hello all,

first of all i have a file like this:

/* People.xml */
<?xml version='1.0' encoding='UTF-8'?>
<!-- Generated by LavishSettings v2 -->
<InnerSpaceSettings>
<Set Name="People">
<Set Name="Alfred">
<Setting Name="age">21</Setting>
<Setting Name="gender">male</Setting>
<Setting Name="weight">65</Setting>
</Set>
<Set Name="Peter">
<Setting Name="age">22</Setting>
<Setting Name="gender">male</Setting>
<Setting Name="weight">50</Setting>
</Set>
</Set>
</InnerSpaceSettings>


and i need to know Name through age, gender or weight.
I went into this code to try to know Name (Alfred) through his age (21):

/* PeopleInfo.iss */
function main()
{
variable string CONFIG_FILE = "People.xml"
variable string NAME = "People"

LavishSettings:Import[${CONFIG_FILE}]
echo ${CONFIG_FILE}

variable iterator PeepIterator
LavishSettings[${This.NAME}]:GetSetIterator[PeepIterator]

if ${PeepIterator:First(exists)}
{
do
{
if ${PeepIterator.Value.FindSetting[age, NOTSET]} == 21
{
echo ${PeepIterator.Key}
}
}
while ${PeepIterator:Next(exists)}
}

echo "nothing found"
}

People.xml and PeopleInfo.iss are both in same dir, appearantly i cant get a valid iterator for my settings (PeepIterator) and also im not sure if this its a correct way to do this, so please if anyone have any clue about this or can help pointing me in the right direction i would appreciate that.

Greets

both files can be downloaded at pastebin:
http://pastebin.org/146977
http://pastebin.org/146978

Post Reply