0
Microsoft® Small Basic<br />Clock, Desktop, and Dictionary Objects<br />Estimated time to complete this lesson: 1 hour<br />
Clock, Desktop, and Dictionary Objects<br />In this lesson, you will learn about:<br />Using different properties of the C...
The Clock Object<br />Let’s explore some properties of the Clock object…<br />Small Basic provides you with a Clock object...
Date, Weekday, and Time<br />You can use the Date property, the WeekDay property, and the Time property of the Clock objec...
The Year Property<br />You can use the Year property of the Clock object to get the current system year.<br />Let’s take a...
 You can use the Month and the Day property of the Clock object to get the current month and current day, respectively.<br...
Hour, Minute, and Second<br /> <br />You can get the current hour, minute, and second of the day with the help of the Hour...
The Desktop Object<br />In addition, you can also retrieve the size of your current desktop and use the information to spe...
The Desktop Object<br />You can use the Height and Width properties of the Desktop object to get the screen height and wid...
The Dictionary Object<br />Dictionary is a useful resource that you can include as part of your Small Basic program.<br />...
The Dictionary Object<br />You can use the GetDefinitionoperation to obtain the meaning of a word, in English. For the def...
Let’s Summarize…<br />Congratulations! Now you know how to:<br />Use different properties of the Clock object.<br />Use di...
It’s Time to Apply Your Learning…<br />Create a program to set an alarm that plays a bell ring sound and changes the wallp...
Upcoming SlideShare
Loading in...5
×

2.5 clock, desktop, and dictionary objects

456

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
456
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

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 = (&quot;Current Date: &quot; + date + &quot;,&quot; + &quot;Current Weekday: &quot; + weekday + &quot;,&quot; + &quot; Current Time: &quot; + time)GraphicsWindow.DrawBoundText(40, 40, GraphicsWindow.Width, display)
  • Code:TextWindow.WriteLine(&quot;Enter the year of your birth:&quot;)birthyear = TextWindow.Read()age = Clock.Year - birthyearTextWindow.WriteLine(&quot;Your age is &quot; + age + &quot;.&quot;)
  • You must be connected to the Internet to use the Dictionary object in Small Basic.
  • Code:txt = &quot;Magnanimous&quot;GraphicsWindow.FontName = &quot;verdana&quot;GraphicsWindow.FontSize = 24GraphicsWindow.BrushColor = &quot;Black&quot;GraphicsWindow.DrawText(10, 10, txt)defn = Dictionary.GetDefinition(txt)GraphicsWindow.FontSize = 12GraphicsWindow.BrushColor = &quot;Black&quot;GraphicsWindow.DrawText(10, 60, defn)
  • Solution:subSetAlarm()imagePath = program.Directory + &quot;desk.jpg&quot; up:IfClock.Time = alarm ThenDesktop.SetWallPaper(imagePath) Sound.PlayBellRing() EndIfProgram.Delay(1000)Goto up SubsubSetAlarmTextWindow.WriteLine(&quot;Set Alarm&quot;)TextWindow.Write(&quot;Enter Hour: &quot;) hour = TextWindow.Read()TextWindow.Write(&quot;Enter Minute: &quot;) minute = TextWindow.Read()TextWindow.Write(&quot;AM/PM?: &quot;)AmPmStatus = TextWindow.Read() alarm = hour + &quot;:&quot; + minute + &quot;:00 &quot; + AmPmStatusTextWindow.WriteLine(&quot;Alarm Time: &quot; + alarm)EndSub
  • Transcript of "2.5 clock, desktop, and dictionary objects"

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

      Clipping is a handy way to collect important slides you want to go back to later.

    ×