Microsoft small basic examples

Microsoft small basic examples DEFAULT

Small Basic Program Gallery - Listed By Category

First published on MSDN on Feb 17,

Authored by Ed Price

 

12/08/15 UPDATE : Oculus Rift Ball Bounce and Batting Practice (games), Database Sample and Wavelength to RGP Converter (Productivity), Clown: Parsed Pixels (Graphical), and Pendulum (Sciences). On 11/17/ Small Block Builder and Triple Six (Games). On 10/21/ Pendulum Clock 2 (Graphical). On 9/3/ Eora Duck Hunt. On 8/ Starfield Simulator 2 (Graphical). On 7/8: Walking Man (Graphical). On 6/ Added SBCraft (Games). On 6/ Added String Searcher. On 5/ Added Basketball Science, Darts (Games), and Collision Physics (Sciences).

 

=====================================

 

In this gallery, the programs are divided by category, subcategory, and then alphabetically. Here are of the best community-made Small Basic programs!

 

To Browse the programs listed only alphabetically, see Small Basic Program Gallery (alphabetical list).

 

You should also come back later, because this list will evolve over time.

 

Index:

 

 

 

 

 

 

 

 

 

 

 

      • Interactive Visualizations

 

 

 

 

 

 

 

 

 

 

 

 

 

Games


Action

Block Smasher V2 ( info ) by Behnam Azizi

 

Brick Wall ( info ) - by Stendec

 

Catch Game - by NaochanON

 

Click the Button - by Timo Sö

 

Darts - by NaochanON

 

Eurora Duck Hunt - by Jibba Jabba

 

Football Pong (P1 use S+D; P2 use K+L) - by Nonki Takahashi

 

Naochan Pong - by NaochanON

 

Oculus Rift: Ball Bounce ( info ) by Zock77

 

Stay Away from the Blue Ball - by Todd

 

Super Pong - by Litdev


Cards & Dice

Triple Six ( info ) - by Bluegrams


Exploration

Small Block Builder ( info ) - by Bluegrams


Mazes

3D Color RayCaster Maze - by Old Basic Coder

 

3D Maze - by Old Basic Coder

 

3D Maze (B&W) - by Pathdrc

 

Chomper (Packman) - by Anthony Yarrell /QBasicLover

 

Pacman Labyrinth - by LitDev

 

Smiley Maze - by Nik Coughlin

 

SnakeBite - by Davey Wavey

 

Snow Man Maze (Big) - by NaochanON

 

Snow Man Maze (Small) - by NaochanON

 

Star Catcher - by NaochanON

 

Turtle Maze ( info ) - by Nonki Takahashi


Shooters

- by Laurent20

 

Alien Barrage ( info ) - by LitDev

 

Asteroids V2 - by Jason Jacques + Community

 

Invader Game - by NaochanON (play locally for proper framerate)

 

Invaders - by JKrueg

 

Soda Pop Showdown - by JKrueg

 

Space Invaders - by Davey Wavey


Sports

Basketball - by NaochanON

 

Basketball Science - by Nonki Takahashi

 

Batting Practice - by Cody_M


Strategy/Puzzle

Chess Board - by Nonki Takahashi

 

Color Memory Game - by Martmen

 

Go Simulator - by Nonki Takahashi

 

Gorillas - by Rushworks

 

Minesweeper - by Nonki Takahashi

 

SBCraft - by Ardiezc Quazhulu

 

SokoCUTE - by kts99

 

TanCraft - by Behnam Azizi

 

Tankinator - by Zock77 & Cobra

 

Tetris - by Kenneth Kasajian

 

Tic Tac Toe (with menu) - by Nonki Takahashi

 

Tic Tac Toe (with tough AI) - by NaochanON

 

Tower of Hanoi - by Alex

 

 

 

Graphical


Animated

Aquarium - by Nonki Takahashi

 

Blimp - by Coding Cat

 

Christmas Tree with R2 - by Nonki Takahashi

 

Christmas Trees with Snow - by NaochanON

 

Fireworks - by NaochanON

 

Manta Rays Swimming - by NaochanON

 

Random Drawing - by Math Man & Coding Cat

 

Star Field Simulator - by JKrueg

 

Starfield Simulator 2 - by Florian Auer

 

Swimming Shark ( info ) - by NaochanON

 

Tornado & Snow - by NaochanON

 

Walking Man - by NaochanON

 

Wave - by NaochanON

 

Whale Sharks - by NaochanON


Clocks

Analogue Clock (with wood texture) - by Math Man

 

Analogue Clock (no background) - by Nicolas_br

 

Pendulum Clock - by Nonki Takahashi

 

Pendulum Clock 2 - by Kevin J

 

Pi Clock - by Math Man

 

Random Cat Clock - by NaochanON

 

Triangle Clock - by Nonki Takahashi

 

Water Clock - by NaochanON


Drawings

Ant - by NaochanON

 

Butterfly with Blue Wings - by NaochanON

 

Butterfly with Yellow Wings - by Math Man

 

Clown: Parsed Pixels ( info ) - by Jibba Jabba

 

Crab - by NaochanON

 

Heart - Plump - by NaochanON

 

Heart - Regular - by Nonki Takahashi

 

Heart - Skinny - by Nonki Takahashi

 

Monarch Butterfly - by Nonki Takahashi


Drawings with Input

Heart Generator - by Math Man (run locally)

 

Pyramid - by NaochanON (be patient)


Drawings with Messages

Blimp - by Coding Cat


Interactive Visualizations

Arrow - by Zock77

 

Atom - by Dudeson (follows mouse cursor)

 

Eyeballs - by Math Man

 

Starfield Simulator - by Florian Auer

 

 

 

Math


Animated Algorithms

Sorting Algorithm Demo - by Zeven


Converters

Decimal to Binary Converter - by Amir CPS

 

Number to Text - by Math Man

 

Text to Binary Converter - by Amir CPS


Fractals

Burning Ship Fractal - by Math Man

 

Julia Fractal - by Math Man

 

Mandelbrot Fractal - by Math Man

 

Mandelbrot Stripes Fractal - by Math Man

 

Mandelbrot Tricorn Fractal - by Math Man

 

Multibrot for D=3 - by Math Man

 

Multibrot for D=4 - by Math Man

 

Random Sierpinski Triangle - by RubikWizard

 

Sierpinski Triangle - by Stendec


Other Interactive

Happy Number Checker - by Math Man

 

 

 

Productivity


Art/Drawing

Blackboard - by Vijaye

 

Color Picker - by Suduadib

 

Shapes ( info ) - by Nonki Takahashi

 

Wavelength to RGB Converter - by Pappa Lapub


Computer Apps

Code Block Generator v ( info ) - by Nonki Takahashi

 

Database Sample - by litdev

 

Installer ( info ) - by Timo Sö

 

String Searcher - by Jibba Jabba


Map Based

Weather (USA) - by NaochanON


Math Apps

Abacus - by Harry Hardjono

 

Abacus Beads - by Nonki Takahashi

 

Calculator - by Alex

 

Graph - by NaochanON

 

Nonki Calculator - by Nonki Takahashi

 

Ruler - by Nonki Takahashi


Music/Sound

Metronome - by NaochanON

 

Music Player ( info ) - by Amir CPS, NaochanON , and Absolu

 

Piano - by Nonki Takahashi (run locally)

 

 

 

Sciences


Astronomy

Moon Phases - by NaochanON


Physics

Balance Scale - by NaochanON

 

Cargo Weight - by NaochanON

 

Collision Physics - by Litdev

 

Light Beam - by Math Man

 

Light Beam - Interactive - by Zock77 (press up and down to rotate the reflector)

 

Pendulum ( info ) - by Jibba Jabba

 

Spring - by NaochanON

 

 

 

Sound

 

Metronome - by NaochanON

 

Piano - by Nonki Takahashi (run locally)

 

 

 

Text


Animated

LED Display - by Amir CPS


Ciphers

Vigenère Cipher ( info ) - by Amir CPS (run locally)


Interactive

Silly Story Writer - by Talgon96 (run locally)

 

Text Writer - by Todd

 

 

 

This idea was inspired by Rene Miner in these comments .

 

Leave a comment with more programs to add. We'll need a name for the program, a category/subcategory it belongs in, a link to download/view it, and the name and profile link of the developer.

 

Thanks!

 

- Ninja Ed

Sours: https://techcommunity.microsoft.com/t5/small-basic-blog/small-basic-program-gallery-listed-by-category/ba-p/

3 Easy Coding Projects for Kids Using Microsoft Small Basic

Learning to code can be daunting, especially for children. The combination of having to learn complicated syntax alongside programming concepts is enough to put many people off. Nevertheless, learning to code is one of the most important things your kids can learn, and tools are available to make it easier for them.

One such tool is Microsoft Small Basic, which is easy to get started with. Here are three projects kids can use to take their first strides into coding.

What Is Microsoft Small Basic?

Microsoft Small Basic (MSB) is a language designed to make it easier to learn the basics of coding. Aimed at children (but perfect for adults too), it provides a stripped-back language and a user-friendly interface. Now in its 10th year, MSB is a forgiving integrated development environment that allows some wiggle room with syntax.

This helps avoid some of the frustrations beginner coders can typically experience.

This project is a walkthrough of coding a personalized clock. The project covers simple programming concepts, and while aimed at children, beginner adults can also benefit from following along. While the IDE can be downloaded to computers running Microsoft Windows, today's tutorial uses the web based IDE. It can be completed on any computer with a browser and an internet connection.

Getting Started With Microsoft Small Basic

To begin, open a web browser and navigate to smallbasic.com. You should see a website with these two buttons in the middle:

Click on the button Start button, and you will be taken to a screen that looks like this:

This is an online version of the Microsoft Small Basic IDE. An online IDE is a place where you can write code and test it, all in one place. As you can see, there is already some code in the text window. Press the blue, triangular, Run button to see what the code does.

Press the little x in the top right corner to close the program. Look at the code. You will see that whatever is inside the brackets gets printed when you run the program. Try changing the word World to your name and click run again. If it didn't work, then make sure that you still have the quotation marks in the brackets ("text") like this:

To understand why this happens, let's break down the line into pieces. It starts with TextWindow. This tells the computer that whatever comes next should happen to the text window. TextWindow.WriteLine means that we want the TextWindow to write a line. TextWindow.WriteLine("Hello, Ian!") means we are telling the TextWindow to write a line, and what is in the brackets is what gets written!

1. Ask for a Name

Now, you are going to change your program to ask for the user's name when it begins. Start with the obvious question:

To get the user's input, we need two things. A way to read what they type in, and a place to keep it. This line gives you both:

This line makes a variable called name. A variable is like a box to store data inin this case, the user's name.

Next, there is an equals sign (=). This means that whatever comes next will be stored inside name.

Then you tell the TextWindow to Read what the user types in. Don't forget the bracketseven though they are empty, the computer needs them to know what to do!

Now, when the program runs, the user is asked their name. When they type it and press enter it is stored. All that is left is to tell the computer to print it back to them.

You'll notice that not everything in the WriteLine brackets has quotation marks. This is because you are combining saying "Hello, " with whatever is stored in the name variable, using a plus sign. This is called string concatenation. Don't worry if you don't understand what that means yetit's a good phrase to know later on when you're more comfortable with programming, or have taken a programming course. Now when you run your program, the user gets a personal response.

2. Telling the Time

So far your program greets each user by name. Now you can make it tell them the time using Clock.Time. Add it to the same line you just made:

Note where there are quotation marks and where there aren't. Also, make sure you include all of the plus signs in the right place. Getting this right is important! Run your code againalong with your greeting, you'll see the time.

Great! If you are getting any errors, or you are missing any spaces in the text window, look carefully over your code for any mistakes.

3. Making It Personal

Now that you have your clock let's make it so that it only works for you. We need a way of checking that the name that's entered is your name. We do this with an if statement. Change your code to look like this:

By adding the word If to the code, the computer knows that it has to check something. This time, you want to check if the name variable matches your name, using the equals sign.

So far, if the name variable that the user typed in equals your name, it will tell you the time. What happens if someone else uses the program?

That is what the Else statement is for. If any other name is typed in, the program skips over the if statement, and does whatever it says after Else.

Finally, type EndIf so that the computer knows that the if statement is over. Now when you run the program you will get a different response back depending on if you enter your name or not:

You just coded a clock that works for you, and greets anyone else who uses it!

Learning More With Microsoft Small Basic

This project has some essential basic concepts for programming. Using a simplified IDE allows beginners to learn programming concepts and get used to coding syntax. This can help down the line with more complicated languages like Python.

Microsoft Small Basic is not the only way to learn, and if actual code is a little too much at this stage, you have other options.

Scratch is a purely visual language that is perfect for kids. There are also several educational elements to Minecraft designed to teach core concepts. Minecraft's Hour of Code provides a familiar learning environment for intrepid young builders!

Image Credit: olly18/Depositphotos

ShareTweetEmail

7 Amazing Art Apps to Give You Creative Inspiration

Got a creative block, or just looking for some new ideas? These inspiring Android and iPhone apps will get your creative juices flowing again.

Read Next

About The Author
Ian Buckley ( Articles Published)

Ian Buckley is a freelance journalist, musician, performer and video producer living in Berlin, Germany. When he's not writing or on stage, he's tinkering with DIY electronics or code in the hope of becoming a mad scientist.

More From Ian Buckley

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

Click here to subscribe

Sours: https://www.makeuseof.com/tag/microsoft-small-basic-coding-projects/
  1. Trulia park ridge il
  2. Oblivion daedric quests
  3. Mccann family now

Microsoft Small Basic

Program Listing: XZG

'***************************************************************************************
'Sample program to demonstate virtually all of the SmallBasic GraphicsWindow commands
'Includes use of Shapes, Images, Arrays, Mouse and Keyboard control
'Does all of the main features required to write games using basic examples
'You will need to look at the code to see what is supposed to happen and how it is done
'Play with it, change it, break it then fix it
'***************************************************************************************
'
'Create a graphics window
'
'Keep it hidden till we want to show it
GraphicsWindow.Hide()
'Give it a title
GraphicsWindow.Title = "Graphics Window Example"
'Set its size and position (use variables gw and gh because they may be useful later)
gw =
gh =
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
'The top and left = 4 position the window neatly in the top left of the screen
GraphicsWindow.Top = 4
GraphicsWindow.Left = 4
'Set a background colour
GraphicsWindow.BackgroundColor = "LightBlue"
'Set it so it cannot be resized
GraphicsWindow.CanResize = "False"
'Show the window
GraphicsWindow.Show()
'Goto end
'
'Create a red ball of diameter 50 (radius 25) and place it in the middle of the window (leave it there for 5 seconds)
'
radius = 25
GraphicsWindow.BrushColor = "Red"
GraphicsWindow.PenColor = "Black"
' We set the position to be the (screen centre - radius), since the screen position is defined as the top left of the ball
ball = Shapes.AddEllipse(2*radius,2*radius)
Shapes.Move(ball,gw/2-radius,gh/2-radius)
Program.Delay() ' milliseconds = 5 seconds
'
'Move the ball randomly by animation 10 times (once per second)
'
For i = 1 To 10
x = Math.GetRandomNumber(gw)
y = Math.GetRandomNumber(gh)
Shapes.Animate(ball,x-radius,y-radius,)
Program.Delay() ' We have to delay (pause) to wait for the animation to finish
EndFor
'
'Move the ball to follow the mouse for 10 seconds
'
start = Clock.Second
time = 0
While (time < 10)
xm = GraphicsWindow.MouseX
ym = GraphicsWindow.MouseY
Shapes.Move(ball,xm-radius,ym-radius)
time = Clock.Second - start
'If we go over the minute then seconds go back to 0 so add 60 seconds
If (time < 0) Then
time = time+60
EndIf
'Display the mouse coordinates - first overwrite the last output
GraphicsWindow.PenColor = GraphicsWindow.BackgroundColor
GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor
GraphicsWindow.FillRectangle(gw,10,,30)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = 20
GraphicsWindow.DrawText(gw,10,"("+xm+","+ym+")")
EndWhile
'
'Use 10 balls and move the one selected by the mouse left down (delete with right down)
'Run until all balls are deleted
'The moved balls change colour
'
GraphicsWindow.Clear()
'Create an array of 10 balls and their random positions
nball = 10
For i = 1 To nball
GraphicsWindow.BrushColor = "LightGreen"
GraphicsWindow.PenColor = "Black"
x[i] = radius + Math.GetRandomNumber(gw-2*radius)
y[i] = radius + Math.GetRandomNumber(gh-2*radius)
ball = Shapes.AddEllipse(2*radius,2*radius)
Shapes.Move(ball,x[i]-radius,y[i]-radius)
balls[i] = ball
EndFor
start = Clock.Second
iball = 0
While (nball > 0)
If (Mouse.IsLeftButtonDown = "True") Then
xm = GraphicsWindow.MouseX
ym = GraphicsWindow.MouseY
'If no ball selected, then check if we are over one
If (iball = 0) Then
For i = 1 To nball
If (xm >= x[i]-radius And xm <= x[i]+radius And ym >= y[i]-radius And ym <= y[i]+radius) Then
iball = i
'To change the colour we delete it and replace it with a new ball
GraphicsWindow.BrushColor = "Pink"
Shapes.Remove(balls[iball])
balls[iball] = Shapes.AddEllipse(2*radius,2*radius)
'We are finished and don't want to continue checking since we have already deleted a ball so end this loop
Goto completed1
EndIf
EndFor
EndIf
completed1:
'Move selected ball
If (iball > 0) Then
ball = balls[iball]
x[iball] = xm
y[iball] = ym
Shapes.Move(ball,x[iball]-radius,y[iball]-radius)
EndIf
Else
'drop current ball
iball = 0
EndIf
'Delete a ball with right click
If (Mouse.IsRightButtonDown = "True") Then
xm = GraphicsWindow.MouseX
ym = GraphicsWindow.MouseY
For i = 1 To nball
If (xm >= x[i]-radius And xm <= x[i]+radius And ym >= y[i]-radius And ym <= y[i]+radius) Then
'Remove the displayed object
Shapes.Remove(balls[i])
'Now remove the array element i - we do this by overwriting it with the balls further up the array
For j = i To nball-1
balls[j] = balls[j+1]
x[j] = x[j+1]
y[j] = y[j+1]
EndFor
'Delete the last ball (now moved up the array 1 place)
balls[nball] = ""
x[nball] = ""
y[nball] = ""
'Reduce the count of balls
nball = nball-1
'We are finished and don't want to continue checking since we have already deleted a ball so end this loop
Goto completed2
EndIf
EndFor
EndIf
completed2:
EndWhile
'
'Replace the ball with an image and move with arrow keys for 20 seconds
'
'Delete the last ball and set a new one as a downloaded image - get its radius
GraphicsWindow.Clear()
image = ImageList.LoadImage("http://www.iconarchive.com/icons/artua/soccer/footballxpng")
ball = Shapes.AddImage(image)
radius = ImageList.GetWidthOfImage(image)/2
'Set variables to say if keys are pressed or not
keyLeft = 0
keyRight = 0
keyUp = 0
keyDown = 0
'Start an event for keydown and keyup
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.KeyUp = OnKeyUp
'Use the event to set the keypress flags - these are only called when a key is pressed or released
Sub OnKeyDown
key = GraphicsWindow.LastKey
If (key = "Left") Then
keyLeft = 1
ElseIf (key = "Right") Then
keyRight = 1
ElseIf (key = "Up") Then
keyUp = 1
ElseIf (key = "Down") Then
keyDown = 1
EndIF
EndSub
Sub OnKeyUp
key = GraphicsWindow.LastKey
If (key = "Left") Then
keyLeft = 0
ElseIf (key = "Right") Then
keyRight = 0
ElseIf (key = "Up") Then
keyUp = 0
ElseIf (key = "Down") Then
keyDown = 0
EndIF
EndSub
'Start in window centre
x = gw/2
y = gh/2
start = Clock.Second
time = 0
While (time < 20)
'Update position if a key is currently down
If (keyLeft = 1) Then
x = x-1
EndIf
If (keyRight = 1) Then
x = x+1
EndIf
If (keyUp = 1) Then
y = y-1 ' The pixes for the window increase downwards from the top
EndIf
If (keyDown = 1) Then
y = y+1
EndIf
'Check for ball leaving screen - reneter other side
If (x < 0) Then
x = gw
EndIf
If (x > gw) Then
x = 0
EndIf
If (y < 0) Then
y = gh
EndIf
If (y > gh) Then
y = 0
EndIf
'Move the ball to the new position
Shapes.Move(ball,x-radius,y-radius)
'Put a small delay in - the computer is too quick - this controls the update rate (frames per second)
'This is not the true fps since it doesn't account for the time drawing etc
fps =
Program.Delay(/fps)
time = Clock.Second - start
'If we go over the minute then add 60 seconds
If (time < 0) Then
time = time+60
EndIf
EndWhile
'
'Now use the arrow keys to accelerate the ball and run until 50 wall hits (almost the same code)
'We can use the keyboard events unchanged
'Reverse spin the ball when we hit a boundary
'
'Start in window centre
x = gw/2
y = gh/2
'Zero initial velocity
u = 0
v = 0
start = Clock.Second
spin = 'Ball spin rate (Positive is anticlockwise)
angle = 0
hits = 0
While (hits < 50)
'Update position if a key is currently down
If (keyLeft = 1) Then
u = u-1
EndIf
If (keyRight = 1) Then
u = u+1
EndIf
If (keyUp = 1) Then
v = v-1 ' The pixes for the window increase downwards from the top
EndIf
If (keyDown = 1) Then
v = v+1
EndIf
'Update position - divide by to stop the acceleration being too extreme
'we can do gravity, friction etc here if we want
x = x+u/
y = y+v/
'Check for ball leaving screen - bounce the ball this time - and spin it
If (x < radius) Then
u = -u
spin = spin+v
hits = hits+1
EndIf
If (x > gw-radius) Then
u = -u
spin = spin-v
hits = hits+1
EndIf
If (y < radius) Then
v = -v
spin = spin-u
hits = hits+1
EndIf
If (y > gh-radius) Then
v = -v
spin = spin+u
hits = hits+1
EndIf
'Move the ball to the new position
Shapes.Move(ball,x-radius,y-radius)
'Rotate the ball with the current spin direction
Shapes.Rotate(ball,angle)
angle = angle+*spin
'Put a small delay in - the computer is too quick - this controls the update rate (frames per second)
'This is not the true fps since it doesn't account for the time drawing etc
fps =
Program.Delay(/fps)
EndWhile
'
'Create an array of 10 randomly sized and coloured rotating boxes, then delete them when clicked with the mouse
'
GraphicsWindow.Clear()
'Create arrays of boxes and their positions and sizes
For i = 1 To 10
x[i] = 20+Math.GetRandomNumber(gw) ' not too close the the screen edge
y[i] = 20+Math.GetRandomNumber(gh)
w[i] = 10+Math.GetRandomNumber(30)
h[i] = 10+Math.GetRandomNumber(30)
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
GraphicsWindow.PenColor = "Black"
box = Shapes.AddRectangle(w[i],h[i])
'Note x[i],y[i] are top left of box, not its centre
Shapes.Move(box,x[i],y[i])
boxes[i] = box
display[i] = 1 ' flag that box is displayed
EndFor
'Start a mouse click event
GraphicsWindow.MouseDown = OnMouseDown
'Write the mouse click event to get coordinates of mouse click and set a flag that the mouse was clicked
clicked = 0
Sub OnMouseDown
xm = GraphicsWindow.MouseX
ym = GraphicsWindow.MouseY
clicked = 1
EndSub
'Continue while boxes remain
nboxes = Array.GetItemCount(boxes)
angle = 0
While (nboxes > 0)
'Mouse was clicked
If (clicked = 1) Then
'Check each box
For i = 1 To Array.GetItemCount(boxes)
'Only look for remaining displayed boxes
If (display[i] = 1) Then
box = boxes[i]
'Since the boxes are rotating use the maximum size to check for click region
'This is not exactly correct for rotating boxes but often in games efficient is more important than absolute correctness
dmax = Math.Max(w[i],h[i])
If (xm >= x[i] And xm <= x[i]+dmax And ym >= y[i] And ym <= y[i]+dmax) Then
'Delete this box from display and reduce the box count by 1
'Note the original arrays are not deleted since we are keeping track of box status using display[i]
Shapes.Remove(box)
nboxes = nboxes-1
display[i] = 0
Sound.PlayClick()
EndIf
EndIf
EndFor
'Reset clicked flag to off since we have done everything with it
clicked = 0
EndIf
'Rotate the boxes (even i anticlockwise, odd i clockwise - negative angle)
For i = 1 To Array.GetItemCount(boxes)
If (display[i] = 1) Then
box = boxes[i]
Shapes.Rotate(box,angle*(*Math.Remainder(i,2)))
EndIf
EndFor
angle = angle+1
Program.Delay(10) ' Small delay to keep the rotation smooth
EndWhile
'
'Finish up
'
end:
image = ImageList.LoadImage("http://www.windowswiki.info/wp-content/uploads/smallbasic_logo.png")
GraphicsWindow.Clear()
GraphicsWindow.FontSize =
GraphicsWindow.FontBold = "True"
GraphicsWindow.FontName = "Rockwell"
GraphicsWindow.DrawResizedImage(image,0,0,gw,gh)
R =
G = 0
B = 0
dR = -1
dG = 2
dB = 3
clicked = 0
While (clicked = 0)
'Change the red, green, blue components of the colour at different rates to get changing colours
If (R < 0 Or R > ) Then
dR = -dR
R = R+dR
EndIf
If (G < 0 Or G > ) Then
dG = -dG
G = G+dG
EndIf
If (B < 0 Or B > ) Then
dB = -dB
B = B+dB
EndIf
colour = GraphicsWindow.GetColorFromRGB(R,G,B)
GraphicsWindow.BrushColor = colour
GraphicsWindow.DrawText(,,"All Done")
GraphicsWindow.DrawText(,,"Click to Exit")
GraphicsWindow.PenWidth = 10
GraphicsWindow.PenColor = colour
GraphicsWindow.DrawLine(50,gh,gw,gh)
GraphicsWindow.DrawLine(gw,gh,gw,50)
GraphicsWindow.DrawLine(gw,50,50,50)
GraphicsWindow.DrawLine(50,50,50,gh)
R = R+dR
G = G+dG
B = B+dB
Program.Delay(20)
EndWhile

Program.End()



Sours: http://smallbasic.com/program/?XZG

The Small Basic Environment

The Small Basic screen has three main components: The Editor, the Toolbar, and the Help Panel. When you first launch Small Basic, you will see a window that looks like the following image (Figure 1).

The Intellisense Helper

When you start typing in the Editor, a window pops up with suggestions that may help you. Figure 2 shows that after typing “gra”, the intellisense window series of suggestions with “GraphicsWindow” highlighted. We can click on this or simply hit “Enter” to accept it. Or you can scroll through the alternate suggestions using the arrow keys, the mouse wheel, or the scroll bar on the right. As you get familiar with the editor, this feature will make it easier and faster to write your programs.

A screenshot of the intellisense helper which displays the suggestion GraphicsWindow after "gra" is typed.

Note: The online version of Intellisense is not as fancy as this one, but it functions the same way

As we will be adding graphics to our game, we will be using the GraphicsWindow component for our output. One of the advantages of this is the ability to use Unicode characters and our heritage language for programming AND display. This is exciting, because even though the programming keywords are in English, we can use any desired language for programming and interacting with the player. Though the code samples in this guide are in English, you will find alternative examples to highlight how code can be written using a First Nation language. The alternative examples in this module are presented in Plains Cree SRO as well as Cree syllabics.

Getting Started: “Welcome to Turtle Island” Program

Our first program is a basic “Welcome to Turtle Island” program that runs in a graphics window. In the editor type the following line of code:

A screenshot of the "Welcome to Turtle Island" program line of code.

That’s it! It is that simple! Press the Run button or hit the shortcut key (F5) and you should see a window similar to Figure 3.

GraphicsWindow after running the Turtle Island program which displays the "Welcome to Turtle Island" message.

It is a good practice to save your programs frequently just in case the power goes out, or the computer locks up, you don’t want to lose all your hard work.

To keep this program, close the running program window or hit the “End Program” button in your Editor window. Then click the Save or Save As button. Choose a file name and save it.

Toolbox

Now that we have written our first program, let’s have a look at all the individual tools we will need to make our Pathfinder text game. Regardless of the programming language you choose, there are some common terms and concepts that nearly all programming languages have. The ones we will be exploring in this module are:

  1. variables,
  2. conditional statements (also known as IF-THEN-ELSE),
  3. loops (sometimes known as FOR-NEXT statements), and
  4. subroutines.

1. Variables

A variable is a “token” we can use to store data that we want to use later, and can be changed as the needs of our program changes. Here are a couple examples:

In this example you will see that our variable name is all one word and has both upper and lower case characters. Variables must be a single word unit, cannot be a number, and though it is not necessary to use upper and lower cases it is good practice to do this to make it easier for others to read.

Code examples of variables.

If all goes well, you should get the same result as the first program, so let’s jazz it up a bit. If you added the number addition section (lines 6 – 9 in the example), you will see how the “+” character behaves when used to add numbers or put words together. You can take this time to play around with the position of your DrawText lines by changing the numbers too!

Tip: Variables are a great opportunity for us to use our heritage languages:
in Cree SRO, mawiswâkan = &#;ayoskanak&#;
in Cree Syllabics, ᒪᐃᐧᓵᐧᑲᐣ = &#;ᐊᔪᐢᑲᓇᐠ&#;

2. Conditional Statements

The If-Then-Else statement is easily understood by its literal English meaning which asks a question: if a certain condition is met, then something occurs. We can add an additional component to this called Else. So in basic English if the answer to our If question is true then do something otherwise (else) do something else. Try these:

Code example of conditional statements.

Notice the order of the IF statements. If we checked if time > 18 first, our greeting variable would say “Good Afternoon” at 6pm instead of “Good Evening” because the second If would check if it is after 12 and would change the greeting again. And there you go. That is how to use the IF THEN ELSE statement. Now let’s try some loops.

3. Loops/Looping

A loop is exactly what it sounds like – it loops, or repeats a set of instructions forever, or until a certain condition is met. We will often use a loop with an If statement. Let’s try this first:

Code examples of loops.
Code example of loops with conditional statements.

Here we have a couple new commands we can use: Clear() and Delay(). These will be very useful when we get to programming our game. We can make it loop forever (or until we stop) by adding the If statement in the second piece of code. And that’s how easy it is to make a loop!

4. Subroutines (Sub)

Quite often you will find that as you write a program you will encounter an instance where you are rewriting or reusing the same code over and over again. This is a perfect case for introducing a Subroutine.

A subroutine is a small section of code that does a series of common or routine steps that we can call from somewhere else in the program. Subroutines are instructions that fit between lines that start with Sub and end with EndSub.

In the following example, add a Random() as the first line after your For loop start line, and then add lines 12 to 14 and see what happens.

Code example with subroutines.

What is happening is when you use Random() in your code, the computer jumps to the Subroutine called Random. It then processes all the instructions in Sub Random and returns itself back to where you called it from and continues. You can think of subroutines as mini-programs.

The other new command here is Math.GetRandomNumber, which is very handy command. We will encounter more basic programming concepts as we put together our Pathfinder video game, but we can tackle those as they arise. For now, make sure you’re comfortable with the four ideas covered in this module:

  • Variables
  • Conditional statements (also known as IF-THEN-ELSE)
  • Loops (sometimes known as FOR-NEXT statements)
  • Subroutines

Almost all programming languages utilize these concepts, and knowing them will allow you to learn other languages more quickly.

Sours: https://pinnguaq.com/learn/pathfinder-series/pathfinderintroduction-to-programming-with-microsoft-small-basic/

Small basic examples microsoft

Introduction

Microsoft always makes the programming environment better and easy. Now, there is a new addition for programming learners that is called Small Basic. Small Basic is for any beginners who wants to learn programming. The new Small Basic IDE is similarl to MS Paint, which makes programmers to work and enjoy learning. I still remember my school days when I was in my high school. During our computer class, the teacher used to ask to start with MS Paint. By using MS paint, we started learning how to use mouse, etc. Now, I can say instead of teaching MS Paint to any new user we can ask them to Start with Small Basic, Yes, Small Basic will be easy for any new person who is working on computer for the first time or who don’t know any programming language and want to start learning programming.

Any person who want to start learning programs, the good time is to start with Small Basic instead of starting from C ,C#,VB.NET or C++. For many people who start learning any language like C,C++ ,C# and etc, found it hard to understand all the basics. Without understanding the basics it will be hard for them to write a good program. Now no need to worry for that, since Small Basic is here for all of them. 

I can strongly say that if anyone want to start learning programming for the first time they should start with Small Basic. They will surely easily understand what is IDE and Editor and how to run a program, how to write their own logic of program within couple of days. Later, they can easily learn any language as they wish for like C++, C#, etc.

Why I recommend Small Basic for Beginners who want to learn Programming?

  • Simple and Easy
  • Small Basic IDE is similar to MS Paint which makes beginners to learn with fun.
  • Even Middle School Students can understand easily.

How to install Small Basic

You can download the Small Basic from the following link:

Installation Steps

After downloading Small basic from the above link install it on your computer.

Image 1

Click Next and Install Microsoft Small Basic.

Image 2

Finally click on Install Button which will install the Small Basic on your computer.

Using the code

After installation you can find the Small Basic Icon,

Image 3

<bri" style="outline: none 0px;">Click and open Microsoft Small Basic.

When we open Small Basic for the first time we can see the Development Environment with the following 3 parts:

  1. Tool Bar: Simple and easy to understandable by any user as this has only New, Open, Save, Save As, Cut, Copy, Paste and Run.
  2. Editor: Here we write our Programs (This looks similar to Notepad).
  3. Help Window: Which will display our programming commands.

Image 4

Our First Small Basic Program (For Output)

Let’s create a simple program to display our Name as output. It will be always fun to see our name to be displayed from our first program. I still remember my high school days as I was so happy to see my name to be displayed from C Language using printf().

Now let’s see how to write our first program to display our Name from Small Basic.

The Output is to display any text or value from our program. As we all know, Program is nothing but a set of instructions. Using one of the Instruction we can display our output. 

To display the Output from Small Basic we will be using the following,

TextWindow.WriteLine(“your output text”); 

As I have told Small Basic Development Environment is much easier for any new developer who learn programming for the first time. When you type text in editor, you can see a small window which will display all the text starting from text (This are all the instructions to perform our programming result).

Image 5

Here, we are using TextWindow.WriteLine(); to display out first output. To display the output we use the WritLine() and to read the Input from the user we will use the Read(). Here WriteLine() and Read()are called as a function, which means this two Read() and WritelLine() will have some set of Instruction which will execute our text and display or get the text from users.

Image 6

Now let’s display our Name.

TextWindow.WriteLine("My Name is SHANU.Welcome to My first Program")

You can copy this code and paste in your Small Basic Editor. Note “SHANU” is my name, so you have to change it to your name.

Yes now we have written our first program to display our name so what is next. Now we need to run the program and view our Output.
To run the program we can press F5 from keyboard or we can click on the Run from the Tool Window.

Image 7

So here is our first program output. I can feel how much you are happy while seeing your successful message. To close the output window you can press any key. Here all the output is based on Console so in next tutorial we will see about graphical window output.

Save the Program

You have successfully created your first program. Now you need to save the program so that you can use later and also you can modify the same program with more functionality. To save the program from Toolbar you can see the Save Icon click on that and save the program to your selected folder for easy access. 

Image 8

The program will be saved as “.sb” extention.

Image 9

If we run our program we can see in the same folder with few more files like “.dll” and “.exe” extension files. We can also run directly by clicking the “.exe” file. Here “.exe” is an executable file.

Image 10

Open the Saved Program

To open the existing saved file we can click on Open icon from the toolbar in Small Basic. Go to the path where you have saved your program. Select the “.sb” extension file and click open.

Image 11

Our First Small Basic Program (For Input/output using Variable)

So you have successfully created your simple program to display your name as output. Now let’s see how to give input to your program and display the output of your input.

So what is the use of getting Input. Now for example you want to write a program where others can give their name as input and you need to display the user entered Name with welcome message. To perform this we need to store the name entered by user temporarily to the computer. Here we use variable to store the input. The variables will reside in computer memory temporarily till we close our program.

In this example program let us see how to store our name to variable and display the output from our program.

TextWindow.WriteLine("My Name is SHANU.Welcome to My first Program") TextWindow.WriteLine("What is your Name") myname=TextWindow.Read() TextWindow.WriteLine("welcome " + myname)

Copy the above code and paste in your editor.

Image 12

  1. Here we can see first I displayed my name with welcome message.
  2. In second line I asked the user ”What is your Name”.
  3. In third line we can see I have used the variable “myname” and storing the user input to this variable.
  4. To get the user input here we use TextWindow.Read() (For output we use WriteLine() and to get the input here we use Read()).
  5. Here we print the result with welcome message.

When we run the program first it will look like the following, 

Image 13

Here we can see first it displayed our name and then ask to give the input as “What is your Name”. Now user can give the input in the empty line. Here I have given the name of my son as “Afraz”.

Image 14

After entering the name when user press any key the output with user name and welcome message will get displayed.

Image 15

Now we have successfully created our program to read input and print the output.

Simple Program to display Background and font with colors

So far in above program the console windows were displaying the output in black and white. Now let’s add colors for background of text and give some colors for the font.

TextWindow.BackgroundColor="yellow" TextWindow.ForegroundColor="blue" TextWindow.WriteLine("wow now it looks cool with colors")

Copy the above code and paste in your editor.

Image 16

For background color we use the following,

TextWindow.BackgroundColor="yellow"


We can give any Small Basic supported color as we like.

For Font color we use the following,

TextWindow.ForegroundColor="blue"


We can give any Small Basic supported color as we like.

Now we give some text output and press F5 or click on the Run button from the Toolbar. We can see the final output with cool color as output in our console window.

Image 17

Program to Add 2 Numbers

Now let’s create a simple program to get two numbers as input from user and add both the numbers and display the calculated result to user. Here 
we use the colors to display the output as colorful.

In this program I have also commented each line of code with its use.

Comment is an important part of programming .Program is write once and used many times. If we follow to write comment on code then it will be useful for any other program who are using our program. Even for us in future it will be more useful as why we had created this line in this program.

To add comment for each line in program we use single quotes '. Note we add the Single quotes ' then the text inside the quotes will be in green color to differentiate as this is a comment.

This program needs any explanation as I have commented in each line with its uses. I have used all our above 3 programs and made one program as this has output, input and colors.

TextWindow.BackgroundColor="yellow" TextWindow.ForegroundColor="darkgreen" TextWindow.WriteLine("Welcome to simple Addition program") TextWindow.WriteLine("Enter your First Number") TextWindow.BackgroundColor="cyan" TextWindow.ForegroundColor="blue" number1=TextWindow.Read() TextWindow.BackgroundColor="yellow" TextWindow.ForegroundColor="darkgreen" TextWindow.WriteLine("Enter your Second Number") TextWindow.BackgroundColor="cyan" TextWindow.ForegroundColor="blue" number2=TextWindow.Read() Calculation=number1+number2 TextWindow.BackgroundColor="yellow" TextWindow.ForegroundColor="red" TextWindow.WriteLine("The result is " + Calculation)

Copy the above code and paste in your editor,

Image 18

Run the program

Give your input as number for first and second number and then check the calculated result. Here for example I have given the first number input as 12 and second number input as 8 and so the calculated result you can see in the output.

Image 19

History

Programs.zif -

Sours: https://www.codeproject.com/Articles//Getting-Started-With-Microsoft-Small-Basic-For-Beg
Small Basic

Microsoft Small Basic

Program Listing: LTH

TextWindow.Title = "Metaprogramming"

Start:

TextWindow.WriteLine ("Small Basic tutorial in Small Basic")
TextWindow.Read()
TextWindow.WriteLine ("by GORS")
TextWindow.Read()
TextWindow.WriteLine ("Thanks to SENGIR who taught me and several others how to program in Small Basic!")
TextWindow.Read()
TextWindow.Write ("Hello, stranger!")

Nameentry:

TextWindow.WriteLine (" What's your name?")
TextWindow.Write (">")
name = TextWindow.Read()
uname = Text.ConvertToUpperCase (name)

If uname = "" Then
TextWindow.WriteLine ("You didn't type anything!")
TextWindow.Read()
Goto Nameentry
EndIf

Nameconfirm:

TextWindow.WriteLine ("Is your name " + uname + "? Y/N")
answer = TextWindow.Read()
uanswer = Text.ConvertToUpperCase (answer)

If uanswer = "Y" Then
Goto Programstart
ElseIf uanswer = "N" Then
TextWindow.WriteLine ("Then,")
TextWindow.Read()
Goto nameentry
Else
TextWindow.WriteLine ("That's not a valid answer.")
TextWindow.Read()
Goto Nameconfirm
EndIf

Programstart:

TextWindow.WriteLine ("Hello, " + uname + "!")
TextWindow.Read()
TextWindow.WriteLine ("This is Gors' Small Basic tutorial in Small Basic!")
TextWindow.Read()
TextWindow.WriteLine ("Small Basic is a simple programming language created by Microsoft in November As the name implies, it's a simplified version of BASIC.")
TextWindow.WriteLine ("Here, you'll learn how to use some of its features! Open up Small Basic, and be prepared!")
TextWindow.Read()
TextWindow.WriteLine ("Let's start with a 'Hello World' text string, " + uname + "!")
TextWindow.Read()
TextWindow.WriteLine ("To make Small Basic to print your text, you need to type this in the Small Basic's notepad:")
TextWindow.Read()
q = Text.GetCharacter(34)
TextWindow.Writeline ("TextWindow.Writeline (" + q + "Hello World" + q + ")")
TextWindow.Read()
TextWindow.Writeline ("Then, press F5 to execute your program! Easy, isn't it?")
TextWindow.Read()
TextWindow.Writeline ("Now let's understand what happened there, " + uname + "!")
TextWindow.Read()
TextWindow.Writeline (q + "TextWindow" + q + " is an OBJECT. They're the basis for everything Small Basic can do!")
TextWindow.Read()
TextWindow.Writeline ("The" + q + "TextWindow" + q + " OBJECT gives you several options to work with text, as its name implies. So, if you intend to show text to the user, you may want to use this a lot.")
TextWindow.Read()
TextWindow.WriteLine ("Next to the OBJECT, you can see " + q + "WriteLine" + q + ". That is a METHOD, or in simpler words, a task the OBJECT can do.")
TextWindow.Read()
TextWindow.WriteLine ("The " + q + "WriteLine" + q + " METHOD prints all the text input on the screen. So, everything you saw here was mostly done with " + q + "TextWindow.Writeline" + q + "!")
TextWindow.Read()
TextWindow.WriteLine ("So, analoguelly saying, TextWindow is a kind of 'BAG' with several 'TOOLS' inside it. One of these 'TOOLS' is WriteLine, which will work once you give it a task.")
TextWindow.Read()
TextWindow.WriteLine ("The tasks come inside parenthesis " + q + "()" + q + ", and those parenthesis can have plain text and VARIABLES, which will be explained soon!")
TextWindow.Read()
TextWindow.WriteLine ("This code has 'Hello World' as plain text, as the quotation marks imply.")
TextWindow.WriteLine ("If you just want a quick text, you can simply write it inside quotation marks.")
TextWindow.Read()
TextWindow.WriteLine ("But, if you want a text, or value, to be repeated through the code, you may want a VARIABLE.")
TextWindow.Read()
TextWindow.WriteLine ("A VARIABLE works like the ones you find in math. In the equation:")
TextWindow.Read()
TextWindow.WriteLine ("x=2")
TextWindow.Read()
TextWindow.WriteLine ("you can see that 'x' equals 2. You can then use this 'x' in other equations to quickly make math operations:")
TextWindow.Read()
TextWindow.WriteLine ("x+3 (which will give you 5);")
TextWindow.Read()
TextWindow.WriteLine ("4x (which will give you 8);")
TextWindow.Read()
TextWindow.WriteLine ("x-1 (which will give you 1), and so on.")
TextWindow.Read()
TextWindow.WriteLine ("Small Basic uses this same logic for its programming, but the twist is that they accept words as variables! So, you can write this:")
TextWindow.Read()
TextWindow.WriteLine ("x = " + q + "Hello World" + q)
TextWindow.WriteLine ("TextWindow.WriteLine (x)")
TextWindow.Read()
TextWindow.WriteLine ("That code says that you've set a VARIABLE, named 'x', and gave it the 'Hello World' value.")
textwindow.WriteLine ("This value is returned in the WriteLine METHOD. Notice the same 'x' VARIABLE inside the parenthesis.")
TextWindow.Read()
textwindow.WriteLine ("You can use variables for several things! your name, " + uname + ", for example, is an VARIABLE!")
TextWindow.Read()
textwindow.WriteLine ("I hope you enjoyed reading through this tutorial. I am still a beginner and some things might be wrong, but you gotta learn it by trying!")
TextWindow.Read()
textwindow.WriteLine ("Thank you, " + uname + "!")
TextWindow.Read()

Sours: http://smallbasic.com/program/?LTH

Now discussing:

Microsoft Small Basic

This article is about the Microsoft programming language. For the GPL programming language, see SmallBASIC.

Microsoft Small Basic icon.png
Small Basic.png
ParadigmStructured, imperative, object-oriented
Designed&#;byMicrosoft, Vijaye Raji
DeveloperMicrosoft
First&#;appearedOctober&#;23, ; 12 years ago&#;()[1][2]
Stable release

v / October&#;1, ; 6 years ago&#;()[3]

Typing disciplineDynamic, weak
Platform.NET Framework [3]
OSSmall Basic Desktop: Windows Vista, Windows 7, Windows 8, Windows , Windows 10, Windows Server R2[4]
Small Basic Online: web browser
LicenseMIT License[5]
Filename extensions,
Websitewww.smallbasic.com
Logo, QBasic, Visual Basic .NET

Microsoft Small Basic is a programming language, interpreter and associated IDE. Microsoft's simplified variant of BASIC, it is designed to help students who have learnt visual programming languages such as Scratch learn text-based programming.[6] The associated IDE provides a simplified programming environment with functionality such as syntax highlighting, intelligent code completion, and in-editor documentation access.[7] The language has only 14 keywords.[8]

History[edit]

Version Release date
Old version, no longer maintained: v October 23, [1]
Old version, no longer maintained: v December 17, [9]
Old version, no longer maintained: v February 10, [10]
Old version, no longer maintained: v April 14, [11]
Old version, no longer maintained: v June 16, [12]
Old version, no longer maintained: v August 19, [13]
Old version, no longer maintained: v October 23, [2]
Old version, no longer maintained: v February 4, [14]
Old version, no longer maintained: v June 11, [15]
Old version, no longer maintained: v November 17, [16]
Old version, no longer maintained: v February 8, [17]
Older version, yet still maintained: v July 12, [18]
Old version, no longer maintained: v March 27, [19]
Current stable version:vOctober 1, [3]

Legend:

Old version

Older version, still maintained

Latest version

Latest preview version

Future release

Legend:

Old version

Older version, still maintained

Latest version

Latest preview version

Future release

Microsoft announced Small Basic in October ,[1] and released the first stable version for distribution on July 12, ,[18] on a Microsoft Developer Network (MSDN) website, together with a teaching curriculum[20] and an introductory guide.[21] Between announcement and stable release, a number of Community Technology Preview (CTP) releases were made.

On March 27, , Microsoft released Small Basic version ,[19] which fixed a bug and upgraded the targeted .NET Framework version from version to version

Microsoft released Small Basic version on October 1, [3] Version was the first update after a four-year hiatus to introduce new features to Small Basic. The update added classes for working with Microsoft's Kinect motion sensors,[3] increased the number of languages supported by the included Dictionary object, and fixed a number of bugs.[4]

On February 19, , Microsoft announced Small Basic Online (SBO). It is open source software released under MIT License on GitHub.[22][23]

Language[edit]

In Small Basic, one writes the illustrative "Hello, World!" program as follows:

TextWindow.WriteLine("Hello, World!")

Microsoft Small Basic is Turing complete. It supports conditional branching, loop structures, and subroutines for event handling. Variables are weakly typed and dynamic with no scoping rules.

Conditional branching[edit]

The following example demonstrates conditional branching. It requests the current temperature in Fahrenheit and comments on the answer.

TextWindow.Write("Enter the temperature today (in F): ")temp=TextWindow.ReadNumber()Iftemp>ThenTextWindow.WriteLine("It is pretty hot.")ElseIftemp>70ThenTextWindow.WriteLine("It is pretty nice.")ElseIftemp>50ThenTextWindow.WriteLine("Don't forget your coat.")ElseTextWindow.WriteLine("Stay home.")EndIf

Looping[edit]

This example demonstrates a loop. Starting from one and ending with ten, it multiplies each number by four and displays the result of the multiplication.

TextWindow.WriteLine("Multiplication Tables")Fori=1To10TextWindow.Write(i*4)EndFor

loops are also supported, and the demonstrated loop can be augmented through the use of the keyword. The keyword is used in setting the value by which the counter variable, , is incremented each iteration.

Data types[edit]

Small Basic supports basic data types, like strings, integers and decimals, and will readily convert one type to another as required by the situation. In the example, both the and methods read a string from the command line, but rejects any non-numeric characters. This allows the string to be converted to a numeric type and treated as a number rather than a string by the operator.

TextWindow.WriteLine("Enter your name: ")name=TextWindow.Read()TextWindow.Write("Enter your age: ")age=TextWindow.ReadNumber()TextWindow.WriteLine("Hello, "+name+"!")TextWindow.WriteLine("In 5 years, you shall be "+(age+5)+" years old!")

As Small Basic will readily convert among data types, numbers can be manipulated as strings and numeric strings as numbers. This is demonstrated through the second example.

TextWindow.WriteLine(Math.log(""))'Prints 2TextWindow.WriteLine(""+"")' Prints TextWindow.WriteLine("Windows "+8)' Prints Windows 8TextWindow.WriteLine(Text.GetLength())' Prints 7 (length of decimal representation including decimal point)

In the second example, both strings are treated as numbers and added together, producing the output To concatenate the two values, producing the output , it is necessary to use the method.

Libraries[edit]

Standard library[edit]

The Small Basic standard library includes basic classes for mathematics, string handling, and input/output, as well as more exotic classes that are intended to make using the language more fun for learners. Examples of these include a Turtle graphics class, a class for retrieving photos from Flickr, and classes for interacting with Microsoft Kinect sensors.

To make the classes easier to use for learners, they have been simplified. This simplification is demonstrated through the code used to retrieve a random mountain-themed image from Flickr:

Fori=1To10pic=Flickr.GetRandomPicture("mountains")Desktop.SetWallPaper(pic)Program.Delay()EndFor

Turtle graphics[edit]

Small Basic includes a "Turtle" graphics library that borrows from the Logo family of programming languages. For example, to draw a square using the turtle, the turtle is moved forward by a given number of pixels and rotated 90 degrees in a given direction. This action is then repeated four times to draw the four sides of the square.

Fori=1to4Turtle.Move()' Forward pixelsTurtle.Turn(90)' Turn 90 degrees rightEndFor

More complex drawings are possible by altering the turning angle of the turtle and the number of iterations of the loop. For example, one can draw a hexagon by setting the turn angle to 60 degrees and the number of iterations to six.

Third-party libraries[edit]

Small Basic allows the use of third-party libraries. These libraries must be written in a CLR-compatible language, and the compiled binaries must target a compatible .NET Framework version. The classes provided by the library are required to be static, flagged with a specific attribute, and must use a specific data type.

An example of a class to be used in Small Basic is provided below, written in C#.

[SmallBasicType]publicstaticclassExampleClass{publicstaticPrimitiveAdd(PrimitiveA,PrimitiveB)=>A+B;publicstaticPrimitiveSomeProperty{get;set;}publicstaticPrimitivePi=>(Primitive);}

If available, the Small Basic development environment will display documentation for third-party libraries. The development environment accepts documentation in the form of an XML file, which can be automatically generated from source code comments by tools such as Microsoft Visual Studio and MonoDevelop.

References[edit]

  1. ^ abcRaji, Vijaye (23 October ). "Hello World". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February
  2. ^ abRaji, Vijaye (23 October ). "Happy Birthday Small Basic". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  3. ^ abcdeScherotter, Michael (1 October ). "Small Basic Released with Kinect Support and Bug Fixes". Small Basic. MSDN Blogs. Microsoft. Retrieved 2 October
  4. ^ ab"Download Microsoft Small Basic from Official Microsoft Download Centre". Small Basic. Microsoft. 1 October Retrieved 2 October
  5. ^https://github.com/sb/smallbasic-editor/blob/master/LICENSE
  6. ^"Small Basic". Retrieved 6 September
  7. ^Price, Ed (22 October ). "The Unique Features of Small Basic". Small Basic. TechNet. Microsoft. Retrieved 22 April
  8. ^Price, Ed (8 October ). "What are the 14 Keywords of Small Basic?". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February
  9. ^Raji, Vijaye (17 December ). "Announcing Small Basic v0_2!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  10. ^Raji, Vijaye (10 February ). "Microsoft Small Basic v is here". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  11. ^Raji, Vijaye (14 April ). "v of Small Basic says "Bonjour"". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  12. ^Raji, Vijaye (16 June ). "The newest, leanest and the meanest is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  13. ^Raji, Vijaye (19 August ). "Now available: Small Basic v". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  14. ^Raji, Vijaye (10 February ). "Small Basic v". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  15. ^Raji, Vijaye (11 June ). "Small Basic V is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  16. ^Aldana, Sandra (17 November ). "Small Basic V is more international than ever!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  17. ^Aldana, Sandra (8 February ). "Small Basic v speaks another language!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  18. ^ abAldana, Sandra (12 July ). "Small Basic is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  19. ^ abPrice, Ed (27 March ). "Small Basic is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September
  20. ^Price, Ed (29 April ). "Small Basic Curriculum". TechNet. Microsoft. Retrieved 9 February
  21. ^Price, Ed; Takahashi, Nonki (25 February ). "Small Basic Getting Started Guide". TechNet. Microsoft. Retrieved 12 February
  22. ^https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Announcing-Small-Basic-OnlinePublic-Preview/ba-p/
  23. ^https://social.technet.microsoft.com/wiki/contents/articles/microsoft-small-basic-online-vcs-installation-guide.aspx

External links[edit]

Sours: https://en.wikipedia.org/wiki/Microsoft_Small_Basic


20284 20285 20286 20287 20288