Let a variable change from bin to dec.
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Location
    Sweden
    Posts
    9

    Question Let a variable change from bin to dec.

    Hi all !

    I tried the attached listning from Rentron.

    I tried to do compare a variable decimaltemp with a defined value of 25 and the varable TempC.

    The problem is that tempC is a binary and not the uservariable.

    I want to set variable decimaltemp = dec (TempC) but have'nt found any function for that.

    It is possible to do such function in serout serout2 and lcdout but not to a variable.....?

    What am i missing ?

    Rentron listning:
    http://www.rentron.com/PicBasic/one-wire3.htm

    Brgds Roy

  2. #2
    d1camero's Avatar
    d1camero Guest

    Default

    I am not sure I understand, but I will try anyways. Variable "decimaltemp" is a word which contains the ASCII representation of some number (e.g. 25). Is this correct? And you want to compare it to variable "TempC" which has the binary value of the temperature. Correct? If so, you need to convert the ASCII value in var "decimaltemp" to a binary value.

    To convert a to digit ASCII word to a binary value, you need to subtract 48 from each byte.

    this might work, I am sure others have way of doing it too.

    <code>
    DecimalTemp var word
    BinaryTemp var word

    BinaryTemp = (DecimalTemp.highbyte - 48)*10 + (DecimalTemp.lowbyte - 48)
    </code>

    Don

  3. #3
    Join Date
    May 2004
    Location
    Sweden
    Posts
    9

    Smile

    Your right !
    I understand now, its not decimal its of course ascii.

    Have not tested yet, but its make sense.

    Thanks Don !

    Brgds Roy

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. PBPL 2.50 observations
    By BrianT in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 17th September 2007, 23:58
  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. Trouble with Serin2 and variable size
    By Ryan7777 in forum Serial
    Replies: 6
    Last Post: - 5th October 2006, 16:40
  5. Bin As Variable
    By Eyal in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 30th September 2005, 17:33

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