AND (boolean)

From QB64 Phoenix Edition Wiki
Revision as of 13:23, 29 April 2022 by RhoSigma (talk | contribs) (Protected "AND (boolean)" ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
Jump to navigation Jump to search

The AND conditonal operator is used to include another evaluation in an IF...THEN or Boolean statement.


Syntax

IF condition AND condition2


Description

  • If condition AND condition2 are true then the evaluation returns true (-1).
  • condition and condition2 can also contain their own AND evaluations.
  • Both the IF evaluation and the AND evaluation must be true for the statement to be true.
  • Statements can use parenthesis to clarify an evaluation.
  • AND (boolean) and OR (boolean) cannot be used to combine command line operations.
  • Not to be confused with the AND and OR numerical operations.


Template:RelationalTable


Examples

Example: Using AND in an IF statement.


a% = 100
b% = 50

IF a% > b% AND a% < 200 THEN PRINT "True"

True

Explanation: Both condition evaluations must be true for the code to be executed.


Example: Using a AND a more complex way.

  
a% = 100
b% = 50
c% = 25
d% = 50
e% = 100

IF (a% > b% AND b% > c%) AND (c% < d% AND d% < e%) THEN
PRINT "True"
ELSE
PRINT "False"
END IF  
True

Explanation: The evaluations in the paranteses are evaluated first then the evaluation of the paranteses takes place, since all evaluations return True the IF...THEN evaluation returns True. If any of the evaluations returned False then the IF...THEN evaluation would also return False.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link