Announcement

Collapse
No announcement yet.

convert 2 chars (ASCII) into one int

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • convert 2 chars (ASCII) into one int

    Dear experts,
    I have 2 characters f.e: 0x32 and 0x33 and want to get an integer from it.
    ASCII 0x32 = 2 and 0x33= 3 that should become to 23.
    How can I do that simple in 4DGL?
    Thanks for help
    Walter

  • #2


    If you're on the Picaso platform, take a look at the str_GetW function at:

    http://www.4dsystems.com.au/developers/docs.php?cat=28&id=152

    This converts a number in string form to an integer. If you'e got the two characters rather than a string, you can do something like:

    to(buffer); print(char1, char2);

    to join them together and then just copy the example code.

    Comment


    • #3


      If your numbers are always ASCII from 0-9, you could:

      MYINTEGER = ((HIBYTE - 30) * 10) + (LOWBYTE -30)
      _______________
      Best Regards,
      Howard

      Comment


      • #4


        Thank you all very much, yes that are the solutions....
        Walter

        Comment


        • #5


          4DsysFan: YOu mean surely: 0x30 in dezimal its 48
          But anyway, thanks for your advice.

          Comment

          Working...
          X