Difference between revisions of "IF"

From QB64 Wiki
Jump to navigation Jump to search
imported>SMcNeill
m (Text replacement - "IDE" to "IDE")
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
'''IF''' statements make Boolean True or False program evaluations to automate program decision making.
+
#REDIRECT [[IF...THEN]]
  
  
 +
[[IF]] statements make Boolean True or False program evaluations to automate program decision making.
  
<center>''Syntax:'' IF evaluation is true THEN execute code</center>
+
{{PageSyntax}}
 +
: [[IF]] evaluation [[THEN]] {{Parameter|{code}}}
  
* The evaluation by '''IF''' must be true for the THEN code to be run.
+
* The evaluation by [[IF]] must be true for the {{Parameter|{code}}} to be run.
 
* IF statements can also have alternative evaluations using [[ELSEIF]] and [[ELSE]] conditions.  
 
* IF statements can also have alternative evaluations using [[ELSEIF]] and [[ELSE]] conditions.  
* When the '''IF''' statement and/or code to be run is more than code line, an [[END IF]] statement '''MUST''' be used.
+
* When the '''IF''' statement and/or code to be run is more than one line of code, an [[END IF]] statement must be used.
 
* With multiple code lines to run, end the IF statement with THEN and place all of the code on lines below that line.
 
* With multiple code lines to run, end the IF statement with THEN and place all of the code on lines below that line.
* With multiple code lines to run (a IF...END IF block), the IF statement and END IF statement must be the first statement on the line!
+
* With multiple code lines to run (an [[IF...END IF]] block), the IF statement and END IF statement must be the first statement on the line.
* The [[IDE]] may point to an [[ERROR Codes|error]] in a loop or somewhere else if you forget to use END IF (typically a ''PROGRAM FLOW ERROR!'' message).
+
* The IDE may point to an [[ERROR Codes|error]] in a loop or somewhere else if you forget to use END IF (typically a ''PROGRAM FLOW ERROR!'' message).
* Use colons to change multiple values in a one line IF statement. You cannot use AND on the other side of THEN!
+
* Use [[colon]]s to execute multiple statements after [[THEN]].
  
  
''See also:'' [[IF...THEN]]
+
{{PageSeeAlso}}
 +
[[IF...THEN]]
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Latest revision as of 02:06, 20 April 2020

Redirect to:

IF statements make Boolean True or False program evaluations to automate program decision making.

Syntax

IF evaluation THEN {code}
  • The evaluation by IF must be true for the {code} to be run.
  • IF statements can also have alternative evaluations using ELSEIF and ELSE conditions.
  • When the IF statement and/or code to be run is more than one line of code, an END IF statement must be used.
  • With multiple code lines to run, end the IF statement with THEN and place all of the code on lines below that line.
  • With multiple code lines to run (an IF...END IF block), the IF statement and END IF statement must be the first statement on the line.
  • The IDE may point to an error in a loop or somewhere else if you forget to use END IF (typically a PROGRAM FLOW ERROR! message).
  • Use colons to execute multiple statements after THEN.


See also

IF...THEN



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page