KTurtle/C3/Common-Errors-in-KTurtle/English
Visual Cue | Narration |
---|---|
Slide Number 1 |
Hello everybody. Welcome to this tutorial on Common Errors in KTurtle. |
Slide Number 2
Learning Objectives |
In this tutorial, we will learn about
Syntax errors and Runtime errors |
Slide Number 3
System Requirement |
To record this tutorial I am using,
Ubuntu Linux OS v. 12.04. KTurtle v. 0.8.1 beta. |
Slide Number 4
Pre-requisites |
We assume that you have basic working knowledge of KTurtle
If not, for relevant tutorials, please visit our website. http://spoken-tutorial.org |
First I will explain about Types of errors. | |
Slide Number 5
Syntax Errors |
A syntax error is a violation of grammatical rules, of a programming language.
Compilation fails when a program has syntax errors. Syntax errors are easy to find and fix. For Eg: Unmatched parentheses, square brackets and curly braces. Use of variable that has not been declared. Missing quotes in strings. |
Switch to KTurtle Application
Dash home >>Search bar appears>> In the Search bar type KTurtle Click on the KTurtle icon. |
Let's open a new KTurtle Application.
Click on Dash home. The Search bar appears. In the Search bar, type KTurtle. Click on the KTurtle icon. |
Let's begin the tutorial with some types of syntax errors. | |
I already have a program in a text editor. | |
reset
$a=ask "enter any number and click Ok" $r = ask "enter any number and click ok" $n = ask "enter any number and click ok" $T = $a*($r^$n)*($r^-1) print $T |
Let copy the program into Kturtle Editor.
Please pause the tutorial and type the program into KTurtle editor
|
Zoom text | Let me zoom into the program text.
It may possibly be a little blurred. |
To explain the error in the program, I will delete part of the code. | |
Highlight
$a=ask "enter any number and click Ok" |
Here, I will deleted the line $a=ask "enter any number and click Ok" |
Run the program | Let's Click on Run button to run the program
Complier shows the following error, The variable $a was used without first being assigned to a value. |
Replace the deleted line | I will replace the deleted line $a=ask "enter any number and click Ok" |
Run the program | Let's run again
press F5 key to run the program We see that the program runs without errors. |
Next let's look at another type of error. | |
I already have a program in a text editor. | |
reset
$degree=ask "enter any angle value and click OK" $radian=(pi/180)*$degree go 50,50 print "Value in radians is"+ " " +$radian spritehide |
Let me copy the program into Kturtle Editor
Please pause the tutorial and type the program into KTurtle editor
|
Zoom text | Let me zoom into the program text.
It may possibly be a little blurred. |
Highlight $ | Let's delete $ signs in the program. |
Run the program |
Let's Click on Run button to run the program.
Complier shows the following error, you cannot put “=” here |
Replace $ signs | Let's replace the $ signs and run again.
Program runs properly |
Highlight "Value in radians is" | Let's remove the one of the quotes of the string. |
Run the program | Let's click on Run button to run the program
Complier shows the following error, text string was not properly closed, expected a double quote “ ” to close the string. |
Repalce the quotes | Let's replace the quotes and run again.
press F5 key run the program. program runs without errors. |
Slide Number 6
Runtime errors |
Run-time error occurs during the execution of a program.
It may crash the program when you run it. Runtime errors are commonly due to wrong input from the user. Compiler cannnot find these errors. For example:
|