Difference between revisions of "Control:If..Else"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
== Forms == | == Forms == | ||
− | + | === If === | |
− | if <[[LavishScript:Mathematical Formulae|formula]]> | + | '''if''' <[[LavishScript:Mathematical Formulae|formula]]> |
<command or code block> | <command or code block> | ||
This form will conditionally execute the following command or code block. The command or code block '''must''' begin on the following line. The command or code block will be executed if the result of the calculation is ''not'' equal to zero (0), which means it will be ''skipped'' if the result of the calculation is equal to zero (0). | This form will conditionally execute the following command or code block. The command or code block '''must''' begin on the following line. The command or code block will be executed if the result of the calculation is ''not'' equal to zero (0), which means it will be ''skipped'' if the result of the calculation is equal to zero (0). | ||
− | + | === If-Else === | |
− | if <[[LavishScript:Mathematical Formulae|formula]]> | + | '''if''' <[[LavishScript:Mathematical Formulae|formula]]> |
<command or code block> | <command or code block> | ||
− | else | + | '''else''' |
<command or code block> | <command or code block> | ||
This form extends the previous form by adding a second command or code block, which executes only when the first one does not execute. This literally means "if something, then do this, otherwise do that". | This form extends the previous form by adding a second command or code block, which executes only when the first one does not execute. This literally means "if something, then do this, otherwise do that". |
Revision as of 01:24, 13 September 2005
Contents
Forms
If
if <formula> <command or code block>
This form will conditionally execute the following command or code block. The command or code block must begin on the following line. The command or code block will be executed if the result of the calculation is not equal to zero (0), which means it will be skipped if the result of the calculation is equal to zero (0).
If-Else
if <formula> <command or code block> else <command or code block>
This form extends the previous form by adding a second command or code block, which executes only when the first one does not execute. This literally means "if something, then do this, otherwise do that".
Examples
if x == 5 { if y == 6 z:Set[17] } else z:Set[20]