Set vale on page2

In my program I write to an un openend page. I use the EasyNextionLibrary. In this case page2 with this code:

myObject.writeStr("page2.t0.txt",objectName[index]);

Two questions:

  1. Is the syntax allowed to write direct to page2?
  2. If I open page2 is the contends of t0 changed?

If page2.t0.txt is global, then it will be changed. It’s so easy to just use serial commands to control the Nextion, that I’ve never looked at any libraries :grin:

Example:
const char* nextionQuoteEnd = “\x22\xFF\xFF\xFF”;

	Serial.print("pageIni.t11.txt=");
	Serial.write(0x22);
	Serial.print("Any text");
	Serial.print(nextionQuoteEnd);

Note: There are multiple ways of sending a " or the end flags.

@Powersoft I’d suggest to use the forum search function to look up pages and global variables. What you want to do is rather easy but depending on your application it has drawbacks you should know about.


Indeed. I’d like to add that usually you just escape them. Meaning, you add a \ before it then the compiler knows that it’s not the end of the string but a " within the string. It’s a rather readable way of writing it, too:

const char* NXT_CMD_END = "\xff\xff\xff";
Serial.print("page2.t0.txt=\"Any text\"");
Serial.print(NXT_CMD_END);

Note: Instead of looking up the ASCII code of ", C/C++ has a built-in way of doing that by using the single quotes:

char quotes = '"';
Serial.print(quotes, HEX); // => 0x22
Serial.write(quotes);      // => "

// Similarly, "ASCII-math" is possible:
Serial.write('A' + 1);     // => B

Kind regards,
Max