[ic] Nested ELSIFs
Grant
listbox at email.com
Tue Sep 2 21:00:19 EDT 2003
> At 04:02 PM 9/2/2003 -0700, you wrote:
> >After running into a strange problem in my code, I've done some
> testing and
> >found what seems like a bug to me. After narrowing it down, the
> following
> >seems to be the simplest correct expression of the code that
> causes the bug:
> >
> >***
> >[if scratch variable]
> >[elsif !scratch variable]
> >[then]
> > [if scratch variable]
> > [elsif !scratch variable]
> > CORRECT
> > [/elsif]
> > [/if]
> >[/then]
> >[/elsif]
> >[/if]
> >***
> >
> >Running that code returns nothing on the screen. Naming the parameters
> >doesn't help. Is it a bug, or are nested elsifs just not allowed?
> >
> >- Grant
>
> Really not sure why you would write a conditional test which executes the
> same code whether a condition is true or false - doesn't seem to be much
> point in that.
The above is just an example I was trying to make as simple as possible.
All I was trying to convey was that the screen should print "CORRECT", and
it doesn't.
>
> In any case, the correct syntax would be:
>
> [if scratch variable]
> [then]
> [if scratch whatever eq this]
> ....
> [elsif scratch whatever eq that]
> ...
> [/elsif]
> [/if]
> [/then]
> [elsif !scratch variable]
> [if value something]
> ...
> [/if]
> [/elsif]
> [/if]
What if you reverse the content of the ifs in your example like this:
[if scratch variable]
[then]
[if value something]
...
[/if]
[/then]
[elsif !scratch variable]
[if scratch whatever eq this]
...
[elsif scratch whatever eq that]
...
[/elsif]
[/if]
[/elsif]
[/if]
The syntax is still correct right? But, if you test it like this:
[tmp whatever]that[/tmp]
[if scratch variable]
[then]
[if value something]
number 1
[/if]
[/then]
[elsif !scratch variable]
[if scratch whatever eq this]
number 2
[elsif scratch whatever eq that]
number 3
[/elsif]
[/if]
[/elsif]
[/if]
"number 3" should print to the screen but you get "number 2" instead.
- Grant
>
> ...hope you get the idea. Also, this is the correct syntax, but
> it is quite
> possible that it could break depending upon conditions - functionality in
> all circumstances is not guaranteed.
>
> I know that [if] went through some re-coding in 4.8, and as a result the
> use of [then] is rarely required.
>
> - Ed L.
More information about the interchange-users
mailing list