Sunday, January 17, 2016

Finally an If else that make sense

Okay,
this is a continuation to the previous post.

I wasn't happy with the IfElse element.
At start I was trying to decide whether it was better to let ifelse as it was or change it for this:

<If Expression="true">
   <SetText>I will be displayed</SetText>
   <Else>
      <SetText>I won't be played</SetText>
   </Else>
</If>

I'm still not sure this is better than the <IfElse> I described in the previous post.

So, I looked at how Slave Maker does it.
Here's a short excerpt:

<if gender='2'>
   <Question event='CockOutOfHole'>Ask for a cock</Question>
   <else>if</else>
   <Question event='CockOutOfHole'>Ask for a cock</Question>
   <Question event='CockIntoHole'>Stick cock into the hole</Question>
</if>

Well...
This, from my point of view, made even less sense than mine...

So, finally I decided to go with the normal way of doing an if else.
Here's the final version (I think) version:

<If Expression="false">
   <SetText>I wont be displayed</SetText>
</If>
<Else>
   <SetText>I will be displayed</SetText>
</Else>

I had to make a little more work since this was the first time I had to treat two sibling xml nodes as "one step"

Before all elements were evaluated singularly.

Anyway this gave me the opportunity to make an ElseIf too.

<If Expression="false">
   <SetText>I wont be displayed</SetText>
</If>
<ElseIf Expression="true">
   <SetText>I will be displayed</SetText>
</ElseIf>
<Else>
   <SetText>I wont be displayed</SetText>
</Else>

Yay!
I'm pretty happy with this, since it's a lot more natural than the previous solutions.

No comments:

Post a Comment