showif

[showif] is one of the fundamental tools in WebDNA, it is used to show anything required if the comparison is met. Having a good understanding of creating these comparisons will give the WebDNA developer a strong ability to create efficient, meaningful code.

Example WebDNA code:
[showif comparison]Show this content or further WebDNA code[/showif]

WebDNA Comparisons:
ComparisonModulo OperatorExample
equal = [showif [username]=SAGEHEN]Welcome Mr. Sagehen[/showif]
not equal ! [showif [random]!45]......[/showif]
contains ^ [showif [browsername]^Mozilla]......[/showif]
begins with ~ [showif [ipaddress]~245.078.013]......[/showif].
Notice the IP address has been defined with 3 digits in each portion of the address.
This is very important for making comparisons with [ipaddress] to work as expected.
less than  < [showif [random]<50]...[/showif]
greater than  > [showif [lastrandom]>25]...[/showif]
divisible by \ [ShowIf [index]\3]......[/ShowIf]

Comparisons are always case-insensitive so "oranges" equals "ORANGES".

If both side of the equation are numbers, then the comparison for greater than, less than, and equals is performed numerically. If either side is not a number, then the comparison is performed alphabetically.

Using WebDNA comparisons:
Ensure neither side of the comparison equation contains any of the special comparison characters listed in the Comparisons Table above.
[showif [question]=I'm Friendly! Are you?]...[/showif]
This example contains an exclamation point inside the sentence being compared, WebDNA sees this as "I'm Friendly" is not equal to " Are you?=[question]", which is not what the developer meant to compare.
The solution is to wrap each side of the comparison in a [url] context:
[showif [url][question][/url]=[url]I'm Friendly! Are you?[/url]]......[/showif]
This causes any embedded ! = > < symbols to be converted to their URL equivalents, which can then be correctly compared.