35 lines
1.2 KiB
Plaintext
35 lines
1.2 KiB
Plaintext
*!* Visual FoxPro natively supports short circuit evaluation
|
|
CLEAR
|
|
CREATE CURSOR funceval(arg1 L, arg2 L, operation V(3), result L, calls V(10))
|
|
*!* Conjunction
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.F., .F., "AND")
|
|
REPLACE result WITH (a(arg1) AND b(arg2))
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.F., .T., "AND")
|
|
REPLACE result WITH (a(arg1) AND b(arg2))
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.T., .F., "AND")
|
|
REPLACE result WITH (a(arg1) AND b(arg2))
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.T., .T., "AND")
|
|
REPLACE result WITH (a(arg1) AND b(arg2))
|
|
*!* Disjunction
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.F., .F., "OR")
|
|
REPLACE result WITH (a(arg1) OR b(arg2))
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.F., .T., "OR")
|
|
REPLACE result WITH (a(arg1) OR b(arg2))
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.T., .F., "OR")
|
|
REPLACE result WITH (a(arg1) OR b(arg2))
|
|
INSERT INTO funceval (arg1, arg2, operation) VALUES (.T., .T., "OR")
|
|
REPLACE result WITH (a(arg1) OR b(arg2))
|
|
GO TOP
|
|
|
|
_VFP.DataToClip("funceval", 8, 3)
|
|
|
|
FUNCTION a(v As Boolean) As Boolean
|
|
REPLACE calls WITH "a()"
|
|
RETURN v
|
|
ENDFUNC
|
|
|
|
FUNCTION b(v As Boolean) As Boolean
|
|
REPLACE calls WITH calls + ", b()"
|
|
RETURN v
|
|
ENDFUNC
|