Author Topic: Looking for string to unsigned short code (ansi c).  (Read 8324 times)

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Looking for string to unsigned short code (ansi c).
« on: May 26, 2008, 09:40:20 AM »
Can anybody point me to or like to share code for string to unsigned short (16bit) routine?  this will be for reading an edit box from a web page to configure a tcp port number.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Looking for string to unsigned short code (ansi c).
« Reply #1 on: May 26, 2008, 10:40:46 AM »
Hi

You should be able to use fnDecStrHex() to do this.

Eg:
usValue = (unsigned short)fnDecStrHex("12345");

If the input is in ASCII Hex the equivalent fnHexStrHex() can be used.

Eg:
usValue = (unsigned short)fnHexStrHex("aB24");

aB is used to show that the input is case-insensitive

Regards

Mark

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Looking for string to unsigned short code (ansi c).
« Reply #2 on: May 30, 2008, 09:47:23 AM »
Thanks, that worked out great.

JD