12-19-2022, 09:47 PM
@Pete -- Try this example out, and maybe it'll help you wrap your head around the function a little better.
Code: (Select All)
Dim As _Byte a
Input "Press 1 for cat 2 for dog: "; userInput
If userInput = 1 Then a = _ToggleBit(a, 0)
Input "Press 1 for happy 2 for sad: "; userInput
If userInput = 1 Then a = _ToggleBit(a, 1)
Input "Press 1 for black 2 for white: "; userInput
If userInput = 1 Then a = _ToggleBit(a, 2)
If _ReadBit(a, 1) Then Print "happy" Else Print "sad"
If _ReadBit(a, 2) Then Print "black" Else Print "white"
If _ReadBit(a, 0) Then Print "cat" Else Print "dog"
Print
Do
Print
Print
Input "Did your pet's mood change? (y/n) =>"; yn$
If Left$(UCase$(yn$), 1) = "Y" Then a = _ToggleBit(a, 1)
Print
Print
If _ReadBit(a, 1) Then Print "happy" Else Print "sad"
If _ReadBit(a, 2) Then Print "black" Else Print "white"
If _ReadBit(a, 0) Then Print "cat" Else Print "dog"
Loop Until yn$ = ""