Convert an integer to a string


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2005
    Posts
    36

    Default Convert an integer to a string

    Hi.
    I need something like serout [dec2 var_name] or lcdout dec var_name;
    but send the result to a string.
    I suppose these functions are available in the compiler; nobody knows how to call them ?
    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Look at SEROUT2 in the manual. This tells how to send in BIN, HEX, DEC, or STR.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    How about:
    Code:
    Serout......[#var_name]
    LCDOUT $FE,1,[#var_name]
    /Henrik Olsson.

  4. #4
    Join Date
    Nov 2005
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Perhaps i badly explained.
    I do not use serout or lcdout; i need a 16 bit binary to decimal conversion; i have to send a variable value to the Nokia 3310 display.
    I now realized that DIG may be useful.
    Regards

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Hmm.. you are looking for an equivalent like the c function sprintf.

    You are right, the DIG command is ideal to build the string. It may be more optimised if you hand code in asm

    Jerson

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by GioppY View Post
    Perhaps i badly explained.
    I do not use serout or lcdout; i need a 16 bit binary to decimal conversion; i have to send a variable value to the Nokia 3310 display.
    I now realized that DIG may be useful.
    Regards
    tenthousands = value / 10000
    value = value - ( tenthousands * 10000 )
    thousands = value / 1000
    value = value - ( thousands * 1000 )
    hundreds = value / 100
    value = value - ( hundreds * 100 )
    tens = value / 10
    value = value - ( tens * 10 )
    ones = value

    string(4) = tenthousands + 48
    string(3) = thousands + 48
    string(2) = hundreds + 48
    string(1) = tens + 48
    string(0) = ones + 48

    First chunk of code will get the decimal values for the place holder for that digit.

    Second chunk of code will change that into an ASCII representation of that number.

    Then you can just serout (or SPI or I2C or whatever) that 'string' out whatever port you need to...

    Theoretically anyways...

Similar Threads

  1. How about String Variables?
    By mytekcontrols in forum PBP Wish List
    Replies: 40
    Last Post: - 20th January 2015, 12:53
  2. How to convert a HSERIN string to a hex value?
    By ShortBus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd October 2009, 04:41
  3. Replies: 11
    Last Post: - 12th July 2008, 02:36
  4. How to convert HEX Value as formatted BIN String ?
    By Robson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2007, 02:16
  5. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39

Members who have read this thread : 1

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