Skip to main content

Codes d’erreur

Codes d’erreur​

Quand quelque chose se passe mal pendant l’exécution d’un programme, BASIC-256 déclenche une erreur d’exécution ou un avertissement, chacun avec son propre numéro. LastError retourne le numéro du dernier intercepté, et LastErrorMessage son message. Erreurs et avertissements peuvent tous deux être interceptés avec Try / Catch / EndTry ou OnError.

  • Les erreurs de 1 à 65535 arrêtent le programme, sauf si elles sont interceptées.
  • Les avertissements, à partir de 65536, affichent un message WARNING et laissent le programme continuer. Le numéro d’un avertissement est 65536 plus le numéro de l’erreur correspondante : WARNING_VARNOTASSIGNED vaut 65536 + 13 = 65549. Dans l’onglet Utilisateur des Préférences, vous choisissez si les conversions de type impossibles et les variables non affectées sont ignorées, donnent un avertissement ou donnent une erreur.
  • Les erreurs inférieures à 0 sont des fautes dans le programme lui-même, comme une étiquette ou une sous-routine manquante, ou une récursion trop profonde. Elles peuvent aussi être interceptées, mais il vaut mieux les corriger dans le programme.
  • ThrowError déclenche une erreur avec un numéro de votre choix. Un numéro absent de ces tableaux, par exemple 1000 ou plus, a pour message "User thrown error number".

Dans un message, %VARNAME% est remplacé par le nom de la variable. Chaque nom des tableaux est aussi une constante utilisable par un programme, par exemple if lasterror = error_divzero then, sauf les noms marqués †, qui n’ont qu’un numéro. Les messages sont donnés en anglais, tels que BASIC-256 les affiche.

Exemple​

onerror nicetrap
print 10 / 0
open 99, "bogus.file"
print "S’exécute quand même"
end

nicetrap:
print "erreur " + lasterror + " ligne " + lasterrorline + " : " + lasterrormessage
if lasterror = error_divzero then print "(c’était une division par zéro)"
return

affichera

erreur 50 ligne 2 : Division by zero
(c’était une division par zéro)
0.0
erreur 5 ligne 3 : Invalid File Number
S’exécute quand même

Erreurs dans le programme lui-même​

NuméroNomMessage
-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

Erreurs​

NuméroNomMessage
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

Avertissements​

NuméroNomMessage
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(pas de message propre)
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

Voir Aussi​

Codes d’erreur, Lasterror, Lasterrorextra, Lasterrorline, Lasterrormessage, Offerror, Onerror, ThrowError, Try / Catch / EndTry

Historique​

2.0.0.0Ajouté à la documentation