[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] IC ITL if conditions
Hi,
this mail is just for information. I'm sure all you know it, but
maybe someone searches the archives for such questions later :)
keywords: if else scratch tmp cgi value conditions evaluation
Just some simple notes about if's.
If you have a scratch like
[set var]0[/set]
then [if scratch var] will return false (since 0 is false).
Example:
[set x]0[/set]
[if !scratch x]!x (true)[/if] <br>
[if scratch x != 0]x != 0[/if] <br>
[if scratch x == 0]x == 0 (true)[/if] <br>
[if scratch x eq ""]x eq ""[/if] <br>
would render:
!x (true) (since it's zero == false)
x == 0 (true) (numeric equal)
zero is non-equal "" of course.
But see that with a empty one:
[set x][/set]
[if !scratch x]!x (true)[/if] <br>
[if scratch x != 0]numeric: x != 0[/if] <br>
[if scratch x == 0]numeric: x == 0 (true)[/if] <br>
[if scratch x eq ""]text: x eq "" (true)[/if] <br>
[if scratch x ne ""]text: x ne ""[/if] <br>
!x (true) (since it has noe true value, like num != 0 or any
text)
numeric: x == 0 (true)
(AFAIK any word including the null-word is numeric zero)
text: x eq "" (true)
(This is also true if x is not even defined)
It seems that you cannot distinguesh between empty and
non-defined, but it shouldn't be possible on clean pages :)
Well, I don't know how to use CGI's in if. The value isn't
working. A simple work-around:
[tmp search_word][cgi search_word][/tmp]
[tmp search_mode][cgi search_mode][/tmp]
[comment]
The next comments are visible in the HTML code sent to browser.
[/comment]
<!-- scratch search_mode '[scratch search_mode]' -->
<!-- scratch search_word '[scratch search_word]' -->
[if scratch search_mode ne ""]
<!-- cgi search_mode set -->
[/if]
Remember, [tmp] are similar like scratch, but are not stored for
the session (only valid for the request). The [tmp] is the same
like [seti] IIRC (which means, that it interpolates by default).
So you can write:
[tmp sql_condition]
( lower(words) like lower('%[cgi search_word]%') )
[/tmp]
How to force scratches to be defined, if they can be numeric
zero? I used constructions like:
[if scratch addressedit_allowed eq ""]
[set addressedit_allowed]1[/set]
[/if]
If you would use [if !scratch hide_price], it would overwrite
numeric zeros alway (here: to one).
oki,
Steffen
--
Dieses Schreiben wurde maschinell erstellt,
es trägt daher weder Unterschrift noch Siegel.