CSD 340 (Blum)1 Errors and Debugging and Swapping Variable Values.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introducing JavaScript
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
The Web Warrior Guide to Web Design Technologies
2440: 211 Interactive Web Programming JavaScript Fundamentals.
CSD 340 (Blum)1 Using Microsoft Visual Studio.NET Development Environment and Introducing Functions.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript
HTML Recall that HTML is static in that it describes how a page is to be displayed, but it doesn’t provide for interaction or animation. A page created.
Guide To UNIX Using Linux Third Edition
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Introduction to scripting
PHP: Hypertext Processor Fred Durao
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
1 Some Variations on Date Display 2 Print HTML Code What PHP prints will be placed into the file, and then the file is sent to the web client to be rendered.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Using Client-Side Scripts to Enhance Web Applications 1.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Strings, output, quotes and comments
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Server versus Client-Side Programming Server-SideClient-Side.
ERRORS. Types of errors: Syntax errors Logical errors.
1 JavaScript in Context. Server-Side Programming.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
CSD 340 (Blum)1 For Loops See Beginning JavaScript (Paul Wilton) p. 87.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 4 Murach's JavaScript and jQuery, C4© 2012, Mike Murach & Associates, Inc.Slide 1.
C language + The Preprocessor. + Introduction The preprocessor is a program that processes that source code before it passes through the compiler. It.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
REEM ALMOTIRI Information Technology Department Majmaah University.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript Errors and Debugging Web Design Sec 6-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
Chapter 6 JavaScript: Introduction to Scripting
ME 142 Engineering Computation I
Tutorial 10 Programming with JavaScript
Introduction to Scripting
Intro to PHP & Variables
A second look at JavaScript
WEB PROGRAMMING JavaScript.
Tutorial 10 Programming with JavaScript
Presentation transcript:

CSD 340 (Blum)1 Errors and Debugging and Swapping Variable Values

CSD 340 (Blum)2 An HTML document with an JavaScript error. Missing quotation mark.

CSD 340 (Blum)3 Gives appearance of having run, but alert box never appeared.

CSD 340 (Blum)4 Go to Tools/Internet Options

CSD 340 (Blum)5 On the Advanced tab, choose not to Disable script debugging and to Display a notification about every script error.

CSD 340 (Blum)6 Script error message displayed. Click on Show Details.

CSD 340 (Blum)7 Details Shown.

CSD 340 (Blum)8 Use the Edit/Go To … feature to find Line 12 where the error is claimed to be. Note errors are often found on the preceding lines, but start at line 12 and go backward in your search for an error.

CSD 340 (Blum)9 Goto Line 12

CSD 340 (Blum)10 I was taken to Line 12 which I have highlighted. The error message mentions Char(acter) 33 which is the end of the line. Again this means that the error occurs before that.

CSD 340 (Blum)11 Unterminated string constant The error Unterminated string constant means that we have started a string constant (or literal string – something between quotation marks) but did not finish it. We should be looking for a missing quotation mark.

CSD 340 (Blum)12 Another HTML document with an JavaScript error. Misspelled “alert” – function name.

CSD 340 (Blum)13 Error message from Error2.htm

CSD 340 (Blum)14 Webopedia.com definition of runtime error

CSD 340 (Blum)15 Compile-time errors are also known as syntax errors because the are violations of the language’s rules.

CSD 340 (Blum)16 Syntax versus runtime errors. The statement alert("Hi there); has a syntax error. The rules say there should be a closing quote and there is not. The statement alrt("Hi there"); obeys the rules. We could have defined our own function alrt as opposed to having misspelled the predefined function alert.

CSD 340 (Blum)17 Whatis.com definition of object.

CSD 340 (Blum)18 Line: 11 Error: Object expected As said earlier, the statement alrt("Hi there"); would have been fine if alrt would have been defined. The error message is saying that it expects an object (or a function which is part of an object) to be defined to make logical sense of the statement.

CSD 340 (Blum)19 Line 11 highlighted, but real error is on Line 12. It’s saying that it expects the definition on some earlier line.

CSD 340 (Blum)20 Swap.htm viewed in browser (1)

CSD 340 (Blum)21 Swap.htm viewed in browser (2)

CSD 340 (Blum)22 Swap.htm viewed in browser (3)

CSD 340 (Blum)23 Swap.htm viewed in browser (4)

CSD 340 (Blum)24 Pre-swap code declares string variables which are image file names and uses them to them to create tag code.

CSD 340 (Blum)25 The first step of the swap is have the extra swap variable take on the value of one of the other variables. This is accomplished by the statement Swap=Image1; If the statement were written the other way around, we would have two undefined values.

CSD 340 (Blum)26 The second step is to let Image1 (the variable whose value we placed in the Swap variable) take on the value of Image2 (the other variable). This is accomplished by Image1=Image2; If the statement were written the other way around, then all three variables would equal “Sun.gif” and we would have lost (irretrievably) all knowledge of “Moon.gif”

CSD 340 (Blum)27 The third and final step of the swap is to let Image2 (the second variable) take on the original value of Image1 (as opposed to the current value of Image1) – this was held in the Swap variable. This is accomplished by the statement Image2=Swap; If the statement were written the other way around, all three variables would have the value “Moon.gif” and we would have lost (irretrievably) all knowledge of “Sun.gif”

CSD 340 (Blum)28 Possible Mistake 1: Image1=Swap; Image1=Image2; Image2=Swap;

CSD 340 (Blum)29 Possible Mistake 2: Swap=Image1; Image2=Image1; Image2=Swap;

CSD 340 (Blum)30 Possible Mistake 3: Swap=Image1; Image1=Image2; Swap=Image2;

CSD 340 (Blum)31 References Beginning JavaScript, Paul Wilton