2.5 clock, desktop, and dictionary objects

Uploaded on


More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • We have used the DrawBoundText operation of the GraphicsWindow object. This operation will draw a line of text at the specified location. We have specified the x- and y-coordinates of the text starting point as 40 and 40. Code:date = Clock.Dateweekday = Clock.WeekDaytime = Clock.Timedisplay = ("Current Date: " + date + "," + "Current Weekday: " + weekday + "," + " Current Time: " + time)GraphicsWindow.DrawBoundText(40, 40, GraphicsWindow.Width, display)
  • Code:TextWindow.WriteLine("Enter the year of your birth:")birthyear = TextWindow.Read()age = Clock.Year - birthyearTextWindow.WriteLine("Your age is " + age + ".")
  • You must be connected to the Internet to use the Dictionary object in Small Basic.
  • Code:txt = "Magnanimous"GraphicsWindow.FontName = "verdana"GraphicsWindow.FontSize = 24GraphicsWindow.BrushColor = "Black"GraphicsWindow.DrawText(10, 10, txt)defn = Dictionary.GetDefinition(txt)GraphicsWindow.FontSize = 12GraphicsWindow.BrushColor = "Black"GraphicsWindow.DrawText(10, 60, defn)
  • Solution:subSetAlarm()imagePath = program.Directory + "desk.jpg" up:IfClock.Time = alarm ThenDesktop.SetWallPaper(imagePath) Sound.PlayBellRing() EndIfProgram.Delay(1000)Goto up SubsubSetAlarmTextWindow.WriteLine("Set Alarm")TextWindow.Write("Enter Hour: ") hour = TextWindow.Read()TextWindow.Write("Enter Minute: ") minute = TextWindow.Read()TextWindow.Write("AM/PM?: ")AmPmStatus = TextWindow.Read() alarm = hour + ":" + minute + ":00 " + AmPmStatusTextWindow.WriteLine("Alarm Time: " + alarm)EndSub


  • 1. Microsoft® Small Basic
    Clock, Desktop, and Dictionary Objects
    Estimated time to complete this lesson: 1 hour
  • 2. Clock, Desktop, and Dictionary Objects
    In this lesson, you will learn about:
    Using different properties of the Clock object.
    Using different operations of the Dictionary object.
    Using different properties and operations of the Desktop object.
  • 3. The Clock Object
    Let’s explore some properties of the Clock object…
    Small Basic provides you with a Clock object to include this logic in your programs.
    You can use the Clock object to write programs that use the system clock. The Clock object has different properties, such as Date, Hour, Time, and Year.
    While programming, you may encounter situations where you need to calculate time or perform certain actions based on the date and time.
  • 4. Date, Weekday, and Time
    You can use the Date property, the WeekDay property, and the Time property of the Clock object to get the current system date, day, and time respectively.
    Let’s look at an example that displays the current system date, day of the week, and time on the graphics window…
  • 5. The Year Property
    You can use the Year property of the Clock object to get the current system year.
    Let’s take an example that uses the Year property of the Clock object to calculate age…
    Click the button on the toolbar.
  • 6.  You can use the Month and the Day property of the Clock object to get the current month and current day, respectively.
    Month and Day
    In this example, the output window displays birthday wishes only if the month and the day entered by the user matches with the current system month and day.
    How about writing a program that greets you on your birthday?
  • 7. Hour, Minute, and Second
    You can get the current hour, minute, and second of the day with the help of the Hour, Minute, and Second properties of the Clock object.
    Let’s combine the Hour, the Minute, and the Second properties of the Clock object to display a digital clock on the graphics window…
  • 8. The Desktop Object
    In addition, you can also retrieve the size of your current desktop and use the information to specify the location of objects on the screen.
    Small Basic provides another object called Desktop. You can use this object to set a desktop wallpaper of your choice.
    Let’s explore the SetWallPaper operation of the Desktop object. You can choose your wallpaper from any local file or network file, or from an Internet URL.
  • 9. The Desktop Object
    You can use the Height and Width properties of the Desktop object to get the screen height and width, respectively, of the primary desktop.
    Let’s apply these properties on the graphics window.
  • 10. The Dictionary Object
    Dictionary is a useful resource that you can include as part of your Small Basic program.
    The Dictionary object has two operations—GetDefinitionand GetDefinitionInFrench
    Small Basic provides a Dictionary object that you can use to retrieve the meaning of a specified word from the online Dictionary service.
  • 11. The Dictionary Object
    You can use the GetDefinitionoperation to obtain the meaning of a word, in English. For the definition in French, use the GetDefinitionInFrenchoperation.
    For example, let’s use the GetDefinitionoperation to find out the meaning of the word, “Magnanimous.”
  • 12. Let’s Summarize…
    Congratulations! Now you know how to:
    Use different properties of the Clock object.
    Use different properties and operations of the Desktop object.
    Use different operations of the Dictionary object.
  • 13. It’s Time to Apply Your Learning…
    Create a program to set an alarm that plays a bell ring sound and changes the wallpaper of your desktop.