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
ifQuick Reference for "if"
Click on command to see examples & comments
Control Operators and Clauses
Usage: if:condition1:condition2
Description: 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.
:true:1==1
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:Overall condition is True.
elseQuick Reference for "else"
Click on command to see examples & comments
Control Operators and Clauses
Usage: else
Description: Starts an Else Clause which specifies any othe condition contrary to the if statement in the same block.
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:Overall condition is False!!
endifQuick Reference for "endif"
Click on command to see examples & comments
Control Operators and Clauses
Usage: endif
Description: Ends an If block. All endif statements must come with an If statement before it.
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
ifQuick Reference for "if"
Click on command to see examples & comments
Control Operators and Clauses
Usage: if:condition1:condition2
Description: 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.
:false:1==1
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:Overall condition is True.
elseQuick Reference for "else"
Click on command to see examples & comments
Control Operators and Clauses
Usage: else
Description: Starts an Else Clause which specifies any othe condition contrary to the if statement in the same block.
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:Overall condition is False!!
endifQuick Reference for "endif"
Click on command to see examples & comments
Control Operators and Clauses
Usage: endif
Description: Ends an If block. All endif statements must come with an If statement before it.
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
ifQuick Reference for "if"
Click on command to see examples & comments
Control Operators and Clauses
Usage: if:condition1:condition2
Description: 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.
:exists:dom.a.Logout
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:Overall condition is TRUE
elseQuick Reference for "else"
Click on command to see examples & comments
Control Operators and Clauses
Usage: else
Description: Starts an Else Clause which specifies any othe condition contrary to the if statement in the same block.
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:Overall condition is FALSE
endifQuick Reference for "endif"
Click on command to see examples & comments
Control Operators and Clauses
Usage: endif
Description: Ends an If block. All endif statements must come with an If statement before it.
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.