DAY 040: _TOGGLEBIT
#7
@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$ = ""
Reply


Messages In This Thread
DAY 040: _TOGGLEBIT - by Pete - 12-19-2022, 07:43 PM
RE: DAY 040: _TOGGLEBIT - by mnrvovrfc - 12-19-2022, 08:32 PM
RE: DAY 040: _TOGGLEBIT - by SMcNeill - 12-19-2022, 08:43 PM
RE: DAY 040: _TOGGLEBIT - by mnrvovrfc - 12-19-2022, 09:37 PM
RE: DAY 040: _TOGGLEBIT - by SMcNeill - 12-19-2022, 09:05 PM
RE: DAY 040: _TOGGLEBIT - by Pete - 12-19-2022, 09:17 PM
RE: DAY 040: _TOGGLEBIT - by SMcNeill - 12-19-2022, 09:47 PM
RE: DAY 040: _TOGGLEBIT - by Pete - 12-19-2022, 10:03 PM
RE: DAY 040: _TOGGLEBIT - by SMcNeill - 12-19-2022, 10:22 PM
RE: DAY 040: _TOGGLEBIT - by Pete - 12-19-2022, 10:30 PM
RE: DAY 040: _TOGGLEBIT - by SMcNeill - 12-19-2022, 10:42 PM
RE: DAY 040: _TOGGLEBIT - by bplus - 12-19-2022, 11:20 PM
RE: DAY 040: _TOGGLEBIT - by Pete - 12-19-2022, 11:22 PM
RE: DAY 040: _TOGGLEBIT - by Jack - 12-19-2022, 11:58 PM
RE: DAY 040: _TOGGLEBIT - by Pete - 12-20-2022, 01:11 AM
RE: DAY 040: _TOGGLEBIT - by vince - 12-20-2022, 01:59 AM
RE: DAY 040: _TOGGLEBIT - by OldMoses - 12-20-2022, 03:46 AM



Users browsing this thread: 14 Guest(s)