Page 1 of 1

Search for Operator

Posted: Sat Oct 07, 2006 9:22 pm
by Konne
Is there an Operator which Switches a 1 into a 0 and a 0 into a 1?

It should do the same than this code:

Code: Select all

      If Value=1
        Value=0
      Elseif Value=0
        Value=1      
      EndIf

Posted: Sat Oct 07, 2006 9:24 pm
by netmaestro
Best available in PureBasic is a=1-a

Posted: Sat Oct 07, 2006 11:38 pm
by jack

Code: Select all

Value = Value XOr $FFFFFFFF

Posted: Sun Oct 08, 2006 12:37 am
by SCRJ

Code: Select all


a = 1

a ! 1
Debug a
a ! 1
Debug a

Posted: Mon Oct 09, 2006 3:03 pm
by blueb
Perhaps the Swap command is what you're looking for.

Posted: Mon Oct 09, 2006 4:13 pm
by naw
this would be the NOT operator, wouldnt it?

Posted: Mon Oct 09, 2006 4:25 pm
by Joakim Christiansen
SCRJ wrote:

Code: Select all


a = 1

a ! 1
Debug a
a ! 1
Debug a
I think this methos is the best :wink:

Posted: Mon Oct 09, 2006 4:35 pm
by einander
; some macros to switch values

Code: Select all

Macro Switch_1_0(n)  ;  switch between  1 and  0
    1-n
EndMacro

Macro Switch_0_Minus1(n)  ;  switch between -1 and 0
 n!-1
EndMacro

Macro Switch_1_2(n) ;switch  between 1 and 2
 3 - n
EndMacro

Posted: Tue Oct 10, 2006 7:39 pm
by Froggerprogger