Page 2 of 2

Posted: Tue Jan 16, 2007 9:25 pm
by AND51
Sorry, I still don't understand... Are you aming at this Macro given in the german help?

Code: Select all

  Macro Is(Bool) 
    (0 Or (Bool)) 
  EndMacro 
Kaeru, you're welcome to wite a PM, if neccessary.

Posted: Tue Jan 16, 2007 9:27 pm
by Trond
AND51 wrote:Unfortunately, I don't really understand...? Can you explain it in other words again and/or give me an example code?
Ok, these are the rules:
Relational operators are: <, >, =, >=, <=, <>
Boolean operators are: And Or Not Xor
The result of relational and boolean operators can only be given to If, While, Until, And, Or, Not, ElseIf or XOr. This means you can't do ((a=b)+2) because then result of the relational operator is given to the + operator.

Forbidden:
A = B = C ; The result of B = C is not given to If, While, Until, And, Or, Not, ElseIf or XOr.

if (B = C) * D ; The result of B = C is given to the * operator, which is not on this list: If, While, Until, And, Or, Not, ElseIf, XOr.

Allowed:
IF B = C * D ; Multiply, then compare and use the result of the comparision in the IF statement.

IF B = C And B = D ; The result of the ='s are given to AND, the result of the AND is given to the IF.

Posted: Tue Jan 16, 2007 9:31 pm
by AND51
Ah ok, thanks a lot! Now I understand! :D

however, this means that calculating with bools is not possible...

Posted: Tue Jan 16, 2007 9:41 pm
by Kaeru Gaman
that's right, Trond.

@AND

1. to some Macro you can not only pass Numbers, but Expressions.
to shut this expressions it MUST be enclosed in Brackets.

2. adding a Compare-Operator to some closed Expression will make the new term a Boolean Expression.
A Boolean Expression ALWAYS have to be enclosed in brackets,
to tell the Compiler its an Expression and not a Comparison.

3. In PB there is a trick: a Boolean Expression can work, if you add a Boolean Operation.
as Freak already said: this is a Trick!
you can't claim any support for a trick.

4. This new Expression should also be enclosed in Brackets.

this should tell you, that you left out much too much Brackets, so no wonder your Code doesn't work.

and I repeat once more:
It is a TRICK, not a Feature!

[edit]
...forgot the "-"...
it doesn't work with StrQ().

Code: Select all

Macro XAbs(Exp) 
  ((Exp)*((((Exp)>0) Or 0)*2-1))
EndMacro

a.l = -512874

Debug XAbs(a)

b.l = XAbs(a)

Debug Str(b)

Posted: Tue Jan 16, 2007 10:19 pm
by Trond
>calculating with bools is not possible...
You understood it right, it's exactly what I said (except I had to use a bit more space to say it)! :lol: