Skip to main content

Error Codes

Error Codes​

When something goes wrong while a program runs, BASIC-256 raises a runtime error or a warning, each with its own number. LastError returns the number of the last one that was trapped, and LastErrorMessage its message. Errors and warnings can both be trapped with Try / Catch / EndTry or OnError.

  • Errors from 1 to 65535 stop the program, unless they are trapped.
  • Warnings, from 65536 up, show a WARNING message and let the program carry on. A warning's number is 65536 plus the number of the matching error: WARNING_VARNOTASSIGNED is 65536 + 13 = 65549. On the User tab of Preferences you choose whether bad type conversions and unassigned variables are ignored, give a warning, or give an error.
  • Errors below 0 are mistakes in the program itself, such as a missing label or subroutine, or recursion that goes too deep. They can be trapped too, but they are best fixed in the program.
  • ThrowError raises an error with a number of your own. A number that is not in these tables, for example 1000 or more, has the message "User thrown error number".

In a message, %VARNAME% is replaced by the name of the variable. Each name in the tables is also a constant that a program can use, for example if lasterror = error_divzero then, except the names marked †, which have only a number.

Example​

onerror nicetrap
print 10 / 0
open 99, "bogus.file"
print "Runs Anyway"
end

nicetrap:
print "error " + lasterror + " on line " + lasterrorline + ": " + lasterrormessage
if lasterror = error_divzero then print "(that was a division by zero)"
return

will display

error 50 on line 2: Division by zero
(that was a division by zero)
0.0
error 5 on line 3: Invalid File Number
Runs Anyway

Errors in the program itself​

NumberNameMessage
-1ERROR_NOSUCHLABELNo such label %VARNAME%
-3ERROR_NOTARRAYVariable %VARNAME% is not an array
-5ERROR_ARGUMENTCOUNTNumber of arguments passed does not match FUNCTION/SUBROUTINE definition
-6ERROR_MAXRECURSEMaximum levels of recursion exceeded
-7ERROR_STACKUNDERFLOWStack Underflow Error
-11ERROR_UNSERIALIZEFORMATUnable to UnSerialize string
-12ERROR_NOSUCHSUBROUTINENo such SUBROUTINE %VARNAME%
-13ERROR_NOSUCHFUNCTIONNo such FUNCTION %VARNAME%
-14ERROR_ONERRORSUBSUBROUTINE %VARNAME% expects arguments and therefore can not be used by ONERROR statement

Errors​

NumberNameMessage
5ERROR_FILENUMBERInvalid File Number
6ERROR_FILEOPENUnable to open file
7ERROR_FILENOTOPENFile not open
8ERROR_FILEWRITEUnable to write to file
9ERROR_FILERESETUnable to reset file
10ERROR_ARRAYSIZELARGEArray %VARNAME% dimension too large
11ERROR_ARRAYSIZESMALLArray %VARNAME% dimension too small
12ERROR_ARRAYEVENArray data must be one dimensional with an even number of elements or two dimemsional with two elements in each row
13ERROR_VARNOTASSIGNEDVariable %VARNAME% has not been assigned a value
14ERROR_ARRAYNITEMSArray %VARNAME% rows must have the same number of items
15ERROR_ARRAYINDEXArray %VARNAME% index out of bounds
17ERROR_STRSTARTStarting position less than zero
20ERROR_RGBRGB Color values must be in the range of 0 to 255
23ERROR_POLYPOINTSNot enough points in array for poly()/stamp()
24ERROR_IMAGEFILEUnable to load image file
25ERROR_SPRITENUMBERSprite number out of range
26ERROR_SPRITENASprite has not been assigned
27ERROR_SPRITESLICEUnable to slice image
28ERROR_FOLDERInvalid directory name
29ERROR_INFINITYOperation returned infinity
30ERROR_DBOPENUnable to open SQLITE database
31ERROR_DBQUERYDatabase query error (message follows)
32ERROR_DBNOTOPENDatabase must be opened first
33ERROR_DBCOLNOColumn number out of range or column name not in data set
34ERROR_DBNOTSETRecord set must be opened first
35ERROR_NUMBERCONVUnable to convert to number
36ERROR_NETSOCKError opening network socket
37ERROR_NETHOSTError finding network host
38ERROR_NETCONNUnable to connect to network host
39ERROR_NETREADUnable to read from network connection
40ERROR_NETNONENetwork connection has not been opened
41ERROR_NETWRITEUnable to write to network connection
42ERROR_NETSOCKOPTUnable to set network socket options
43ERROR_NETBINDUnable to bind network socket
44ERROR_NETACCEPTUnable to accept network connection
45ERROR_NETSOCKNUMBERInvalid Socket Number
46ERROR_PERMISSIONYou do not have permission to use this statement/function
47ERROR_IMAGESAVETYPEInvalid image save type
50ERROR_DIVZERODivision by zero
53ERROR_FREEFILEThere are no free file numbers to allocate
54ERROR_FREENETThere are no free network connections to allocate
55ERROR_FREEDBThere are no free database connections to allocate
56ERROR_DBCONNNUMBERInvalid Database Connection Number
57ERROR_FREEDBSETThere are no free data sets to allocate for that database connection
58ERROR_DBSETNUMBERInvalid data set number
59ERROR_DBNOTSETROWYou must advance the data set using DBROW before you can read data from it
60ERROR_PENWIDTHDrawing pen width must be a non-negative number
62ERROR_ARRAYINDEXMISSINGArray variable %VARNAME% has no value without an index
63ERROR_IMAGESCALEImage scale must be greater than or equal to zero
66ERROR_RADIXSTRINGUnable to convert radix string back to a decimal number
67ERROR_RADIXRadix conversion base muse be between 2 and 36
68ERROR_LOGRANGEUnable to calculate the logarithm of a number less than or equal to 0
69ERROR_STRINGMAXLENString exceeds maximum length of 16,777,216 characters
71ERROR_PRINTERNOTONPrinter is not on
72ERROR_PRINTERNOTOFFPrinting is already on
73ERROR_PRINTEROPENUnable to open printer
78ERROR_FILEOPERATIONCan not perform that operation on a Serial Port
79ERROR_SERIALPARAMETERInvalid serial port parameter
80ERROR_LONGRANGENumber exceeds long integer range (minimum to maximum)
81ERROR_INTEGERRANGENumber exceeds integer range (minimum to maximum)
82ERROR_SLICESIZEInvalid Slice dimensions
83ERROR_ARRAYLENGTH2DCan not get a single length of a two dimensional array
84ERROR_EXPECTEDARRAYExpected array
85ERROR_VARNULLVariable %VARNAME% refers to a non-existent variable
86ERROR_VARCIRCULARCircular reference in variable %VARNAME%
87ERROR_IMAGERESOURCESpecified image resource not found
88ERROR_SOUNDRESOURCESpecified sound resource not found
89ERROR_INVALIDRESOURCESpecified resource not found
90ERROR_SOUNDFILEUnable to load sound file
91ERROR_SOUNDNOTSEEKABLE(only used as a warning)
92ERROR_SOUNDLENGTH(only used as a warning)
93ERROR_DOWNLOADError downloading file
94ERROR_EXPECTEDSOUNDExpected sound
95ERROR_TOOMANYSOUNDSToo many sound instances
96ERROR_ENVELOPEODDEnvelope data must contain at least 4 elements and an even number of elements
97ERROR_ENVELOPEMAXIt was exceeded the maximum length of an envelope, which is 20 seconds
98ERROR_HARMONICNUMBERHarmonic number must be an integer greater than zero
99ERROR_HARMONICLISTHarmonics list must be one dimensional array with an even number of elements or two dimemsional array with two elements in each row
100ERROR_WAVOBSOLETE(only used as a warning)
101ERROR_SOUNDFILEFORMAT(only used as a warning)
102ERROR_SOUNDERROR(only used as a warning)
103ERROR_ONEDIMENSIONALExpects one dimensional array or one dimensional list of elements
104ERROR_WAVEFORMLOGICALCreating custom waveform using logical coordinates it request at least 3 elements
105ERROR_STRING2NOTEUnable to convert string to musical note
106ERROR_ARRAYELEMENTElement of array %VARNAME% has not been assigned a value
107ERROR_SETTINGSGETACCESSThe program does not have permission to read settings from other program. Check access level from 'Preferences' panel
108ERROR_SETTINGSSETACCESSThe program does not have permission to write settings for other program. Check access level from 'Preferences' panel
109ERROR_INVALIDPROGNAMEInvalid program name
110ERROR_INVALIDKEYNAMEInvalid key name
111ERROR_SETTINGMAXLENSetting string exceeds maximum length of 16,383 characters
112ERROR_SETTINGMAXKEYSThe maximum number of keys for this program has been exceeded
113ERROR_REFNOTASSIGNEDVariable %VARNAME% refers to an unassigned variable
114ERROR_UNEXPECTEDRETURNUnexpected RETURN
115ERROR_NEXTNOFORNext without FOR
116ERROR_SQRRANGEUnable to calculate the root of a negative number
117ERROR_ASINACOSRANGEUnable to calculate the arc-sine or arc-cosine of a value outside the interval [-1.0, +1.0]
118ERROR_STRINGCONVUnable to convert to a string
119ERROR_BOOLEANCONVUnable to convert to a Boolean
120ERROR_ARRAYEXPRArray Expression Expected.
121ERROR_NUMBEREXPRNumeric Expression Expected.
122ERROR_STRINGEXPRString Expression Expected.
123ERROR_ZEROORONE †Zero or one expected.
124ERROR_NOTMAP †Variable %VARNAME% is not a map
125ERROR_ARRAYORMAPEXPR †Array or Map Expression Expected.
126ERROR_MAPKEY †Map key does not exist
128ERROR_MKDIR †Unable to create new folder
129ERROR_NOTAVAILABLE †Feature not available on this platform
130ERROR_WINDOWSIZE †WINDOW needs a width and a height that are not zero
131ERROR_MATNOTMATRIX †MAT needs an array for %VARNAME%, not a single value
132ERROR_MATDIM †MAT needs both matrices to have the same number of rows and the same number of columns
133ERROR_MATMULDIM †MAT MUL needs the first matrix to have as many columns as the second has rows
134ERROR_MATNOTSQUARE †MAT INV needs a square matrix
135ERROR_MATSINGULAR †MAT INV can not invert a singular matrix
136ERROR_VECNOTVECTOR †DOT, CROSS, NORM and UNIT need an array, not a single value
137ERROR_VECDIM †DOT and CROSS need both vectors to have the same number of elements
138ERROR_CROSSDIM †CROSS needs vectors of two or three elements
139ERROR_VECELEMENT †the vector has an element that has not been given a value
140ERROR_VECZERO †UNIT can not make a unit vector from a vector of length zero
141ERROR_HSV †HSV needs a hue from 0 to 360, and saturation, value and alpha from 0 to 100
65535ERROR_NOTIMPLEMENTEDFeature not implemented in this environment

Warnings​

NumberNameMessage
65549WARNING_VARNOTASSIGNEDVariable %VARNAME% has not been assigned a value
65571WARNING_NUMBERCONVUnable to convert string to number, zero used
65616WARNING_LONGRANGENumber exceeds long integer range (minimum to maximum), zero used
65617WARNING_INTEGERRANGENumber exceeds integer range (minimum to maximum), zero used
65627WARNING_SOUNDNOTSEEKABLEMedia file is not seekable
65628WARNING_SOUNDLENGTHDuration is not available for media file
65636WARNING_WAVOBSOLETEWAVPLAY suite is obsolete. Use SOUND/SOUNDPLAY/SOUNDPLAYER instead
65637WARNING_SOUNDFILEFORMATUnable to play the selected file
65638WARNING_SOUNDERRORUnable to play the sound
65641WARNING_STRING2NOTE(no message of its own)
65642WARNING_ARRAYELEMENTElement of array %VARNAME% has not been assigned a value
65649WARNING_REFNOTASSIGNEDVariable %VARNAME% refers to an unassigned variable
65654WARNING_STRINGCONVUnable to convert to a string, '' used
65655WARNING_BOOLEANCONVUnable to convert to a Boolean, false used
65662WARNING_MAPKEY †Map key has not been assigned a value

See Also​

Error Codes, Lasterror, Lasterrorextra, Lasterrorline, Lasterrormessage, Offerror, Onerror, ThrowError, Try / Catch / EndTry

History​

2.0.0.0Added to Documentation