Advertisement
krzys_h

CBOT - reading hex string

Nov 9th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. int hexval(string s)
  2. {
  3.     int a = 0;
  4.     s = strupper(s);
  5.     while(s != "") {
  6.         string x = strleft(s, 1);
  7.         s = strright(s, strlen(s)-1);
  8.         int n = strval(x);
  9.         if(x == "A") n = 10;
  10.         if(x == "B") n = 11;
  11.         if(x == "C") n = 12;
  12.         if(x == "D") n = 13;
  13.         if(x == "E") n = 14;
  14.         if(x == "F") n = 15;
  15.         a = a * 16 + n;
  16.     }
  17.     return a;
  18. }
  19.  
  20. extern void object::New()
  21. {
  22.    
  23.     string s = "303132";
  24.     while(s != "") {
  25.         int x = hexval(strleft(s, 2));
  26.         s = strright(s, strlen(s)-2);
  27.         message(x);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement