Logical OR of a true/false status of two values
i || j
i, j:function arguments
To test whether either of two conditions is true (or if both are true), use GFA-BASIC 32's logical OR operator ||. The condition is evaluated form left to right. To evaluate to true only one of the conditions must be true. When the first condition is true, the second isn't evaluated.
Dim a% = 10
If a% = 0 || ff() Then Print "Both evaluated"
If a% || ff() Then Print "Only one evaluated"
Function ff() As Int
Return 1
EndFunction
|| is a logical OR operator (and can be replaced by OR) but is not the same as the bitwise OR operators |, or %|. Replacing || with either of these would first evaluate both conditions, which are then bitwise Or-ed. Then the result of the bitwise or operation is tested for true or false, as shown below:
Dim a% = 10, b% = 2
Print a% = 10 Or b% = 5 // Prints -1 (True)
Print a% = 10 || b% = 5 // Prints True
Print a% = 10 %| b% = 5 // Prints False
Print a% = 10 | b% = 5 // Prints False
{Created by Sjouke Hamstra; Last updated: 23/09/2014 by James Gaite}