SlideShare una empresa de Scribd logo
1 de 11
Microsoft® Small Basic Debugging Aids Estimated time to complete this lesson: 1 hour
Debugging Aids In this lesson, you will learn about: Using the TextWindow.WriteLine operation to debug your programs.
Debugging  Even a minor bug in a program can defeat the efforts of the programmer! Debugging is a method of detecting and resolving bugs in your computer program. Every programmer develops the skill to detect bugs and debug his or her program. While working on large programs, programmers write debugging support code that is not included in the final program. This is to determine the point where a program fails to run.
TextWindow.WriteLine As a Debugging Helper So how can you debug programs in Small Basic? To debug your program, you can use the TextWindow.WriteLine operation. This operation acts as a debugging helper, and it provides information to help debug your program.
TextWindow.WriteLine As a Debugging Helper In this program, you first display an ellipse on the graphics window. In case your program does not run as expected, you need to debug it!  This is when you can use the TextWindow.WriteLine operation as a debugger. It can help you trace the value of “i” on every iteration of the For…EndFor loop. The value of “i” is displayed in a separate text window, enabling you to easily detect a bug and fix it. Let’s look at an example that uses the TextWindow.WriteLine operation for debugging.
TextWindow.WriteLine As a Debugging Helper Oh! The image you requested is not visible on the graphics window. It’s time to debug your code! Now, let’s use the TextWindow.WriteLine operation in another program and see how it can help you debug the program. In this example, you use the Flickr object to download a photo from www.flickr.com and display it on the graphics window.
TextWindow.WriteLine As a Debugging Helper One of the possibilities could be unavailability of an Internet connection or no access to the website.  To check this possibility, you can use the TextWindow.WriteLine operation for displaying the path of the image from the website. If the Internet connection is working fine, the path of the image will be displayed in the text window. Otherwise, the text window will not display any path. As you can see, the text window is not displaying the path of the image, which means you are not connected to the Internet.
 TextWindow.WriteLine As a Debugging Helper You may not see the contents of the file in the text window because: ,[object Object]
 The file may not be present at the specified source.
 The name of the specified file may be incorrect.Now, let’s write a program to copy a file and display its contents in the text window. Now how do we detect the error? It’s time to debug your code once again… In this example, if the CopyFileoperation is successful, the text window displays the contents of the file.
TextWindow.WriteLine As a Debugging Helper Let’s use the TextWindow.WriteLine operation to detect the error. You can modify your program and use  TextWindow.WriteLine to display the return value of the CopyFile operation in the text window  which will either be SUCCESS or FAILED. So, if your program is unable to run due to the CopyFile operation error, you immediately know about it!

Más contenido relacionado

La actualidad más candente

Programming language environments
Programming language environmentsProgramming language environments
Programming language environments
Mr McAlpine
 
Step by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAPStep by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAP
nityaabap
 
Creating a Personalized ipad Wallpaper
Creating a Personalized ipad WallpaperCreating a Personalized ipad Wallpaper
Creating a Personalized ipad Wallpaper
szanotti
 
Creating a package_in_abap_navigator
Creating a package_in_abap_navigatorCreating a package_in_abap_navigator
Creating a package_in_abap_navigator
nityaabap
 
How To Make A Quikmap
How To Make A QuikmapHow To Make A Quikmap
How To Make A Quikmap
satonner
 
How to add gadgets
How to add gadgetsHow to add gadgets
How to add gadgets
Ruth Aw
 
Amazing photoshop light effect in 10 steps
Amazing photoshop light effect in 10 stepsAmazing photoshop light effect in 10 steps
Amazing photoshop light effect in 10 steps
Irene Situmorang
 
Images & Dreamweaver
Images & DreamweaverImages & Dreamweaver
Images & Dreamweaver
jbellWCT
 

La actualidad más candente (16)

Moreno Xec
Moreno XecMoreno Xec
Moreno Xec
 
Small basic
Small basicSmall basic
Small basic
 
Programming language environments
Programming language environmentsProgramming language environments
Programming language environments
 
Step by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAPStep by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAP
 
Android application (how to add a splash screen with timer) tutorial #4
Android application (how to add a splash screen with timer) tutorial #4Android application (how to add a splash screen with timer) tutorial #4
Android application (how to add a splash screen with timer) tutorial #4
 
Creating a Personalized ipad Wallpaper
Creating a Personalized ipad WallpaperCreating a Personalized ipad Wallpaper
Creating a Personalized ipad Wallpaper
 
Stepshot Intro
Stepshot IntroStepshot Intro
Stepshot Intro
 
Android application (how to change the background) tutorial #3
Android application (how to change the background) tutorial #3Android application (how to change the background) tutorial #3
Android application (how to change the background) tutorial #3
 
Creating a package_in_abap_navigator
Creating a package_in_abap_navigatorCreating a package_in_abap_navigator
Creating a package_in_abap_navigator
 
How To Make A Quikmap
How To Make A QuikmapHow To Make A Quikmap
How To Make A Quikmap
 
Android application (how to change the icon )tutorial #2
Android application (how to change the icon )tutorial #2Android application (how to change the icon )tutorial #2
Android application (how to change the icon )tutorial #2
 
How to add gadgets
How to add gadgetsHow to add gadgets
How to add gadgets
 
812 wordpress tablet
812 wordpress tablet812 wordpress tablet
812 wordpress tablet
 
Amazing photoshop light effect in 10 steps
Amazing photoshop light effect in 10 stepsAmazing photoshop light effect in 10 steps
Amazing photoshop light effect in 10 steps
 
Android hello world application tutorial #1
Android hello world application tutorial #1Android hello world application tutorial #1
Android hello world application tutorial #1
 
Images & Dreamweaver
Images & DreamweaverImages & Dreamweaver
Images & Dreamweaver
 

Destacado (6)

3.3 the math object
3.3   the math object3.3   the math object
3.3 the math object
 
4.2 responding to events
4.2   responding to events4.2   responding to events
4.2 responding to events
 
4.1 playing with shapes
4.1   playing with shapes4.1   playing with shapes
4.1 playing with shapes
 
3.2 stacks and arrays
3.2   stacks and arrays3.2   stacks and arrays
3.2 stacks and arrays
 
4.4 advanced games
4.4   advanced games4.4   advanced games
4.4 advanced games
 
Mlp_winter-2015
Mlp_winter-2015Mlp_winter-2015
Mlp_winter-2015
 

Similar a 3.6 debugging aids

Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
An I
 
4007655 introduction-to-javascript
4007655 introduction-to-javascript4007655 introduction-to-javascript
4007655 introduction-to-javascript
Vikash Chandra
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
som_nangia
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfVISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
NALANDACSCCENTRE
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1
晟 沈
 
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docxLabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
DIPESH30
 

Similar a 3.6 debugging aids (20)

Java script hello world
Java script hello worldJava script hello world
Java script hello world
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
 
Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by Citytech
 
Programming Without Coding Technology (PWCT) Features - Framework & Extension
Programming Without Coding Technology (PWCT) Features - Framework & ExtensionProgramming Without Coding Technology (PWCT) Features - Framework & Extension
Programming Without Coding Technology (PWCT) Features - Framework & Extension
 
4007655 introduction-to-javascript
4007655 introduction-to-javascript4007655 introduction-to-javascript
4007655 introduction-to-javascript
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfVISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
 
Explaindio is a versatile tool for creating animated videos
Explaindio is a versatile tool for creating animated videosExplaindio is a versatile tool for creating animated videos
Explaindio is a versatile tool for creating animated videos
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1
 
Part1
Part1Part1
Part1
 
Slide 01
Slide 01Slide 01
Slide 01
 
Pixlr and small apps in the classroom
Pixlr and small apps in the classroomPixlr and small apps in the classroom
Pixlr and small apps in the classroom
 
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docxLabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
 
Developers Border Line: Unit Testing
Developers Border Line: Unit TestingDevelopers Border Line: Unit Testing
Developers Border Line: Unit Testing
 
Question 4 evaluation
Question 4  evaluationQuestion 4  evaluation
Question 4 evaluation
 
django
djangodjango
django
 
Membangun Desktop App
Membangun Desktop AppMembangun Desktop App
Membangun Desktop App
 
Copycat Site BluePrint - make money online fast
Copycat Site BluePrint - make money online fastCopycat Site BluePrint - make money online fast
Copycat Site BluePrint - make money online fast
 

Más de allenbailey

4.3 collision detection
4.3   collision detection4.3   collision detection
4.3 collision detection
allenbailey
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
allenbailey
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
allenbailey
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
allenbailey
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
allenbailey
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
allenbailey
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
allenbailey
 

Más de allenbailey (8)

4.3 collision detection
4.3   collision detection4.3   collision detection
4.3 collision detection
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
 
1.3 variables
1.3   variables1.3   variables
1.3 variables
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

3.6 debugging aids

  • 1. Microsoft® Small Basic Debugging Aids Estimated time to complete this lesson: 1 hour
  • 2. Debugging Aids In this lesson, you will learn about: Using the TextWindow.WriteLine operation to debug your programs.
  • 3. Debugging Even a minor bug in a program can defeat the efforts of the programmer! Debugging is a method of detecting and resolving bugs in your computer program. Every programmer develops the skill to detect bugs and debug his or her program. While working on large programs, programmers write debugging support code that is not included in the final program. This is to determine the point where a program fails to run.
  • 4. TextWindow.WriteLine As a Debugging Helper So how can you debug programs in Small Basic? To debug your program, you can use the TextWindow.WriteLine operation. This operation acts as a debugging helper, and it provides information to help debug your program.
  • 5. TextWindow.WriteLine As a Debugging Helper In this program, you first display an ellipse on the graphics window. In case your program does not run as expected, you need to debug it! This is when you can use the TextWindow.WriteLine operation as a debugger. It can help you trace the value of “i” on every iteration of the For…EndFor loop. The value of “i” is displayed in a separate text window, enabling you to easily detect a bug and fix it. Let’s look at an example that uses the TextWindow.WriteLine operation for debugging.
  • 6. TextWindow.WriteLine As a Debugging Helper Oh! The image you requested is not visible on the graphics window. It’s time to debug your code! Now, let’s use the TextWindow.WriteLine operation in another program and see how it can help you debug the program. In this example, you use the Flickr object to download a photo from www.flickr.com and display it on the graphics window.
  • 7. TextWindow.WriteLine As a Debugging Helper One of the possibilities could be unavailability of an Internet connection or no access to the website. To check this possibility, you can use the TextWindow.WriteLine operation for displaying the path of the image from the website. If the Internet connection is working fine, the path of the image will be displayed in the text window. Otherwise, the text window will not display any path. As you can see, the text window is not displaying the path of the image, which means you are not connected to the Internet.
  • 8.
  • 9. The file may not be present at the specified source.
  • 10. The name of the specified file may be incorrect.Now, let’s write a program to copy a file and display its contents in the text window. Now how do we detect the error? It’s time to debug your code once again… In this example, if the CopyFileoperation is successful, the text window displays the contents of the file.
  • 11. TextWindow.WriteLine As a Debugging Helper Let’s use the TextWindow.WriteLine operation to detect the error. You can modify your program and use TextWindow.WriteLine to display the return value of the CopyFile operation in the text window  which will either be SUCCESS or FAILED. So, if your program is unable to run due to the CopyFile operation error, you immediately know about it!
  • 12. Let’s Summarize… Congratulations! Now you know how to: Use the TextWindow.WriteLine operation to debug programs.
  • 13. It’s Time to Apply Your Learning… A program creates a slide show of images in the graphics window. All these images are stored in a local folder. With every mouse click, a new image is displayed in the graphics window. Use the TextWindow.WriteLine operation as a debugging helper by displaying the path of each image in the text window.

Notas del editor

  1.  Slide Notes:In this program, you first display an ellipse on the graphics window. Next, you use the SetOpacity operation of the Shapes object to set the opacity level of the ellipse. You place this code within a For…EndFor loop, to change the opacity with every single iteration. Similarly, you set the zoom level of the ellipse within the same loop.  In case your program does not run as expected, you need to debug it! This is when you can use the TextWindow.WriteLine operation as a debugger.  The TextWindow.WriteLine operation can help you trace the value of “i” on every iteration of the For…EndFor loop. The value of “i” gets displayed in a separate text window, enabling you to easily detect the bug and fix it.Code:GraphicsWindow.Height = 400GraphicsWindow.Width = 600Ellipse = Shapes.AddEllipse(200,200)Shapes.Move(Ellipse,200,100)For i = 1 To 5Program.Delay(1000)Shapes.SetOpacity(Ellipse,5*i) Shapes.Zoom(Ellipse,i * 0.4,i * 0.4) TextWindow.WriteLine("Value of i at this moment is " + i) EndFor 
  2. Code:Sourcepath = Program.Directory+"Sourcedata.txt"Destpath = Program.Directory+"dest"file.CopyFile(Sourcepath,Destpath)TextWindow.WriteLine(File.ReadContents(File.ReadContents(destPath+"data.txt")))
  3. Code:Sourcepath = Program.Directory+"Sourcedata.txt"Destpath = Program.Directory+"dest"TextWindow.WriteLine(file.CopyFile(Sourcepath,Destpath))TextWindow.WriteLine(File.ReadContents(File.ReadContents(destPath+"data.txt")))
  4. Solution:Please Note: Ensure that a folder containing the images exists at the path specified in the program.ImagePath = program.Directory + "img" i = 1GraphicsWindow.Width = 600GraphicsWindow.Height = 450GraphicsWindow.Top = (Desktop.Height-450) / 2GraphicsWindow.left = (Desktop.Width-600) / 2 GUI()SmallBasicImage = File.GetFiles(ImagePath) GraphicsWindow.DrawResizedImage(SmallBasicImage[i], 50, 50, 500, 300) Controls.ButtonClicked = SlideShowSub GUI GraphicsWindow.BackgroundColor="LightSlateGray" GraphicsWindow.FontSize=25 nxtBtn = Controls.AddButton("<",50,370) bckBtn = Controls.AddButton(">",500,370) Controls.SetSize(nxtBtn, 50, 50)Controls.SetSize(bckBtn, 50, 50) EndSubSubSlideShowIfControls.GetButtonCaption(Controls.LastClickedButton) = ">" ThenIfi < Array.GetItemCount(SmallBasicImage) Theni = i + 1 images[i] = ImageList.LoadImage(SmallBasicImage[i]) GraphicsWindow.DrawResizedImage(images[i], 50, 50, 500, 300) TextWindow.WriteLine("Image Name:" + SmallBasicImage[i]) EndIfEndIfIfControls.GetButtonCaption(Controls.LastClickedButton) = "<" ThenIfi > 1 Theni = i - 1 images[i] = ImageList.LoadImage(SmallBasicImage[i]) GraphicsWindow.DrawResizedImage(images[i], 50, 50, 500, 300) TextWindow.WriteLine("Image Name:" + SmallBasicImage[i]) EndIfEndIfEndSub