Converting a USINT to a Character

Does anyone know if there is a B&R Library that has a function in it to convert a USINT value to a Character value?

Hi,

I’m not sure if I understood your question right: do you want to interprete the USINT value as ASCII value? For example, interprete the value 65 as ‘A’?
If yes, just memcopy the value to a STRING variable, for example in ST:

// myString is of type STRING[1], myUsint is of type USINT holding the value of a ASCII character
brsmemcpy(ADR(myString),ADR(myUsint),1);

Best regards!

3 Likes

Hi @CJ_Bienia, is it your question answered, can you update us?

Thanks Alex, is there a library I need to load for that function? When I added that code to my project it is asking be to delcare brsmemcpy as a variable.

You’ll need to add library AsBrStr to your project.

1 Like

Thank you! Works perfectly.

1 Like