Debugging Your Code: Types of Errors
Errors are a part of programming. Knowing how to find and fix your mistakes is as important as knowing how to write the code in the first place. Logical Errors occur while your code is running. Syntax Errors occur while your code is compiling. The following is a more detailed description of the types of errors you will likely encounter while programming in Sesame. For debugging techniques, see this Knowledge Base article.
Syntax ErrorsThese are caught by testing your program in the Programming Editor. Syntax Errors occur when a section of code has been mistyped/misspelled, causing Sesame to misunderstand your instructions. A syntax error does not prevent you from saving a program. You can save your work - errors and all - and close the editor, the return to it later for further work. (Any programming is automatically, temporarily saved when you exit/close the Program Editor window. To permanently save all of your programming changes, click Save Layout Design on the Commands menu.) Examples of syntax errors include:
- Misspelling an Element name
- Misspelling an SBasic call
- Leaving out a parenthisis
- Calling a procedure with the wrong number or type of arguments
Logical Errors occur when Sesame is doing exactly what you told it to, and that is the problem. These include :
- Dividing by zero
- Checking an incorrect condition
- Incorrectly bracing conditionals
- Looping forever
Type of Error | Error | Description | Incorrect | Correct | |
---|---|---|---|---|---|
Warning | Warning: layout element name [name] contains operator characters. | The layout element name contains characters which make it illegal for use in programming. This is only a warning. If the layout element is not referred to in programming, this will not cause an error. |   |   | |
Syntax/Compile | Missing closing quotes in String. | Strings must have both opening and closing quotes. | vStr = "Sesame |
vStr = "Sesame" |
|
Syntax/Compile | Missing close comment. | Comments opened using /* must be closed. | /* This is a comment |
/* This is a comment */ <?td>
|
|
Syntax/Compile | Unclosed character constant. | Characters (Chars) must have both opening and closing single quotes. | vChar = 'A |
vChar = 'A' |
|
Syntax | Declaration expected. | Error occurs on or before the referenced line. |   |   | |
Syntax | Statement expected. | Error occurs on or before the referenced line. |   |   | |
Syntax | Statement or End-Of-File expected | Error occurs on or before the referenced line. |   |   | |
Syntax/Compile | Subroutine name expected. | A subroutine declarations is missing the name. | Subroutine() |
Subroutine MySub()
|
|
Syntax/Compile | Function name expected. | A function declaration is missing the name. | Function() as Int |
Function MyFunc() As Int |
|
Syntax/Compile | Variable declaration list expected. | The program contains "var" without completing the declaration. | var |
var vInt as Int |
|
Syntax/Compile | Static declarations after dynamic declarations are not allowed. | All declarations of static variables must occur before any declaration of dynamic variables |   |   | |
Syntax/Compile | Static declarations in functions and subroutines are not allowed. | Static variables may only be declared outside of a function or subroutine |   |   | |
Syntax/Compile | Variable name expected. | Program uses a for-next loop with an invalid or missing index variable. | For = 1 to 20 |
For vInt =1 to 20 |
|
Syntax/Compile | Expression is expected. | Program is missing an expression. | vTotal = |
vTotal = (Unit * Price) |
|
Syntax/Compile | Parameter declaration expected. | A procedure declaration has a trailing comma in the parameters area. | Subroutine TestMe( var a as Int, ) |
Subroutine TestMe( var a as Int, var b as Int |
|
Syntax/Compile | Formal parameter declaration expected. | A procedure declaration has an incomplete parameter. | Subroutine TestMe( var ) |
Subroutine TestMe( var a as Int ) |
|
Syntax/Compile | Subroutine or label expected. | GoTo used without specifying target. | GoTo |
GoTo CalculateMe |
|
Syntax.Compile | Label expected. | GoTo used without specifying target. | GoTo |
GoTo CalculateMe |
|
Syntax/Compile | Assignment operator expected. | Statement missing an equal sign (=). | vInt Units |
vInt = Units |
|
Syntax/Compile | Term expected | Program contains an incomplete expression. | vInt = 3 + |
vInt = 3 + 5 |
|
Syntax/Compile | Symbol expected [symbol], symbol found [symbol2]. | Usually indicates that an open symbol, such as (, occurs without a matching close symbol. [symbol] shows the found open symbol. [symbol2] shows the symbol found instead of the expected close symbol. |
If(vInt = 5 Then produces the error: Symbol expected [)], symbol found [THEN].
|
||
Syntax/Compile | Direct reference for var parameter expected. | The program attempts to pass a static value to a function or subroutine which is expecting a variable to be passed by reference. |
Example:Function TestMe(var vInt as Int) as Int Return 5 End Function Var vInt2 as Int vInt2 = TestMe("test") |
||
Syntax/Compile | Label used as jump target but label definition is missing. | GoTo statement references a label which does not exist in the procedure. |
Example: If there is no label defined as GoHere:, the following statement would produce this error.
GoTo GoHere
|
||
Syntax/Compile | Type expected. | A declaration is missing the type. | var vInt as |
var vInt as Int |
|
Syntax/Compile | Type mismatch error (operation is not defined for the types of the operands). | Program attempts to perform an operation which is illegal for the types of the operands. | Example: if vFullName and vLastName are both type String, the following statement would produce this error because Strings cannot be subtracted from each other.
FirstName = vFullName - vLastName |
||
Syntax/Compile | Type mismatch error (types of formal and actual parameter must match for VAR parameter). | The program attempts to pass a value to a function/subroutine which is of a different type than is declared for that function or subroutine. |
Example: The following code would produce this error because the type of the variable being passed is not the same as the type declared.
Function TestMe(var vInt as Int) as Int Return 5 End Function Var vStr as String Var vInt2 as Int vStr = "Test" vInt2 = TestMe(vStr) |
||
Syntax/Compile | Type mismatch (both operands must be of the same type). | Both operands (specifies what data is to be manipulated or operated on) must be of the same type. |   |   | |
Syntax/Compile | Boolean expression expected. | Program expects an expression or value of the specified type. |   |   | |
Syntax/Compile | String expression expected. | String expression expected. |   |   | |
Syntax/Compile | Numeric expression expected (int, double, char, bool, date, time). | Program expects an expression or value of the specified type. |   |   | |
Syntax/Compile | String type expected. | Program expects an expression or value of the specified type. |   |   | |
Syntax/Compile | String expected | Program expects an expression or value of the specified type. |   |   | |
Syntax/Compile | Unknown identifier. | Identifier does not exist or is undeclared. Identifiers must be declared before they are used. |   |   | |
Syntax/Compile | Loop invariants (FOR-NEXT-counter) must be simple local variables. | Variables used to index loops must be declared locally. |   |   | |
Syntax/Compile | GOTO not allowed here. | Program attempted to use a GoTo to jump out of the current function or subroutine. |   |   | |
Syntax/Compile | Navigation programming not allowed here. | Navigation programming is not legal if running SBasic standalone. |   |   | |
Syntax/Compile | Redefinition of identifiers is not allowed. | Indentifiers may only be declared once within any particular scope. |   |   | |
Syntax/Compile | Variable or function not defined. | Variable or function does not exist or is undeclared. Variables and functions must be declared before they are used. |   |   | |
Syntax/Compile | Array name expected. | Program attempts to access a generic array using = instead of a generic array call, such as SetIntElement. |   |   | |
Syntax/Compile | Number of dimensions does not match definition. | The number of dimensions in the array does not match the array declaration. |   |   | |
Syntax/Compile | Number of formal parameters does not match number of actual parameters. | The number of parameters used does not match the procedure declaration. |   |   | |
Syntax/Compile | Indexing operator [ ] not allowed on generic arrays. | Program attempts to index a generic array instead of using a generic array call, such as SetIntElement. |   |   | |
Runtime Error | Function does return a value. | A function must return a value. | Function MyFunc() as Int End Function |
Function MyFunc() as Int Return 1 End Function |
|
Runtime Error | Illegal type (operation not allowed). | The operation is illegal for the data types. |
Example:
vString = "FirstName" / "LastName"
|
||
Runtime Error | Division by zero. | Program attempted to divide by zero. |
Example:
Bonus = Salary / 0
|
||
Runtime Error | Array not dimensioned. | An array was declared, but not dimensioned. |   |   | |
Runtime Error | Wrong number of dimensions in array access. | Program uses an array accessor function using a different number of dimensions than the array being accessed. |
Example:
var MyArray as Array[10, 2] of Int MyArray[5] = 3 |
||
Runtime Error | Max. array index negative while creating array. | An array has been declared with a negative dimension. |
Example:
var MyArray as Array[-1] of Int
|
||
Runtime Error | Array index zero while accessing the array. | The program attempted to access an array using an index of 0 (zero). |
Example:
vInt = vaMyArray[0]
|
||
Runtime Error | Array index negative while accessing an array. | The program attempted to access an array using a negative index. |
Example
vInt = vaMyArray[-1]
|
||
Runtime Error | Array index overflow. | The program attempted to access an array using an index larger than the array dimension. |
Example:
var vaMyArray as Array[10] of Int vInt = vaMyArray[15] |
||
Runtime Error | Runtime type mismatch while accessing an array. | Program attempted to access a generic array using an accessor function for a different data type. | Example: Attempted to access an array of type String using SetIntElement. | ||
Runtime Error | @CGR: pv and fv must have the same sign. | Present Value and Future Value must have the same sign. | vCGR = @CGR(100, -500, 10) |
vCGR = @CGR(100, 500, 10) |
|
Runtime Error | @FV: i must be >= -1; @PMT: i must be >= -1; @PV: i must be >= -1. |
Program attempted to use one of these financial functions with an interest rate parameter of less than -1 |   |   | |
Internal Error | Constant pool overflow. |   |   |   |   |
Internal Error | Runtime stack overflow. |   |   |   |   |
Internal Error | Internal error: Runtime stack underflow. |   |   |   |   |
Internal Error | Internal Error: Call stack empty while looking for invocation record. |   |   |   |   |
Internal Error | Internal Error: Invocation record not found on call stack. |   |   |   |   |
Internal Error | Internal Error: jump target not defined. |   |   |   |   |
Internal Error | Internal Error: variable name could not be defined. |   |   |   |   |
Internal Error | Internal SBasic Error. Contact Technical Support. |   |   |   |   |