Concatenation


Closed Thread
Results 1 to 8 of 8

Thread: Concatenation

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    968


    Did you find this post helpful? Yes | No

    Default Re: Concatenation

    Code:
    If PortB.0 = 1 Then 'monitor PortE.2 for beam break
       DataIn2 = DataIn2<<1 'Move bit one place to left to concatinate variable
       DataIn2 = DataIn2 + 1 'something blocking beam, write a 1 to DataIn2 variable
    Else 
       DataIn2 = DataIn2<<1
       DataIn2 = DataIn2 + 0 'Beam clear, write a 0 to DataIn2 variable
    EndIf
    How about doing it this way?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Concatenation

    Hi,
    Adding to (or removing from actually...) Jersons example, this should let you get rid of the IF/THEN construct as well
    Code:
    DataIn2 = (DataIn2 << 1) + PortB.0   ' Move bits one step to the left and add state of PortB.0 to the least significant bit.
    /Henrik.

  3. #3
    Join Date
    Dec 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Concatenation

    Many thanks Jerson, just swapping the lines over did the trick. I really sacrificed at the alter of stupidity this week!
    HenrikOlsson, i did not know you could do this. Should save some space and speed things up.
    Many thanks to both of you for your time, really saved my sanity.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    968


    Did you find this post helpful? Yes | No

    Default Re: Concatenation

    You're welcome. We have all been there(the altar of stupidity) at some time in our lives, haven't we?

  5. #5
    Join Date
    Dec 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: Concatenation

    Hi Jerson / HenrikOlsson,

    Not sure what happened to my spelling this week either. 'alter' - what is wrong with me! Maybe i should get checked for early onset Alzheimers - ah, maybe not, i can spell Alzheimers!
    Having looked through my code, I've realised (English spelling), that concatenation is spelled incorrectly as well, argghhh! Maybe it's the wine - surely not - it can't be the wine - oh god , not the wine!!

    P.S. HenrikOlsson, thanks again, that one line of code is beautiful - did i spell that correctly, phew!

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