Good morning,
I would like to get the char which corresponds to a ASCII code. For example, if I have a byte with a value 16#68, I would like to get a char with value 'h'.
Thanks!
VAR
someByte: BYTE := 16#68;
theChar: STRING(1);
END_VAR
theChar[0] := someByte;
A STRING is just an array of BYTES. You can replace any of them with whatever value you want.
VAR
someByte: BYTE := 16#68;
theChar: STRING(1);
bytePtr: POINTER TO BYTE := ADR(theChar);
END_VAR
bytePtr[0] := someByte;
or bytePtr^ := someByte;
Create a Union:
TYPE CHAR :
UNION
ascii: STRING(1);
raw: BYTE;
END_UNION
END_TYPE
theChar.raw := 16#68;