Page 1 of 1

[Implemented] Allowing Logical Statments in Compiler If

Posted: Sat Feb 03, 2007 11:52 pm
by Dreglor
It would be great to allow the CompilerIf Statement to accept all of the logical statments; AND, OR, XOR, NOT

Re: Allowing Logical Statments in Compiler If

Posted: Tue Feb 06, 2007 4:17 pm
by horst
Dreglor wrote:It would be great to allow the CompilerIf Statement to accept all of the logical statments; AND, OR, XOR, NOT
CompilerIf can only evaluate expressions with constants, where bit operators &|~! can be used.

AND, OR, XOR, NOT are designed to handle conditions with variables.

Re: Allowing Logical Statments in Compiler If

Posted: Tue Feb 06, 2007 4:55 pm
by Trond
horst wrote:
Dreglor wrote:It would be great to allow the CompilerIf Statement to accept all of the logical statments; AND, OR, XOR, NOT
CompilerIf can only evaluate expressions with constants, where bit operators &|~! can be used.

AND, OR, XOR, NOT are designed to handle conditions with variables.
He knows that, but he wants to use the other operators with constants as well, which is why he posted in this forum.

You can emulate them using macros:

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