Unofficial Nextion/TJC User Forum

How to get ascii from char?

Seen that the fake C in nextion editor does not consider chars as normal C Does,
seen that ‘a’ + 1 return an error, is there a trick to obtain from a char var its ascii value?
(non intending to make it externally from, for example, arduino)?

Nextion Editor is seeing “a” as string and not as char. That’s why your implicit type conversion and addition fails.

It’s ugly, but this code searches for a letter in a string and returns the next letter in a round-robbin fashion:

// get one letter and put it in va0.txt
substr "abcdefghijklmnopqrstuvwxyza",va0.txt,sys0,1
// check if t0.txt matches the letter
// advance to the next letter
// put the next letter in t1.txt
substr "abcdefghijklmnopqrstuvwxyz",t1.txt,sys0,1

sys0 contains the position number within the string. You can expand on this as needed.

1 Like

Thank you. I meant to avoid cycles to reduce time.

Yes, i know, unfortunately