Tuesday, December 11, 2012

A Free On-Line C/C++ Compiler

For those who like programming in C or C++, this is a site where you can register for free and use their compiler. You can also view tutorials and sample programs. This site also has a forum.

BotSkool: C and C++ Free On Line Compiler

Sunday, December 2, 2012

Microsoft Small Basic: A Very Simple Slot Machine Program

Here is a simple slot machine program that uses text boxes to display the three numbers. It also uses the timer command. 

'Create a very simple slot machine game
GraphicsWindow.Show()
GraphicsWindow.Title = "A Very Simple Slot Machine Game"
'Add Text Boxes
TextBoxOne = Controls.AddTextBox(30,30)
TextBoxTwo = Controls.AddTextBox(30,70)
TextBoxThree = Controls.AddTextBox(30,110)
'Add Button for rolling them
RollButton= Controls.AddButton("Roll 'em",30,150)
'Display the word Blank in each text bos
Controls.SetTextBoxText(TextBoxOne,"Blank")
Controls.SetTextBoxText(TextBoxTwo,"Blank")
Controls.SetTextBoxText(TextBoxThree,"Blank")
'When Button is pressed, call RollEmSub
Controls.ButtonClicked = RollEmSub

Sub RollEmSub
  'Generate random number between 1 and 3 for each text box
  Controls.SetTextBoxText(TextBoxOne, Math.GetRandomNumber(3))
  Controls.SetTextBoxText(TextBoxTwo, Math.GetRandomNumber(3))
  Controls.SetTextBoxText(TextBoxThree, Math.GetRandomNumber(3))
  'Read each random number
  TextOne = Controls.GetTextBoxText(TextBoxOne)
  TextTwo = Controls.GetTextBoxText(TextBoxTwo)
  TextThree = Controls.GetTextBoxText(TextBoxThree)
  'Compare random numbers
  If TextOne = TextTwo Then
    If TextTwo = TextThree Then
      'Display You Win
      Controls.SetButtonCaption(RollButton,"You Win!")
      Controls.ButtonClicked = DoNothingSub
      'Set delay timer for 20 seconds
      Timer.Interval = 2000
      'When timer expires call EndDelaySub
      Timer.Tick = EndDelaySub
   EndIf
 EndIf
EndSub

Sub EndDelaySub
  Controls.SetButtonCaption(RollButton,"Game over!")
       'Set delay timer for 20 seconds
      Timer.Interval = 2000
      'When timer expires call EndProgramSub
      Timer.Tick = EndProgramSub
EndSub

Sub DoNothingSub
EndSub

Sub EndProgramSub
  Program.End()
EndSub




Saturday, December 1, 2012

ISO C++ Standard 2011

A new ISO Standard for C++ was issued in 2011 and has been implemented in the latest C++ compilers.  I searched for an explanation of this standard after trying to compile a short C++ program that used
a structure containing a character string.

The compiler reported an error for both these statements:
char* mystring = "John";
string mystring = "John";
The error stated that ISO prohibited the initiation of a constant string.

There are still a lot of C++ books and a lot of C++ tutorials that implement this old style of initiating strings.  And this is fine for people working with old compilers. However people working with new compilers or free on-line compilers will experience difficulties with the two C++ statements above as well as in other C++ statements.

I found a C++11 on-line reference at

C++11 Reference

The ISO 2011 C++ Standard costs about $30.00 to download. So I searched further and found a ISO 2011 C++ FAQ for which I provide the link below:

C++11 - the new ISO C++ standard



Thursday, September 27, 2012

Small Basic: A Simple Addition Program

Here is a simple Microsoft Small Basic Program that adds two numbers and displays the answer.

'Create a Graphics Window
GraphicsWindow.Show()
'Create caption and text box for the first variable
GraphicsWindow.DrawText(20,20,"Enter First Number")
typedvar1 = Controls.AddTextBox(200,20)
'Create caption and text box for the second variable
GraphicsWindow.DrawText(20,120,"Enter Second Number")
typedvar2 = Controls.AddTextBox(200,120)
'Create caption and text box for the answer
GraphicsWindow.DrawText(20,220,"The answer is")
Answer1 = Controls.AddTextBox(200,220)
'Create a button for adding the two variables
Controls.AddButton("Add", 220,400)
'The answer goes in textbox labeled Answer1
Controls.SetTextBoxText(Answer1, "  ")
'Execute subroutine named buttonsub when add button is clicked
Controls.ButtonClicked = buttonsub
'Subroutine executed when add button is clicked
Sub buttonsub
  'fetch two numbers entered
  var1 = Controls.GetTextBoxText(typedvar1)
  var2 = Controls.GetTextBoxText(typedvar2)
  'Add the two numbers
  var3 = var1 + var2
  'Display the sum in the textbox named answer1
  Controls.SetTextBoxText(Answer1,var3)
EndSub



Tuesday, August 28, 2012

Microsoft Small Basic: A Simple Program With Two Buttons

Here is a simple Small Basic program that uses two buttons. When a button is pressed, a window message pops up naming the button that was pressed.


GraphicsWindow.Show()
'Add the button labeled Exit
ExitButton = Controls.AddButton("Exit",20,50)
'Add the button labeled Hello
HelloButton = Controls.AddButton("Hello",20,20)
'When a button is clicked, call the ButtonsBeenClicked subroutine
Controls.ButtonClicked=ButtonsBeenClicked

Sub ButtonsBeenClicked
  'If the Hello button was clicked, display the message Hello Button Presssed
  If controls.LastClickedButton = HelloButton then
    GraphicsWindow.ShowMessage("Hello Button Pressed","Button Message")
    'Else if the Exit button was clicked, display the message Exit Button Pressed
    ElseIf controls.LastClickedButton = ExitButton then
      GraphicsWindow.ShowMessage("Exit Button Pressed","Button Message")
  EndIf
EndSub




Friday, August 24, 2012

Microsoft Small Basic: Where To Get Help

After downloading and installing Microsoft Small Basic and the free tutorial Introducing Small Basic, the next logical question is: "Okay. If I need help, where do I go?"

Of course, the first place I turned to was the Microsoft Small Basic Forum at MSDN

MSDN Small Basic Forum

Another place to get help is

Small Basic Web Site

If your primary goal is creating kid's games than this book might be very helpful

Programming Kid's Games With Microsoft Small Basic


Thursday, August 23, 2012

Microsoft Small Basic: A Graphical Programming Language For Beginners

I've been tinkering with Microsoft Small Basic over the past several months. At the time of this writing, Microsoft Small Basic is available for free at the URL listed below.  Microsoft Small Basic is intended for beginners. The free tutorial is titled Introducing Small Basic and it is relatively easy to read and follow.

The editor is easy to use and the programmer is guided step by step through each program line the programmer types in. I like it very much.

I also purchased a book titled 'The Developer's Reference Guide to Microsoft Small Basic.'  This reference guide is actually a tutorial for anyone familiar with programming. It is a reference guide for beginners. And, thus far, it has been helpful. Unlike Visual Basic, Small Basic does not have the drag and drop feature for adding text boxes, buttons and drop down menus to a program. It is an object oriented graphics programming language, but the explanation is simple enough so that the programmer unfamiliar with object oriented programming can understand it.

I'll write more about Microsoft Small Basic as I explore it. Right now, I recommend it for anyone who wants to learn how to program.

Download Microsoft Small Basic Here

Look around for the Microsoft Small Basic Reference Guide. I was able to find one selling for $19.99 at Amazon. Here is a URL where you can purchase the Reference book. Unfortunately, the lower priced one is no longer listed.

Microsoft Small Basic Developers Reference Guide

Here is the URL for another Microsoft Small Basic Book:

Beginning Microsoft Small Basic