Programming Tips
 

Backup
Keep copies of working code so that you can return to them if you find your current code stops working.
Do not use an SD card for main project storage. They can be damaged after multiple insertions.

Brackets

Check brackets "(", ")", "{", "}", "[", "]" are correct (same amount of open brackets as closed brackets).

Code Layout
Keep text in blocks and use indenting to keep it tidy eg
POSN(240,136); TEXT(txtname,"text",Style);
KEY(keyname,keyfunc,xsize,ysize,TOUCH);
POSN(340,136); TEXT(txtname2,"text",Style);
KEY(keyname2,keyfunc2,xsize,ysize,TOUCH);

Comments

Always add comments to all lines or blocks of code if possible – helpful for debugging and when looking at old projects.

Debugging

When debugging code on the module, put debug information in a temporary text string on the page or send debug information through an unused serial port on the module by setting it's rxi=D; parameter.

Entity Names
Make sure the name of the entity created is exactly the same when used in other parts of the code / project.

Entity Names
Choose an entity name that is: unique as entities are global and more than one can’t have the same name easy to remember (related to what it is or does).

Entity Names
Be careful when copying and pasting code that you make entity names unique.

Entity Names
The length of entity names can only be up to 18 characters plus can only start with a letter or _

File Names
Use 8.3 format file names with maximum 11.3 format where absolutely necessary.
Support for longer file names is being developed.

Faster Page Updates
If using update=changed or update=all, make sure you know the difference between them and their limitations so you know when to use them.

Limiting Values
Make sure that you know the default, minimum and maximum values of style and setup parameters.
eg Values set higher than the parameter's limit will cause an error.

Memory Allocation
To save memory, particularly in memory hungry projects, when setting the length or size in a style for a page component,
set to the maximum predicted value rather than using the defaults or an unnecessary large value. eg For a text style,
if creating a text component with the word "hello" -> set maxLen parameter in style to 5.

Page refresh ";;"
Make sure you know when a page refresh is needed, keep them to a minimum and don’t overuse them.

Project Layout
Order / Structure projects so that the core commands are loaded in the following order
Interface and System SETUP and INT
Include other files using INC(filename); in the order of...
Image and Font LIB commands
Entity STYLES
Variable declarations VAR
Pages PAGE with page specific functions included
Functions for general purpose use.
then SHOW(firstpage); unless this is controlled by the host.

Project Layout
Where possible use individual files to put each page of project in own mnu file like PgMain.mnu
When using the PAGE command, use the file name as the page name: Page(PgMain,stpage) {....}
Group all funcs, styles, variables and library items in group files like func mnu, styles.mnu, var.mnu, lib.mnu

Semi-colons
Check each command ends with a semi-colon, where necessary.

Strings

Check strings are correctly enclosed in double quotes "string". Use "\\22" to insert a double quote into a string.