Command FUNC
 
Description Create a function called by commands which returns to the next command on completion. Functions can call other functions and themselves. No storing or passing of variables occurs as these are all global even if created in a function.
Maximum 28 nested loops or functions - v49.32.
Maximum Function Size increased: 8192 ASCII characters - v49.32.
 
Syntax/Parameters FUNC(Name) {…}
 
Options You can exit a function by using the EXIT command
EXIT(Name) - end functions - v47.24

> EXIT(name); // exit nested loops/functions up to and including loop/function with name
 
Example > FUNC(fn1) { if(x=5?[EXIT(fn1);]); ...... } // exits function when x=5 without running rest of code
> FUNC(fn2) { LOOP(lp3,100){ LOAD(RS2,"*"); if(quit=1?[EXIT(fn2);;]);
// sends 100 *'s through RS2 unless quit is set to 1, then loop and the function are exited (A screen refresh occurs before the exit)

Note, if the name provided in the EXIT(name); command does not exist in the current function/loop nesting, then all loops
and functions are exited up to the top level. It is not possible to exit the page loop in this way.

Restriction: If processing a function called from a KEY() command then further key presses will be ignored. Each touch key press function must be processed to completion before another can be processed. Please refer to the project example 'keyboard' for the technique to process keys.
 
Update Information

 Version

 Title

Date  

 Details

49.58

 INLINE FUNCTIONS

07 Sep 15 

Show

* Now handles empty functions - []

49.34

 Parser - Fixed problem with passing page creation parameters between functions.

23 Feb 13 

Show

Parser
* Fixed problem with passing page creation parameters between functions which caused entities to not be displayed.

49.32

 Internal Message Items - Increased nesting depth/loops/functions from 24 to 28.

14 Feb 13 

Show

* Increased nesting depth/loops/functions from 24 to 28.
* Current number of used msg items can be read in S32 Variable SYSINTMSG.

49.32

 Parser - Maximum Function Size increased: 8192 ASCII characters.

14 Feb 13 

Show

* Maximum Function Size increased: 8192 ASCII characters (was 4096 in V00.49.31)
* Error message "Memory Error - Function Too Big. Please split into smaller functions" if the 8192 limit is reached. Please make smaller functions (eg using RUN(fnc1,fnc2,fnc3);) or contact us if this is a problem.

49.08

 Not Function Error - Fixed error which was due to a pointer error when changing/refreshing a page without page loop

11 Jul 12 

Show

Fixed "Not Function" Error which was due to a pointer error when changing/refreshing a page without page loop. This problem could cause other unexplained errors. This bug was present in the code from before V00.47.24.

49.02

 Serial Port Error Handlers

15 May 12 

Show

Function name lookup corrected for the error handlers (setup parameter "func").

49.00

 Commands - The limitation of 256 characters for each parameter in a command has been increased to 1024 characters.

22 Mar 12 

Show

The limitation of 256 characters for each parameter in a command has been increased to 1024 characters.
The maximum length of a command remains at 8192 characters.
Fixed problem when a 'proc' has been specified and the port is in command mode.
The 'proc' is now correctly ignored when in command mode.

47.24

 Exit() - end loops and functions - Exit command added to exit loops or functions

31 Oct 11 

Show

Exit command added to exit loops or functions
> exit(); // exit current loop/function
> exit(name); // exit nested loops/functions up to and including loop/function with name
* Examples:
> loop(lp1,FOREVER){ calc(x,y,z,"+"); if(x=5?[exit(lp1);]); } // exit loop when x=5
> loop(lp2,FOREVER){ calc(x,y,z,"+"); if(x=5?[exit(lp2);]); } // exit loop when x=5 (as above)
> func(fn1) { if(x=5?[exit(fn1);]); ...... } // exits function when x=5 without running rest of code
> func(fn2) { loop(lp3,100){ load(rs2,"*"); if(quit=1?[exit(fn2);;]); // sends 100 *'s through RS2 unless quit is set to 1, then loop and the function are exited (A screen refresh occurs before the exit)

* Note, if the name provided in the exit(name); command does not exist in the current function/loop nesting, then all loops
and functions are exited up to the top level. It is not possible to exit the page loop in this way.

21.00

 FUNC LOOP - Allow single line FUNC(){} and LOOP(){}

30 Jul 10 

Show

Allow single line FUNC(){} and LOOP(){}
e.g. FUNC(Help) { SHOW (HelpPage); }