hideif
[hideif] along with its counterpart [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:
Example WebDNA code:
[hideif comparison]Hide this content or further WebDNA code[/hideif]
[hideif] works in exactly the same way as [showif] but in reverse.WebDNA Comparisons:
Working with long numbers:
Using this example: [hideif 147854924874287509390=147854924874287504050]display this text[/hideif]
you would expect that the returned result would not show the text display this text, however due to the length of the number and the limitations of the sscan() C library the hideif fails.
Comparison | Modulo Operator | Example |
---|---|---|
equal | = | [hideif [username]=SAGEHEN]You are not Mr. Sagehen[/hideif] |
not equal | ! | [hideif [random]!45]......[/hideif] |
contains | ^ | [hideif [browsername]^Mozilla]......[/hideif] |
begins with | ~ | [hideif [ipaddress]~245.078.013]......[/hideif]. 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 | < | [hideif [random]<50]...[/hideif] |
greater than | > | [hideif [lastrandom]>25]...[/hideif] |
divisible by | \ | [hideif [index]\3]......[/hideif] |
Working with long numbers:
Using this example: [hideif 147854924874287509390=147854924874287504050]display this text[/hideif]
you would expect that the returned result would not show the text display this text, however due to the length of the number and the limitations of the sscan() C library the hideif fails.
Using double quotes around the comparison and input values in the same manner as used in [if] will force WebDNA to treat the values as a string.
[hideif "147854924874287509390"="147854924874287504050"]display this text[/hideif]
thus ensuring the the text does display