Home AMX User Forum NetLinx Studio

Conversion issue

Hello,

I would like to know if it's possible to do a conversion ignoring the conversion (?)

What I mean is:

$19 (Hexadecimal) = 19 (ASCII)

I need this because of a genius who wrote a checksum that simply ignore the usual conversion and uses $19 as 19 ASCII.

Thank you.

Regards,

André Roberto

Comments

  • JasonSJasonS Posts: 229
    I had to do the same thing for a wierd protocol, this is java code translated on the fly so it might need some tweaking and I have only used it with values from 0 - 99.
    DEFINE_FUNCTION CHAR encodeValue(INTEGER value) {
        if (value >= 0 AND value < 100) {
            RETURN TYPE_CAST((value/10) << 4) BOR TYPE_CAST(value % 10)
        }
        RETURN 0
    }
    
    DEFINE_FUNCTION INTEGER decodeValue(CHAR value) {
        RETURN TYPE_CAST((((value & $F0) >> 4) * 10) + (value & $0F))
    }
    
Sign In or Register to comment.