[Implemented] Allowing Logical Statments in Compiler If
Posted: Sat Feb 03, 2007 11:52 pm
It would be great to allow the CompilerIf Statement to accept all of the logical statments; AND, OR, XOR, NOT
http://www.purebasic.com
https://www.purebasic.fr/english/
CompilerIf can only evaluate expressions with constants, where bit operators &|~! can be used.Dreglor wrote:It would be great to allow the CompilerIf Statement to accept all of the logical statments; AND, OR, XOR, NOT
He knows that, but he wants to use the other operators with constants as well, which is why he posted in this forum.horst wrote:CompilerIf can only evaluate expressions with constants, where bit operators &|~! can be used.Dreglor wrote:It would be great to allow the CompilerIf Statement to accept all of the logical statments; AND, OR, XOR, NOT
AND, OR, XOR, NOT are designed to handle conditions with variables.
Code: Select all
Macro COr(A, B)
((((A)<>0)+((B)<>0))<>0)
EndMacro
Macro CAnd(A, B)
((((A)<>0)+((B)<>0))=2)
EndMacro
Macro CXor(A, B)
((((A)<>0)+((B)<>0))=1)
EndMacro
Macro CNot(A)
((A)<>0)
EndMacro
; #MAX_PATH = 1024 Or #MAX_PATH = 260
CompilerIf COr(#MAX_PATH = 1024, #MAX_PATH = 260)
Debug 1
CompilerElse
Debug 0
CompilerEndIf
; #MAX_PATH = 1024 And #MAX_PATH = 260
CompilerIf CAnd(#MAX_PATH = 1024, #MAX_PATH = 260)
Debug 1
CompilerElse
Debug 0
CompilerEndIf
; #ACK = 6 Or (#BEL = 6 And #SYN = 7)
CompilerIf COr(#ACK = 6, CAnd(#BEL = 6, #SYN = 7))
CompilerEndIf