View Full Version : Get a bit or set a bit
Normnet
- 2nd April 2010, 04:45
Is their an easier way to get a bit or set a bit in a variable?
I can use select case but something like the following would be nice.
For i = 7 to 0 step -1
x = varBYTE[i]
next
'or
For i = 7 to 0 step -1
x = varBYTE.i
next
For i = 7 to 0 step -1
varBYTE[i] = x
next
'or
For i = 7 to 0 step -1
varBYTE.i = x
next
Norm
rsocor01
- 2nd April 2010, 05:12
Normnet,
I can use select case but something like the following would be nice.
You can use some of the code that you posted. Except that I would do the increment from 0 to 7 instead of the other way. But, all depends on what you are trying to do. What exactly are you trying to do?
VAR X BIT[8]
For I = 0 to 7
X[I] = varBYTE.I
next
For I = 0 to 7
varBYTE.I = X[I]
next
Robert
Normnet
- 2nd April 2010, 05:52
What exactly are you trying to do?
Bitbang.
Works OK with select case but not with posted code.
Need to get each bit from a send byte and set pin to TX or
read a pin and set a bit in receive byte to RX.
I would do the increment from 0 to 7
Bitbang sends/reads bit 7 first.
Norm
Charles Linquis
- 2nd April 2010, 06:05
I haven't tried it, but -
Variable.0[X] = Y
Should work
Normnet
- 2nd April 2010, 06:31
Variable.0[X] = Y
Works fine!
Norm
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.