Microsoft® Small Basic

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
SCRATCH Lesson Two – Interactive Concepts Using Sensing, Operators, and Variables.
Microsoft® Small Basic
Microsoft® Small Basic
Microsoft® Small Basic Statements, Properties, and Operations Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic
Microsoft® Small Basic Clock, Desktop, and Dictionary Objects Estimated time to complete this lesson: 1 hour.
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
Microsoft® Small Basic Sharing Code Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic Clock, Desktop, and Dictionary Objects Estimated time to complete this lesson: 1 hour.
Microsoft® Small Basic The Controls Object Estimated time to complete this lesson: 1 hour.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 8: String Manipulation
Microsoft® Small Basic
An Introduction to Textual Programming
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Arrays and File Handling
CRE Programming Club - Class 7 Robert Eckstein and Robert Heard.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Office Management Tools II Ms Saima Gul. Office Management Tools II Ms Saima Gul.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
Illustration of a Visual Basic Program Running an Ada Program 1 by Richard Conn 11 September 1999.
Alice in Action with Java Chapter 4 Flow Control.
Chapter 10 So Many Paths … So Little Time (Multiple-Alternative Selection Structures) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Animations & Multimedia LESSON 9 #2.09 USING ANIMATION AND MULTIMEDIA.
var variableName:datatype;
C++ Basic Input and Output (I/O)
Introducing Instructions
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Value-Returning Functions
Mail Merge And Macros in MS WORD
Computer Programming I
IF statements.
The Selection Structure
Introduction to Scripting
Visual programming Chapter 1: Introduction
Using Procedures and Exception Handling
Keyboard Input and Screen Display ––––––––––– Interactive Programming
Microsoft® Small Basic
Microsoft® Small Basic
More on Graphical User Interfaces
Starter Write a program that asks the user if it is raining today.
elppa legoog erawdrah erawtfos margorp Cisab llams Apple Google
Microsoft Word - Formatting Pages
Creating and Modifying Queries
Topics Introduction to File Input and Output
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Assignment 4 For this assignment refer to the notes on MATLAB from an MIT course that you can find here (or at the original website, lectures 14, 15, 16).
Microsoft® Small Basic
T. Jumana Abu Shmais – AOU - Riyadh
Microsoft® Small Basic
MyFloridaMarketPlace
HOW TO CREATE A CLASS Steps:
A look at Small basic The Text Window 2017.
Introduction to Database Programs
Data Groupings: File File: a group of related records
Flowcharts and Pseudo Code
Introduction to Database Programs
JavaScript: Introduction to Scripting
Basic Lessons 5 & 6 Mr. Kalmes.
Animations & Transitions
Topics Introduction to File Input and Output
CS 1111 Introduction to Programming Spring 2019
Presentation transcript:

Microsoft® Small Basic Sound, Program, and Text Objects Estimated time to complete this lesson: 1 hour

Sound, Program, and Text Objects In this lesson, you will learn about: Using the Program object to manage execution of Small Basic programs. Using the Sound object to enable playback of sounds in Small Basic programs. Using the Text object to work with text-related functions in Small Basic programs.

Introduction to the Program Object When creating programs and working with various objects and operations offered by Small Basic, you might want to control the execution of your program. You can use the Program object to manipulate how your program executes. To better understand the Program object, let’s take a look at the example displayed. In this example, notice the use of Delay and End operations. The Delay operation sets a fixed time delay for the program to execute, and the End operation ends the program execution. output You can control the execution of a program by using the Program object in Small Basic. Notice the example on the screen. First, you use the Directory operation to display the current directory of the executing program. To display the path of the directory, you use the TextWindow object with the WriteLine operation. Next, you want to delay the execution of the program by five seconds, so you use the Delay operation and define the parameter for time in milliseconds. The Program.End() statement forcefully ends the program execution. Check the output of your program by clicking the Run button on the toolbar or pressing F5 on the keyboard. The text window displays the program directory and, after a delay of five seconds, the program ends.

Exploring the Program Object Let’s take a look at an example to understand how you can use the Program object to determine the count and value of arguments passed to a program during execution. The Program object also allows you to retrieve information about the arguments passed to your program. You can also use operations in the program to determine information about the arguments passed to a program. For example, you can use the ArgumentCount operation to find out the number of command-line arguments passed to the program. Similarly, you can use the GetArgument operation that returns the specified argument. You need to provide the index value of the required argument as a parameter to the operation.

Introduction to the Sound Object After working with arguments and using the Program object, let’s explore some other interesting aspects of Small Basic. Look at the example displayed. You can work with sounds in your program by using the Sound object with operations such as Play, Pause, and Stop. Did you know that you could include sounds in your Small Basic programs? In fact, you can choose from sample sounds provided in the Small Basic library. The output of this example plays, pauses, and stops the specified sound file at regular intervals. To play a sound in your program, you use the Play operation of the Sound object. You specify the path of the local file or the URL of the file on the network as a parameter to the Play operation. Similarly, you use the Pause operation with the path of the file as the parameter. To stop playing the sound, use the Stop operation.   In addition, observe the use of the Delay operation of the Program object in the example. The Delay operation helps you delay the execution of commands. You can use various sound-file formats such as .mp3, .wav, or .wma in your Small Basic programs.

Exploring the Sound Object Now, let’s take a look at an example to understand how you can play specific sounds, such as a bell ring, chime, or click, in your Small Basic program. Observe the use of the PlayAndWait operation in the example. The PlayAndWait operation plays an audio file and waits until the audio has finished playing. In the previous example, you saw how to play a sound in your program by specifying the file path. The example here explains how to include sounds such as ringing bells, chimes, and clicks in your program. As you see, after an interval of one second, the program executes the command PlayBellRing() and plays the bell sound. Then after another second, the PlayChime() command is executed and plays the chime sound. Finally, after a delay of another second, the PlayClick() command executes and plays the click sound. The PlayAndWait operation plays an audio file and waits until the audio has finished playing. If the particular file is paused, then the operation resumes from the position where the audio playback was paused. The output will play the sound of a bell ringing, a chime, and a click, at regular intervals.

Introduction to the Text Object Small Basic also offers useful operations that help you work with text. In Small Basic, when working with text, you can use the Text object and its various functions and methods to perform operations on the text. For example, you may want to convert all names to uppercase. Alternatively, you may want to find out whether a portion of text contains specific information. Let’s learn some more operations of the Text object with an example... For example, to find out the length of a text string, you can use the GetLength operation. When working in Small Basic, you can perform operations on text by typing a statement containing the Text object.   Look at the example on the screen: First, you use the TextWindow object and the Write and Read operations to get the user’s first name and last name. You then append the last name to the first name by using the Append operation of the Text object. Next, to convert the appended text into uppercase, you use the ConvertToUpperCase operation. You must specify the variable name holding the assigned text as a parameter. Similarly, you can also use the ConvertToLowerCase operation to convert the text to lowercase. You can check the output of your program by clicking the Run button on the toolbar or pressing F5 on the keyboard.

More on the Text Object Let’s take a look at another example to understand some more operations of the Text object. In this example, the user inputs an e-mail address. Using the IsSubText operation of the Text object, you can determine whether the e-mail address is valid or not. You can use the Text object to check whether specific text or a character is a subset of the larger text. To demonstrate this, consider the displayed example. First, we use the Write and Read operations of the TextWindow object to receive an e-mail address from the user. Then we use the IsSubText operation of the Text object to determine whether the user has entered a valid e-mail address.

Operations of the Text Object Another operation of the Text object is the GetSubText operation. This operation takes three parametersthe text from which you want to derive the subtext, the location from where you want to derive the subtext, and the length up to which you want to derive the subtext. Here are some more uses of the Text object… To determine whether given text starts with specified subtext, you can use the StartWith or EndWith operations. To get the character code for a specific Unicode character, you can use the GetCharacterCode operation. To determine the index position of specific subtext, you can use the GetIndexOf operation.

Let’s Summarize… Congratulations! Now you know how to: Use the Program object to manage the execution of a Small Basic program. Use the various operations of the Sound object to include sounds in your Small Basic program. Use the Text object to operate on text in your Small Basic program.

It’s Time to Apply Your Learning… Write a program that displays a text window and perform the following steps: Ask the user to type an answer to a simple question. If the answer is correct, the program must display a success message along with a chime sound. If the answer is incorrect, the program must display the appropriate message along with the sound of a bell. Solution: TextWindow.Title = "Let’s take a quiz…"   TextWindow.WriteLine("Name the third planet from the Sun: ") answer = TextWindow.Read() If (Text.StartsWith(answer, "Earth") Or Text.StartsWith(answer, "earth")) Then Sound.PlayChime() TextWindow.WriteLine("You are absolutely right!") Else TextWindow.WriteLine("That is incorrect.") Sound.PlayBellRing() EndIf