Unless

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "= Unless...ElseIf...Else...EndIf = === Description === Conditionally run statements. <pre> Unless <expression> Then statements ... [ElseIf expression-n Then [else...")
 
Line 1: Line 1:
= Unless...ElseIf...Else...EndIf =
+
= Unless...Else Unless...Else  =
  
 
=== Description ===
 
=== Description ===
Line 6: Line 6:
  
 
<pre>
 
<pre>
Unless <expression> Then
+
Unless(<expression>)
 +
{
 
     statements
 
     statements
 
     ...
 
     ...
[ElseIf expression-n Then
+
}
     [elseif statements ... ]]
+
Else If(expression-n)
 +
{
 +
     else if statements
 
     ...
 
     ...
[Else
+
}
     [else statements]
+
Else Unless(expression-n)
 +
{
 +
     else if statements
 
     ...
 
     ...
EndIf
+
}
 +
Else
 +
{
 +
    else statements
 +
    ...
 +
}
 
</pre>
 
</pre>
  
Line 22: Line 32:
 
==== expression  ====
 
==== expression  ====
  
If the expression is false, the first statement block is executed. If not, the first true ElseIf block is executed. Otherwise, the "Else" block is executed.
+
If the expression is false, the first statement block is executed. If not, the first true Else If block is executed or the first false Else Unless block is executed. Otherwise, the "Else" block is executed.
 +
 
 +
All the Else If, Else Unless and Else blocks are optional.
  
 
=== Remarks ===
 
=== Remarks ===
Line 28: Line 40:
 
Unless statements may be nested.
 
Unless statements may be nested.
  
An Unless is bascially just a negative IF therefor anything that would be TRUE for an If will be FALSE for an Unless.
+
Its worth noting you can use Else Ifs and Else Unless together with no problem.
  
The expression can contain the boolean operators of AND, &&, OR, ||, NOT, ! as well as the logical operators <, <=, >, >=, ==, ==, and <> as needed.
+
The expression can contain the boolean operators of AND, &&, OR, ||, NOT, ! as well as the logical operators <, <=, >, >=, ==, ==, and <> as needed grouped with parentheses as needed.
  
 
=== Example ===
 
=== Example ===
  
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
Unless $a == 100 Then
+
Unless($a == 100)
println( "Value is 100" )
+
{
ElseIf $a == 200 Then
+
println( "Value is NOT 100" );
println( "Value is 200" )
+
}
Else
+
Else If($a == 200)
println( "No Match" )
+
{
EndIf
+
println( "Value is 200" );
</syntaxhighlight>
+
}
 
+
Else Unless($a == 44)
Example of using the logical NOT or ! operator:
+
{
 
+
println( "Value is NOT 44" );
<syntaxhighlight lang="sputnik">
+
}
Unless NOT $a == 100 Then
+
println( "Value is 100" )
+
ElseIf $a == 200 Then
+
println( "Value is 200" )
+
 
Else
 
Else
println( "No Match" )
+
{
EndIf
+
println( "No Match" );
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 20:57, 16 November 2011

Contents

Unless...Else Unless...Else

Description

Conditionally run statements.

Unless(<expression>)
{
    statements
    ...
}
Else If(expression-n)
{
    else if statements
    ...
}
Else Unless(expression-n)
{
    else if statements
    ...
}
Else
{
    else statements
    ...
}

Parameters

expression

If the expression is false, the first statement block is executed. If not, the first true Else If block is executed or the first false Else Unless block is executed. Otherwise, the "Else" block is executed.

All the Else If, Else Unless and Else blocks are optional.

Remarks

Unless statements may be nested.

Its worth noting you can use Else Ifs and Else Unless together with no problem.

The expression can contain the boolean operators of AND, &&, OR, ||, NOT, ! as well as the logical operators <, <=, >, >=, ==, ==, and <> as needed grouped with parentheses as needed.

Example

Unless($a == 100)
{
	println( "Value is NOT 100" );
}
Else If($a == 200)
{
	println( "Value is 200" );
}
Else Unless($a == 44)
{
	println( "Value is NOT 44" );
}
Else
{
	println( "No Match" );
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox