Problems with HEX and DEC

I have been playing with my Nextion screen (see many other posts…) trying to get xod to process the output. When an event occurs on the screen it returns a sting of hex bytes. I have been trying to convert the bytes to numbers, but I am confused about the difference between notations. Sometimes the notation is e.g. 65h, meaning 65 hex. Elsewhere the notation e.g. 0x65 is used. They appear to be not interchangeable even though they should be identical. I’ve tried using @gweimer’s hex-to-number function as my input byte shows as 65h in a watch node (i’m assuming that’s really hex 65) but it returns an error. If I give it a string “0x65” then it works fine. Now all I need to do is convert 65h to the string “0x65”!
I found this post HEX>DEC Convert in XOD? with some tricky code to do the conversion but I have not been able to get it to work. The first problem was a compiile error, where it said that “x” has not been defined, in the sscanf statement. Not sure which x it was complaining about.
So I created a variable set to “0x%x” and put that in the sscanf statement instead. The node compiled but didn’t work. I had it in a patch with a bunch of watch nodes which worked fine until I put my new node into it. Then the program would compile and start, but nothing is ever displayed in the watch nodes.
Here’s my program, copied almost verbatim from the post above

struct State {


void evaluate(Context ctx) {
    XString hex = getValue<input_HEX>(ctx);
    char hexBuff[16] = { 0 }; // unsafe 16 char cap, init with terminal zeros
    dump(hex, hexBuff);
    int dec;
    auto fmt = "0x%x";
    sscanf(hexBuff, fmt, &dec);
    emitValue<output_DEC>(ctx, dec);

Here’s my test program
It appears the input string into the hex-to-number must be a four character string, not an actual hex value.
Maybe the simplest solution would be to allow a hex/byte to connect to a numeric pin. It’s just a number after all. In fact a string of bytes all concatenated together is just a number. So in theory any byte, or string of bytes, should be connectable to a numeric pin? Gonna cause problems if you get it wrong (i.e. connect a string to a numeric pin) but maybe byte(s) should be connectable?

:wink: Ian