Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

LASTERR

Description

LASTERR is a read-only pseudo variable. Any write attempt results in an error. LASTERR is somewhat like a volatile status value that is used by many functions to report success or error. Most functions and commands set LASTERR to 0 (ERR_OK) on entry. When the Scripting Language detects inconsitencies, LASTERR is set to a value other than 0 to report the problem to the program.

The system defines the following error codes:

 Name  Value  Description
 ERR_OK  0 Everything works fine
 ERR_NO_COMMAND  1 The input was not a known command
 ERR_NO_FRAME  2 Packet Interface only: Wrong frame format
 ERR_PARAMCOUNT  3 Too much or too less arguments for that command
 ERR_ARGUMENT  4 One of the arguments was wrong
 ERR_LENGTH  5 The argument has a wrong length
 ERR_CRC  6 Packet Interface only: CRC error on incoming packet
 ERR_UNSPEC  7 The command or argument is not yet specified 
 ERR_NO_DATA  8 There's currently no data
 ERR_NO_DISK  9 The SD card is missing 
 ERR_INVALID_HANDLE  10 Handle number out of permitted range 
 ERR_TRUNCATED  11 The data was truncated 
 ERR_REJECTED  12 Command or argument currently not valid 
 ERR_FR_NOT_READY  13 The file system is not yet initialized 
 ERR_FR_NO_FILE  14 File does not exist 
 ERR_FR_NO_PATH  15 Path does not exist
 ERR_FR_INVALID_NAME  16 The file name is invalid 
 ERR_FR_INVALID_DRIVE  17 A drive parameter was not recognized
 ERR_FR_DENIED  18 Access is denied 
 ERR_FR_EXIST  19 File or directory already exists 
 ERR_FR_RW_ERROR  20 Low level error while trying to access the disk 
 ERR_FR_WRITE_PROTECTED  21 The disk is write protected
 ERR_FR_NOT_ENABLED  22 File system not mounted 
 ERR_FR_NO_FILESYSTEM  23 There's no file system on the disk
 ERR_FR_INVALID_OBJECT  24 Internal FAT error
 ERR_FS_UNKNOWN  25 The file system could not be recognized 
 ERR_FIL_EXHAUSTED  26 All file handles are in use
 ERR_ID_USED  27 This file handle or other object is already in use  
 ERR_NOT_OPEN  28 The file or other object is not open 
 ERR_NO_READ  29 Read access denied 
 ERR_NO_WRITE  30 Write access denied 
 ERR_TOO_MUCH  31 Too much data 
 ERR_FILE_OPEN  32 The file or other object is already open 
 ERR_EOF  33 File pointer is at the end 
 ERR_DISK_FULL  34 The disk is full 
 ERR_FW_IMAGE  35 The firmware was rejected 
 ERR_ALREADY_RUNNING  36 A script is already running 
 ERR_NOT_RUNNING  37 The script is not running 
 ERR_NOCONN  38 There's no connection, The connection is gone 
 ERR_NET_DOWN  39 The network connection is broken 

Example

This program demonstrates LASTERR. On startup, LASTERR is always 0 (ERR_OK). Variable assignments don't affect LASTERR, so the first program line reads LASTERR and keeps its old value. In the 4.th line, there's a faulty instruction, which sets LASTERR to 4 (ERR_ARGUMENT). The PRINT statement after that resets LASTERR to 0 again.

let a = LASTERR
outmode -2
print a
open "x", 999, "..."
let b = LASTERR
print b
print LASTERR
end

Remarks

Because LASTERR is only valid immediatly after command execution, it needs immediate evaluation or must be stored into a variable for later evaluation.