Skip to main content

Códigos de error

Códigos de error​

Cuando algo sale mal mientras se ejecuta un programa, BASIC-256 provoca un error o un aviso de ejecución, cada uno con su propio número. LastError devuelve el número del último que se capturó, y LastErrorMessage su mensaje. Tanto los errores como los avisos pueden capturarse con Try / Catch / EndTry u OnError.

  • Los errores de 1 a 65535 detienen el programa, salvo que se capturen.
  • Los avisos, de 65536 en adelante, muestran un mensaje WARNING y dejan que el programa continúe. El número de un aviso es 65536 más el número del error correspondiente: WARNING_VARNOTASSIGNED es 65536 + 13 = 65549. En la pestaña Usuario de las Preferencias eliges si las conversiones de tipo erróneas y las variables sin asignar se ignoran, dan un aviso o dan un error.
  • Los errores por debajo de 0 son fallos del propio programa, como una etiqueta o subrutina que no existe, o una recursión demasiado profunda. También pueden capturarse, pero lo mejor es corregirlos en el programa.
  • ThrowError provoca un error con un número elegido por ti. Un número que no está en estas tablas, por ejemplo 1000 o más, tiene el mensaje "User thrown error number".

En un mensaje, %VARNAME% se sustituye por el nombre de la variable. Cada nombre de las tablas es también una constante que un programa puede usar, por ejemplo if lasterror = error_divzero then, salvo los nombres marcados con †, que solo tienen número. Los mensajes aparecen en inglés, tal como los muestra BASIC-256.

Ejemplo​

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

mostrará

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

Errores del propio programa​

NúmeroNombreMensaje
-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

Errores​

NúmeroNombreMensaje
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(solo se usa como aviso)
92ERROR_SOUNDLENGTH(solo se usa como aviso)
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(solo se usa como aviso)
101ERROR_SOUNDFILEFORMAT(solo se usa como aviso)
102ERROR_SOUNDERROR(solo se usa como aviso)
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

Avisos​

NúmeroNombreMensaje
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 tiene mensaje propio)
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

Véase también​

Códigos de error, Lasterror, Lasterrorextra, Lasterrorline, Lasterrormessage, Offerror, Onerror, ThrowError, Try / Catch / EndTry

Historial​

2.0.0.0Se añadió a la documentación