How to combine variable


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89

    Unhappy How to combine variable

    My variable is

    B0 var byte
    B1 var byte
    B2 var byte
    C0 var byte

    B0 = 1
    B1 = 2
    B2 = 3



    I want C0 = 123
    ( C0 = B0 B1 B2 )


    -------------------

    C0 = B0 DIG 1
    C0 = B1 DIG 2
    C0 = B1 DIG 3

    Not working ????

    in pbp manual, 4.17.7 , example is to Extraction, not combine.

    .

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    B0 = 1
    B1 = 2
    B2 = 3



    I want C0 = 123
    ( C0 = B0 B1 B2 )
    Try this

    C0 = (B0*100)+(B1*10)+B2

    or you can do it like this
    C0 = B0*10
    C0 = (C0+B1)*10
    C0 = (C0+B2)

    Happy Easter
    Jerson

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    'putting it together
    B0=1
    B1=2
    B2=3
    C0=B0*100+B1*10+B2 ' C0=123

    taking it apart
    C0 = 456
    B0=CO DIG 0 ' B0 = 6
    B1=C0 DIG 1 ' B1 = 5
    B2=C0 Dig 2 ' B2 = 4
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Default

    Thanks Jerson
    Thanks paul borgmeier

    its working.

    Thanks

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 21:16
  5. Storing a variable in EEPROM
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th October 2005, 13:53

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