跳转到内容

Microsoft Small Basic

维基百科,自由的百科全书

这是本页的一个历史版本,由P1ayer留言 | 贡献2011年5月13日 (五) 08:19 (添加 {{notchinese}}标记至条目,通過Friendly▫)编辑。这可能和当前版本存在着巨大的差异。

Microsoft Small Basic
File:Small Basic.png
Small Basic running on Windows 7
原作者Microsoft DevLabs
開發者Microsoft DevLabs
首次发布2008
当前版本Microsoft Small Basic v0.95(8th February 2011)
编程语言Microsoft .Net 3.5
操作系统Microsoft Windows
平台Microsoft Windows
类型Integrated development environment
网站http://www.smallbasic.com/

Microsoft Small Basic是一個經簡化過的BASIC程式語言,於Microsoft於2008年10月發表。 With a bare minimum of concepts, Microsoft touts this as an easy programming language for beginners to grasp. The language itself has only 14 keywords[1], and the environment is beginner friendly with a straight-forward interface. Since version 0.9 (11 June 2010)[2] no additional features have been added, just translations.

Microsoft Small Basic was designed by Microsoft DevLabs and released as a Technology Preview[3] in October 2008. Its intended audience is anyone looking to begin programming, including children and beginner adults as well.

程式語言

它最初是以微軟的QBasic程式語言做為基礎進行修改,但被移植到.Net Framework。以範例'Hello World'為例,必須寫成:

TextWindow.Write("Hello World")

或是:

TextWindow.Writeline("Hello World")

The first example just writes 'Hello World', but the second example writes 'Hello World' on a new line.

Note that traditional Basic variants, including Microsoft QuickBasic, used an easier syntax:

print "Hello World"

The language itself is Turing complete and supports concepts like conditional branching and loops. Variables are typeless and dynamic, and there are no scoping rules. The language supports subroutines and the runtime uses them for event handling purposes.

Conditional Branching

TextWindow.Write("Enter the temperature today (in F): ")
temp = TextWindow.ReadNumber()
If temp > 100 Then
  TextWindow.WriteLine("It is pretty hot.")
ElseIf temp > 70 Then
  TextWindow.WriteLine("It is pretty nice.")
ElseIf temp > 50 Then
  TextWindow.WriteLine("Don't forget your coat.")
Else
  TextWindow.WriteLine("Stay home.")
EndIf

For迴圈

TextWindow.WriteLine("Multiplication Tables")
table = 4
For i = 1 to 10
  TextWindow.WriteLine(i + " x " + table + " = " + table * i)
EndFor

Libraries

The software ships with a built in set of libraries which are quite modern and intended to grasp the learners' interest.

For example to change the desktop wallpaper to a variety of 10 mountain photos, the students would make use of a prebuilt "GetRandomPicture" method for Flickr so the code becomes simply:[4]

For i = 1 To 10
  pic = Flickr.GetRandomPicture("mountains")
  Desktop.SetWallPaper(pic)
  Program.Delay(10000)
EndFor

Turtle

Microsoft Small Basic ships with a Turtle graphics library that borrows the idea from Logo. For example, you can make the turtle draw a square by simply saying:

For i = 1 to 4
  Turtle.Move(100)
  Turtle.TurnRight()
EndFor

相較於其它的 Basic 語言, 例如 Microsoft QuickBasic, 它是使用

EndFor

而不是

Next i

Testing

The first trials were successfully done with several middle school children, most of them children of workers at Microsoft. Small Basic was also successfully tested using a hands-on lab approach to a group of 25 high school girls.[5]

References

外部連結