Hi ancien Lady,
It is just a work around to implement the NOT statement that is not currently supported by the V108. Of course, the example I gave only supports integer based boolean operation, bit support is not implemented.
Howhever, the advantage I can see is to allow the use of NOT operand until the bug is corrected. When it will be, in the next Tier 1 AppGameKit version I hope, and in order to use the fixed NOT statement, you would have to remove the user not() function and replace only the call to this by regular not statement in the code.
This would allow in advance development taking in account the next defect fixes.
Regarding the fact that compilation is ok and execution also is maybe linked to the fact that, in a case a statement (AND, OR, XOR, ...) is used and, in other one, a function is used.
The signatures are certainly different as function signature would correspond to the function name, the input parameter types and the return type.
I believe it is the reason it actually works as:
- signature(not) <> signature(integer not(integer)).
Below the modified code I took back from previous message in this thread with 'not' and 'and' user defined functions (i.e. I added the and user defined funtion to ensure that an already working statement can be, let say, "overrided" by an user defined function and it is the case).
dice1 as integer
dice2 as integer
do
dice1 = 2
dice2 = 3
print("Regular AND Operand")
printc("0 AND 0 = ")
print((0 AND 0))
printc("0 AND 1 = ")
print((0 AND 1))
printc("1 AND 0 = ")
print((1 AND 0))
printc("1 AND 1 = ")
print((1 AND 1))
print("")
print("User defined AND() function")
printc("0 AND 0 = ")
print(and(0, 0))
printc("0 AND 1 = ")
print(and(0, 1))
printc("1 AND 0 = ")
print(and(1, 0))
printc("1 AND 1 = ")
print(and(1, 1))
print("")
print("User defined NOT() function")
printc("NOT 0 = ")
print(not(0))
printc("NOT 1 = ")
print(not(1))
print("")
print ("Some tests in if branch structure")
print (("Dice1 = " + str(dice1)))
print (("Dice2 = " + str(dice2)))
print("")
print ("Test using user defined NOT() function :")
print("--> if (not((dice1 <> dice2)))")
if (not((dice1 <> dice2)))
print("dice1 = dice2")
else
print("dice1 <> dice2")
endif
print("")
print("---")
print("")
print ("Test using <>")
if (dice1 <> dice2)
print("dice1 <> dice2")
else
print("dice1 = dice2")
endif
Sync()
loop
function not(value as integer)
result as integer
if (value = 0)
result = 1
else
result = 0
endif
endfunction result
function and(val1 as integer, val2 as integer)
result as integer
if (val1*val2 = 1)
result = 1
else
result = 0
endif
endfunction result
Best regards
Michel
Michel