Revision history for KeyPgOpAndAlso


Revision [22084]

Last edited on 2018-01-27 11:12:08 by JeffMarshall [add additional explanation of the short-circuit behaviour]
Additions:
The truth table below demonstrates all combinations of a short circuit-and operation, the '-' denotes that the operand is not evaluated.
Short-circuiting is performed - only expressions needed to calculate the result are evaluated. The left hand side ##//lhs//## is evaluated first, and only if it evaluates to non-zero (true) is the right hand side ##//rhs//## also evaluated. If the left hand side evaluation ##//lhs//## returns zero (false), it is known that at that point that the overall condition is false, so the right hand side ##//rhs//## is not evaluated (skipped).
Deletions:
The truth table below demonstrates all combinations of a short circuit-and operation, the '-' denotes that the operand is not evaluated. The left hand side ##//lhs//## is evaluated first, and only if it evaluates to non-zero (true) is the right hand side ##//rhs//## also evaluated. If the left hand side evaluation ##//lhs//## returns zero (false), it is known that at that point that the overall condition is false, so the right hand side ##//rhs//## is not evaluated (skipped).
Short-circuiting is performed - only expressions needed to calculate the result are evaluated.


Revision [22082]

Edited on 2018-01-27 11:08:59 by JeffMarshall [add additional explanation of the short-circuit behaviour]
Additions:
The truth table below demonstrates all combinations of a short circuit-and operation, the '-' denotes that the operand is not evaluated. The left hand side ##//lhs//## is evaluated first, and only if it evaluates to non-zero (true) is the right hand side ##//rhs//## also evaluated. If the left hand side evaluation ##//lhs//## returns zero (false), it is known that at that point that the overall condition is false, so the right hand side ##//rhs//## is not evaluated (skipped).
Deletions:
The truth table below demonstrates all combinations of a short circuit-and operation, the '-' denotes that the operand is not evaluated.


Revision [20999]

Edited on 2016-03-13 05:05:07 by fxm [Formatting]

No Differences

Revision [20349]

Edited on 2016-02-10 16:03:34 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **""AndAlso""** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T1//, [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] //T2// ) [[KeyPgAs|as]] //Ret//
The return type is almost always an ##[[KeyPgInteger|Integer]]##, of the value ##0## or ##-1##, denoting false and true respectively. Except if the left and right-hand side types are both ##[[KeyPgBoolean|Boolean]]##, then the return type is also ##[[KeyPgBoolean|Boolean]]##.
0, 1, 1, 0, 1, 0, 1, 0, 0, 0 _
- ##[[KeyPgOpOrElse|OrElse]]##
- ##[[KeyPgOpAnd|And]]##
- [[TblTruth|Operator Truth Tables]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **""AndAlso""** ( [[KeyPgByref byref]] //lhs// [[KeyPgAs as]] //T1//, [[KeyPgByref byref]] //rhs// [[KeyPgAs as]] //T2// ) [[KeyPgAs as]] //Ret//
The return type is almost always an ##[[KeyPgInteger Integer]]##, of the value ##0## or ##-1##, denoting false and true respectively. Except if the left and right-hand side types are both ##[[KeyPgBoolean Boolean]]##, then the return type is also ##[[KeyPgBoolean Boolean]]##.
0, 1, 1, 0, 1, 0, 1, 0, 0, 0 _
- ##[[KeyPgOpOrElse OrElse]]##
- ##[[KeyPgOpAnd And]]##
- [[TblTruth Operator Truth Tables]]


Revision [17789]

Edited on 2015-09-12 08:24:34 by FxMwikki [Added the case for a boolean return type]
Additions:
The return type is almost always an ##[[KeyPgInteger Integer]]##, of the value ##0## or ##-1##, denoting false and true respectively. Except if the left and right-hand side types are both ##[[KeyPgBoolean Boolean]]##, then the return type is also ##[[KeyPgBoolean Boolean]]##.
Deletions:
The return type is always an ##[[KeyPgInteger Integer]]##, of the value ##0## or ##-1##, denoting false and true respectively.


Revision [17779]

Edited on 2015-09-12 07:27:17 by FxMwikki [Added conversion of Booleans to Integers]
Additions:
This operator evaluates the left hand side expression. If the result is zero, then zero is immediately returned. If the result is nonzero then the right hand side is evaluated, and the logical result from that is returned.
(for conversion of a boolean to an integer, false or true boolean value becomes 0 or -1 integer value)
Deletions:
This operator evaluates the left hand side expression. If the result is zero, then zero is immediately returned. If the result is nonzero then the right hand side is evaluated, and the logical result from that is returned.


Revision [17764]

Edited on 2015-09-12 04:46:05 by FxMwikki [Added boolean type]
Additions:
Any numeric or boolean type.
Any numeric or boolean type.
A numeric or boolean type (varies with ##//T1//## and ##//T2//##).
Deletions:
Any numeric type.
Any numeric type.
An Integer.


Revision [16809]

Edited on 2013-05-15 17:00:07 by CountingPine [More useful example]
Additions:
'' Using the ANDALSO operator to guard against array access
'' when the index is out of range
dim as integer isprime(1 to 10) = { _
_ ' 1 2 3 4 5 6 7 8 9 10
0, 1, 1, 0, 1, 0, 1, 0, 0, 0 _
}
dim as integer n
input "Enter a number between 1 and 10: ", n
'' isprime() array will only be accessed if n is in range
if (n >= 1 and n <= 10) andalso isprime(n) then
print "n is prime"
else
print "n is not prime, or out of range"
end if
Deletions:
' Using the ANDALSO operator on two numeric values
DIM AS INTEGER numeric_value1, numeric_value2
numeric_value1 = 15
numeric_value2 = 30
'Result = -1
PRINT numeric_value1 ANDALSO numeric_value2
SLEEP


Revision [16807]

Edited on 2013-05-15 16:49:36 by CountingPine [Formatting, clearer table (not bitwise)]
Additions:
This operator evaluates the left hand side expression. If the result is zero, then zero is immediately returned. If the result is nonzero then the right hand side is evaluated, and the logical result from that is returned.
{{table columns="3" cellpadding="2" cells="Lhs Value;Rhs Value;Result;0;-;0;nonzero;0;0;nonzero;nonzero;-1"}}
The return type is always an ##[[KeyPgInteger Integer]]##, of the value ##0## or ##-1##, denoting false and true respectively.
Deletions:
This operator evaluates the left hand side expression. If the result is zero, then zero is immediately returned. If the result is non zero then the right hand side is evaluated, and the logical result from that is returned.
{{table columns="3" cellpadding="2" cells="Lhs Value;Rhs Value;Result;0;-;0;1;0;0;1;1;1"}}
The return type is always an Integer, of the value 0 or -1, denoting false and true respectively.


Revision [15723]

Edited on 2012-01-17 11:56:05 by CountingPine [Link to And]
Additions:
- ##[[KeyPgOpAnd And]]##


Revision [13415]

The oldest known version of this page was created on 2008-05-31 16:16:39 by JeffMarshall [Link to And]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode