Start a new topic


It would be useful to have a subroutine capability

Perhaps it could be implemented as an item in the toolbox, like the variables are.

Once included on a page the user could select local or global scope and type the code to be run.

It could also be used as a function the return being provided by the .val property. It should be possible to pass parameters when calling.

Just an idea

1 person likes this idea
1 Comment

The building blocks for this exist already.

Add three global Variables, change .objname to param0, param1 and param2.

Set as string or numeric as desired.  Also sys0, sys1 and sys2 already exist as numeric variables.

Add another global Variable, change .objname to .outval

Set as string or numeric as desired for the return value

Add hotspot m0, resize .w and .h to 5x5 and place in a portion of the screen less likely to be pressed.

Set hotspot as global

You now have two code holders to work with: Touch Pressed and Touch Released

set code in these events to work on param0, param1, param2, sys0, sys1, sys2 as needed

set code to assign return value to outval variable

use click m0,1 for Pressed and click m0,0 for Released

The main difficulty in having a subroutine in a normal coding construct is that the Nextion isn't a coding language, rather a series of interpreted text commands.

Login or Signup to post a comment