Start a new topic
Solved

Page Referencing in programming

On versions 0.42 and 0.43


If I have a page say  No 2 title A then


 a)  page 2.t31.txt=t0.txt   does not compile (Error: Invalid Page ID:page 2.t31.txt=t0.txt( Double click to jump to code)


b) page2.t31.txt=t0.txt  does not compile though it used to on an older program


c) A.t31.txt=t0.txt  works


If I have a page say 2 title A B  then

d) A B .t31.txt=t0.txt  does not compile


If I have a page say 2 title A_B  then

e) A_B .t31.txt=t0.txt  does compile


I would have thought that a) or e) are the correct formats and thus a) should compile? by the way there is no mention in the manual that page names should not have spaces




Page names shouldn't have spaces.  Variable names shouldn't have spaces.


This concept is a carry over of programming.

When parsing occurs (in any parser) the space in the name will be interpreted as a delimiter.

The compile process checks and reports errors - never thought it needed to be mentioned explicitly.


(case a) not expected to work page 2 has a space

(case b) page0.t1.txt=t0.txt  compiles and works in version v0.43

(case c) should and does work

(case d) shouldn't work as there are multiple spaces

(case e) shouldn't work as there is a space.  Fails on version v0.43


Patrick... Taking out the spaces did not work.. Please see attached

image

to access variables on different pages, they also must be declared as global ...


are they?


and where is your page2? 


and page names with a space ... read above from Patrick

1) yes, declared as variables

2) See RHS of screen shot Page 2 is named STA_MOD_SetUP

3) No spaces


I can make this code work if I use  STA_MOD_SetUP instead of page2

I understood that the page reference was the nextion assigned page number, not its description

Is this incorrect? or is the manual ambiguous

wrong understanding ....


global variables are always referenzed by their pagename 

and not by the page ID


a reason more to avoid spaces ...


it is also nowhere mentioned, that the id is used for variable referenzing ...

The preset examples show referencing to  A and B, previous examples I have seen showed page1, page 2..


 The 'refresh' function uses either the title or the page ID. 

  

It seems to me using the page ID is much more sensible than the title which can be many characters long. This would have the advantage if you changed the title you don't have to go back through your code changing every reference

page2 is an example of a pagename.  2 is an example of a pageid


ref uses either the object name or the component id

only because page components always have component id of 0

 does ref 0 cause a refresh of the current page.


In your picture, you have no pages name page2 - so it fails.

when you create a new page, the default set pagename is


    - page0

    - page1

    - page2

    - ...


but that's the pagename, not the pageid ...


Login or Signup to post a comment