webDOMinator - Minion Scripting Language Reference

Search a Command:
<< Back to Control Operators and Clauses

if

Usage...
if:condition1:condition2

Starts an IF block. condition1 can be either (true, false, exists, !exists, empty, or !empty) where !exists and !empty mean "doesn't exist" and "isn't empty".

condition2 is a condition specified by conditional operators (<<, >>, ==, !=, <=, >=, , and ) if condition1 is set to true or false.

If condition1 is set to empty, or exists, condition2 need only include a DOM element property or variable.

An example would be: "if:exists:dom.a.1" or "if:true:dom.a.1.innerhtml==foo" or even "if:false:foodom.a.1.innerhtml". There are many ways to use the two conditional statements to specify the condition needed.

All if statements must come with a following endif statement.

This applies to webDOM version 2.0.0 and above.

User Comments on if

Some exceptions

Written by: webDOMinator 2 years and 2 months ago

Here are some ways you might think to use the if command which do not compute to webDOM... for instance, if you try to use the "exists" for condition one with the "<in>" in condition two you will run into a big mess. When using the <in> condition you should only use true or false for condition1.

Playing with the two conditionals

Written by: webDOMinator 2 years and 5 months ago

The minion if statements have two conditionals for easy switching of the overall condition... the first condition can be: true, false, exists, !exists, empty, and !empty.

The first condition and the second condition together make an overall outcome condition which will be either true or false.

An example of playing with true/false switching would be:

Code
if:true:1==1
echo:Overall condition is True.
else
echo:Overall condition is False!!
endif

This works out to true because the first condition is true and the second condition is true. But lets say you wanted to test if 1==1 was false.... which, yes, one equals one, so that's going to be true...
Code
if:false:1==1
echo:Overall condition is True.
else
echo:Overall condition is False!!
endif

The overall condition is now false because even though the second condition is true, the first condition is false because we set it to false.

This is just one way you can use the if statements to switch what webdom does by just changing the first condition. Another example would be if you wanted to use the exists and !exists first conditions. When using this first condition... the second condition does not have to be a comparison. The second condition is actually just treated as an argument. For instance. If I wanted to see if there was a link on the page that said "Logout" I could use the method below:
Code
if:exists:dom.a.Logout
echo:Overall condition is TRUE
else
echo:Overall condition is FALSE
endif

Ofcourse, you can change what you do based off of the conditions, you don't always have to use an echo. This is just an example. The opposite of the "exists" condition is "!exists" so you would just change the first condition to get an opposite result and webDOM would tell you that the overall condition is false when the Logout link does actually exist.

Example 1

Written by: webDOMinator 2 years and 5 months ago

This example echoes out a confirmation if it finds the text "Memphis" (case sensitive) in the body of the current page.

Code
if:true:Memphis<in>dom.body.1.innerhtml
echo:The user is from Memphis!
endif

Post a Comment About the "if" Command
Title:
Comment:
Post as Anonymous:
User Login
Username:
Email:
Password:
webDOMinator is copyright ©2008, 2009, 2010, 2011, 2012 Nathaniel D. Gibson. All Rights Reserved.
Contact | Tutorials | Forum
By using webDOMinator you are taking all liability in to your own hands. Nathaniel D. Gibson is not responsible for any damages, loss, or defamation (legal or otherwise) caused to you or your business from using this program. Nathaniel D. Gibson is not associated with, affiliated with, nor responsible for the content submitted and displayed by users of this site.