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

Thank you very much fvanroie,

This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).