Get a bit or set a bit


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    440

    Default Get a bit or set a bit

    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

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    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?

    Code:
    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

  3. #3
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I haven't tried it, but -

    Variable.0[X] = Y

    Should work
    Charles Linquist

  5. #5
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default

    Variable.0[X] = Y
    Works fine!

    Norm

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts