Thursday, April 10, 2014

A Brief Introduction to Windows 8.1

Read and enjoy this brief article on Windows 8.1.

A Brief Introduction to Windows 8.1


Sunday, March 2, 2014

Microsoft Small Basic: A Simple Program Handling Multiple Events

Here is a simple Microsoft Small Basic program that handles multiple events. A graphics window is displayed with a text box and a button.

Every time the user uses the mouse to click on the button, the message 'Button Clicked Event Raised' is displayed in a message window. The user acknowledges the message by clicking on the 'OK' button in the message window.

Click the mouse in the text box window. When the user types a letter or number in the text box window,  the message 'Text Typed Event Raised' appears in a message window. The user acknowledges the message by clicking on the 'OK' button in the message window.


Thursday, January 17, 2013

Shareware: A Cross Platform C++ IDE

I have not downloaded this C++ IDE so I can't really give any information about it. I stumbled across it while I was reading about C++11 on

Cprogramming Web Site

As of the time of this writing the C++ IDE is free. Here is the web site where you'll find documentation and the C++ IDE.

Code::Blocks: A C++ IDE

The code::blocks user manual is also available at

code::blocks user manual


Sunday, January 6, 2013

Small Basic: Craps Game Program With Comments

Click on photo to view it
'This is the starting point of the craps program
Main_Program:
Initialize_Craps()

Sub Initialize_Craps
  'Generate and size the graphics window
  GraphicsWindow.Show()
  GraphicsWindow.Height = 620
  GraphicsWindow.Width = 800
  GraphicsWindow.BackgroundColor = "Cyan"
GraphicsWindow.Title = "Craps Game"
'
'Draw the die outline for die 1
GraphicsWindow.DrawRectangle(100,100,180,180)
GraphicsWindow.BrushColor = "Yellow"
GraphicsWindow.FillRectangle(100,100,180,180)
'
'Draw the die outline for die 2
GraphicsWindow.DrawRectangle(500,100,180,180)
GraphicsWindow.BrushColor = "Yellow"
GraphicsWindow.FillRectangle(500,100,180,180)
'
'Initialize all variables for the graphics program
Initialize_Data()
'
'Draw nine  buttons in each die.
Draw_Buttons()
'Create text boxes and instructions
GraphicsWindow.BrushColor = "Black"

GraphicsWindow.DrawText(260,300,"Press the left mouse button to roll the dice")
'
GraphicsWindow.DrawText(280,340,"Press the right mouse button exit")
'
'The Instruction Box displays the messages
'New Game
'and
'Roll em again
InstructionBox = Controls.AddTextBox(340,50)
Controls.SetSize(InstructionBox,100,30)

GeneralMessageBox = Controls.AddTextBox(290,25)
Controls.SetSize(GeneralMessageBox,200,30)
Controls.SetTextBoxText(GeneralMessageBox,"   Let's Play A Game Of Craps")
GraphicsWindow.DrawText(20,400,"Rules of Craps Game")
GraphicsWindow.DrawText(20,430,"First Roll of Dice")
GraphicsWindow.DrawText(20,460,"7 or 11 wins")
GraphicsWindow.DrawText(20,490,"2, 3 or 12 loses")
GraphicsWindow.DrawText(20,520,"4, 5, 6, 7, 9 or 10 okay")
GraphicsWindow.DrawText(20,550,"Matching first roll wins")
GraphicsWindow.DrawText(20,580,"Rolling a 7 loses")
'
'The following instruction causes the execution of
'the subroutine RollTheDice every time a mouse button
'is pressed.
'
GraphicsWindow.MouseDown = RollTheDice
EndSub

'This sub is executed every time a mouse button is pressed
Sub RollTheDice
  'If the right mouse button is pressed, end the program
  If Mouse.IsRightButtonDown Then
    Program.End()
  EndIf
  'MouseEvent is used to prevent the program from responding to
  'the mouse button being pressed again before this sub is completely executed.
  If MouseEvent = 0 then
    MouseEvent = 1
    Controls.SetTextBoxText(InstructionBox," ")
    'Create two small die
  GraphicsWindow.BrushColor = "Yellow"
  MyDie1=Shapes.AddRectangle(50,50)
  Shapes.HideShape(MyDie1)
  Shapes.Move(MyDie1,340,170)
  Shapes.ShowShape(MyDie1)
  MyDie2=Shapes.AddRectangle(50,50)
  Shapes.HideShape(MyDie2)
  Shapes.Move(MyDie2,400,170)
  Shapes.ShowShape(MyDie2)
  talpha = 50
  ' this for loop rotates the dice
  For ndexa = 1 To 20
    Shapes.Rotate(MyDie1,talpha)
    Shapes.ShowShape(MyDie1)
    Program.Delay(30)
    talpha = talpha+10
    Shapes.Rotate(MyDie2,talpha)
    Shapes.ShowShape(MyDie2)
    Program.Delay(30)
    talpha = talpha+10
  EndFor
  'Fetch randon value for each die
   Die1_number = Math.GetRandomNumber(6)
   Die2_number = Math.GetRandomNumber(6)
   'Hide the dice
   Shapes.HideShape(MyDie1)
   Shapes.HideShape(MyDie2)
   GraphicsWindow.BrushColor = "Blue"
   'Display value on each die via coloring the appropriate buttons
   Display_Die_One()
   Display_Die_two()
   'Display results of first roll of dice
   InfoBoxes()
   MouseEvent = 0
 Endif
 EndSub
 '          Each die contains nine ellipses
 '          Here are the ellipse numbers
 '         In this program ellipses are also referred
 '         to as buttons
 '        
 '          1         4       7
 '          2        5       8
 '          3        6       9
 '
 Sub Display_Die_One
   'Ensure that the die only displays the results
   'of the current roll.
    Reset_Die1()
    '
    If Die1_number = 1 Then
      'sub call
      'ellipse number five is the center ellipse and
      'it's the only ellipse that is colored if the die1_number is
      'a one.
      el_num = 5 'Select the center ellipse
      ColorAnEllipse()
       '
    ElseIf Die1_number = 2 then
      'sub call
      'die number = 2
      'ellipse number 1 and ellipse number 9 are colored
            el_num = 1
            ColorAnEllipse()
            el_num = 9
            ColorAnEllipse()
         
            '
    Elseif Die1_number = 3 then
      'sub call
      'die number = 3
      'ellipse numbers 1, 5 and 9 are colored
            el_num = 1
            ColorAnEllipse()
            el_num = 5
            ColorAnEllipse()
            el_num = 9
            ColorAnEllipse()
      '
    Elseif Die1_number = 4 then
      'sub call
      'Ellipse number 1, 3, 7, and 9 are          
            el_num = 1
            ColorAnEllipse()
            el_num = 3
            ColorAnEllipse()
            el_num = 7
            ColorAnEllipse()
            el_num = 9
            ColorAnEllipse()
   

    Elseif die1_number = 5 then
  'Ellipse number 1, 3, 5, 7 and 9 are colored
            el_num = 1
            ColorAnEllipse()
            el_num = 3
            ColorAnEllipse()
            el_num = 5
            ColorAnEllipse()
            el_num = 7
            ColorAnEllipse()
            el_num = 9
            ColorAnEllipse()    

      'subcall
    Elseif Die1_number = 6 then
      'subcall
      'Ellipse number 1, 2, 3, 7, 8 and 9 are colored
            el_num = 1
            ColorAnEllipse()
            el_num = 2
            ColorAnEllipse()
            el_num = 3
            ColorAnEllipse()
            el_num = 7
            ColorAnEllipse()
            el_num = 8
            ColorAnEllipse()
            el_num = 9
            ColorAnEllipse()
    EndIf
  EndSub
  '
  Sub Display_Die_Two
   'Ensure that the die only displays the results
   'of the current roll.
    Reset_Die2()
    '
    If Die2_number = 1 Then
      'sub call
      'ellipse number five is the center ellipse and
      'it's the only ellipse that is colored if the die2_number is
      'a one.
      el_num = 5 'Select the center ellipse
      ColorAnEllipse2()
       '
    ElseIf Die2_number = 2 then
      'sub call
      'die number = 2
      'ellipse number 1 and ellipse number 9 are colored
            el_num = 1
            ColorAnEllipse2()
            el_num = 9
            ColorAnEllipse2()
         
            '
    Elseif Die2_number = 3 then
      'sub call
      'die number = 3
      'ellipse numbers 1, 5 and 9 are colored
            el_num = 1
            ColorAnEllipse2()
            el_num = 5
            ColorAnEllipse2()
            el_num = 9
            ColorAnEllipse2()
      '
    Elseif Die2_number = 4 then
      'sub call
      'Ellipse number 1, 3, 7, and 9 are          
            el_num = 1
            ColorAnEllipse2()
            el_num = 3
            ColorAnEllipse2()
            el_num = 7
            ColorAnEllipse2()
            el_num = 9
            ColorAnEllipse2()
   

    Elseif die2_number = 5 then
  'Ellipse number 1, 3, 5, 7 and 9 are colored
            el_num = 1
            ColorAnEllipse2()
            el_num = 3
            ColorAnEllipse2()
            el_num = 5
            ColorAnEllipse2()
            el_num = 7
            ColorAnEllipse2()
            el_num = 9
            ColorAnEllipse2()    

      'subcall
    Elseif Die2_number = 6 then
      'subcall
      'Ellipse number 1, 2, 3, 7, 8 and 9 are colored
            el_num = 1
            ColorAnEllipse2()
            el_num = 2
            ColorAnEllipse2()
            el_num = 3
            ColorAnEllipse2()
            el_num = 7
            ColorAnEllipse2()
            el_num = 8
            ColorAnEllipse2()
            el_num = 9
            ColorAnEllipse2()
          EndIf
  EndSub
  '
  Sub ColorAnEllipse
    'Color an ellipse on die 1
      GraphicsWindow.BrushColor = "Black"
      ButtonNumber[el_num] = Shapes.AddEllipse(10,10)
      'Hide the button
      Shapes.HideShape(ButtonNumber[el_num])
      'Move the button
      Shapes.Move(ButtonNumber[el_num],die1_btnpos_x[el_num],die1_btnpos_y[el_num])
      'Show the button
      Shapes.ShowShape(ButtonNumber[el_num])
    EndSub
 
    Sub ColorAnEllipse2
    'Color an ellipse on die 2
      GraphicsWindow.BrushColor = "Black"
      ButtonNumber[el_num] = Shapes.AddEllipse(10,10)
      'Hide the button
      Shapes.HideShape(ButtonNumber[el_num])
      'Move the button
      Shapes.Move(ButtonNumber[el_num],die2_btnpos_x[el_num],die2_btnpos_y[el_num])
      'Show the button
      Shapes.ShowShape(ButtonNumber[el_num])
    EndSub
 
 
  Sub Reset_Die1
            el_num = 1
            UncolorAnEllipse()
            el_num = 2
            UncolorAnEllipse()
            el_num = 3
            UncolorAnEllipse()
            el_num = 4
            UncolorAnEllipse()
            el_num = 5
            UncolorAnEllipse()
            el_num = 6
            UncolorAnEllipse()
            el_num = 7
            UncolorAnEllipse()
            el_num = 8
            UncolorAnEllipse()
            el_num = 9
            UncolorAnEllipse()
  EndSub
       
  Sub Reset_Die2
            el_num = 1
            UncolorAnEllipse2()
            el_num = 2
            UncolorAnEllipse2()
            el_num = 3
            UncolorAnEllipse2()
            el_num = 4
            UncolorAnEllipse2()
            el_num = 5
            UncolorAnEllipse2()
            el_num = 6
            UncolorAnEllipse2()
            el_num = 7
            UncolorAnEllipse2()
            el_num = 8
            UncolorAnEllipse2()
            el_num = 9
            UncolorAnEllipse2()
  EndSub

  Sub UncolorAnEllipse
      GraphicsWindow.BrushColor = "White"
      ButtonNumber[el_num] = Shapes.AddEllipse(10,10)
      'Hide the button
      Shapes.HideShape(ButtonNumber[el_num])
      'Move the button
      Shapes.Move(ButtonNumber[el_num],die1_btnpos_x[el_num],die1_btnpos_y[el_num])
      'Show the button
      Shapes.ShowShape(ButtonNumber[el_num])
 EndSub

   Sub UncolorAnEllipse2
      GraphicsWindow.BrushColor = "White"
      ButtonNumber[el_num] = Shapes.AddEllipse(10,10)
      'Hide the button
      Shapes.HideShape(ButtonNumber[el_num])
      'Move the button
      Shapes.Move(ButtonNumber[el_num],die2_btnpos_x[el_num],die2_btnpos_y[el_num])
      'Show the button
      Shapes.ShowShape(ButtonNumber[el_num])
    EndSub

 
   Sub Initialize_Data
'Initialize all variables used in the program
'
'Generate buttom positions on die 1
die1_btnpos_x[1] = 120
die1_btnpos_x[2] = 120
die1_btnpos_x[3] = 120
die1_btnpos_x[4] = 185
die1_btnpos_x[5] = 185
die1_btnpos_x[6] = 185
die1_btnpos_x[7] = 250
die1_btnpos_x[8] = 250
die1_btnpos_x[9] = 250
'
die1_btnpos_y[1] = 120
die1_btnpos_y[2] = 185
die1_btnpos_y[3] = 250
die1_btnpos_y[4] = 120
die1_btnpos_y[5] = 185
die1_btnpos_y[6] = 250
die1_btnpos_y[7] = 120
die1_btnpos_y[8] = 185
die1_btnpos_y[9] = 250
'
'Generate die 2 button positions
displacement = 400
For ndex = 1 to 9
die2_btnpos_x[ndex] = die1_btnpos_x[ndex] + displacement
die2_btnpos_y[ndex] = die1_btnpos_y[ndex]
EndFor

ButtonSize_x = 10
ButtonSize_y = 10

' This flag indicates the first roll of
'the dice in a game of craps
First_Dice_Roll = 1
First_Die1_Roll_no = 0
First_Die2_Roll_no = 0
' MouseEvent prevents a mouse down event from
'being serviced while a previous mouse down event
'is being serviced.
'Intialize MouseEvent to zero to indicate that
'no mouse event is being serviced
MouseEvent = 0
InitializeMsgData()
EndSub

Sub InitializeMsgData
  'Initializes the data for mytextbox1 and mytextbox2
  'which are used to display the results
  'of the first dice roll
yposText = 500
xposText1 = 250
xposText2 = 450
xposDie1 = 320
xposDie2 = 520
yposDie = 500
EndSub

Sub InfoBoxes
  'This sub displays the first roll of the dice
  If First_Dice_Roll = 1 Then
GraphicsWindow.DrawText(xposText1+100,yposText-30, "First Roll of Dice")
GraphicsWindow.DrawText(xposText1,yposText,"Die One ")
mytextbox1 = Controls.AddTextBox(xposDie1,yposDie)
Controls.SetSize(mytextbox1,40,20)
Controls.SetTextBoxText(mytextbox1,Die1_Number)
GraphicsWindow.DrawText(xposText2,yposText,"Die Two ")
mytextbox2 = Controls.AddTextBox(xposDie2,yposDie)
Controls.SetSize(mytextbox2,40,20)
Controls.SetTextBoxText(mytextbox2,Die2_Number)
First_Die1_Roll_no = Die1_number
First_Die2_Roll_no = Die2_number
Die1_number = 0
Die2_number = 0
First_Dice_Roll = 0
EndIf
'Controls.SetTextBoxText(mytextbox,myvalue) 'overwrites previous value
DetermineWinOrLoss()
EndSub

'
Sub Draw_Buttons
  '-------------------------------------------
'Software to draw nine buttons on die_1
' and nine buttons on die-2
'Left column Button one Top
'
'Create the buttons
For i = 1 to 9
GraphicsWindow.BrushColor = "White"
ButtonNumber[i] = Shapes.AddEllipse(10,10)
'Hide the button
Shapes.HideShape(ButtonNumber[i])
'Move the button
Shapes.Move(ButtonNumber[i],die1_btnpos_x[i],die1_btnpos_y[i])
'Show the button
Shapes.ShowShape(ButtonNumber[i])
GraphicsWindow.BrushColor = "White"
ButtonNumber[i] = Shapes.AddEllipse(10,10)
'Hide the button
Shapes.HideShape(ButtonNumber[i])
'Move the button
Shapes.Move(ButtonNumber[i],die2_btnpos_x[i],die2_btnpos_y[i])
'Show the button
Shapes.ShowShape(ButtonNumber[i])
EndFor
EndSub
'
Sub DetermineWinOrLoss
First_Dice_Total = First_Die1_Roll_no + First_Die2_Roll_no
  Current_Dice_Total = Die1_number + Die2_number
If First_Dice_Total = 7 Then
  YouWin()
ElseIf First_Dice_Total = 11 Then
  YouWin()
ElseIf First_Dice_Total = 2 Then
  YouLose()
ElseIf First_Dice_Total = 3 Then
  YouLose()
ElseIf First_Dice_Total = 12 Then
  YouLose()
ElseIf Current_Dice_Total = First_Dice_Total Then
  YouWin()
Elseif Current_Dice_Total = 7 then
  YouLose()
Else
Controls.SetTextBoxText(InstructionBox,"Roll 'em again!")
Endif
EndSub

Sub YouWin
  Controls.SetTextBoxText(InstructionBox," ")
  Sound.PlayChime()
  GraphicsWindow.ShowMessage("You Win!","Craps")
  Controls.SetTextBoxText(mytextbox1," ")
  Controls.SetTextBoxText(mytextbox2," ")
  First_Dice_Roll = 1
  First_Die1_Roll_no = 0
  First_Die2_Roll_no = 0
  Controls.SetTextBoxText(InstructionBox,"  New game!")
EndSub

Sub YouLose
  Controls.SetTextBoxText(InstructionBox," ")
  Sound.PlayBellRing()
  GraphicsWindow.ShowMessage("Dang it! You lose","Craps")
  Controls.SetTextBoxText(mytextbox1," ")
  Controls.SetTextBoxText(mytextbox2," ")
  First_Dice_Roll = 1
  First_Die1_Roll_no = 0
  First_Die2_Roll_no = 0
  Controls.SetTextBoxText(InstructionBox,"  New game!")
EndSub

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




Saturday, June 23, 2012

Book Review: Pointers on C

The book 'Pointers on C' is an excellent book for the person with a working knowledge of the C language. If the reader does not know this, the reader will be made painfully aware of it in the first chapter.  Instead of the typical "Hello World" one line program, the program explained in the first chapter is one only a person who has written programs would understand. In the explanation of the program and throughout the rest of the book, the author sites good and bad programming practices. This is exactly why I like this book. It covers C programming in a unique way.

In the second chapter, the author discusses lexical rules and the importance of good program style. Each chapter is devoted to one topic: Data, Statements, Operators and Expression, Pointers, etc.

As the reader probably guess, the book elaborates on pointers.  There are three chapters focused on pointers and chapters with partial focus on pointers. These chapters include the chapters titled Arrays, Using Structures and Pointers and Advanced Pointer Topics as well as many other chapters. 


The book also contains a chapter on the Preprocessor, abstract data types and the run-time environment.


This book is a practical book on the C language. I've had this book for years and have referenced it while I was an embedded systems software engineer. 


Pointers on C
Written by Kenneth A. Reek
Published by Addison-Wesley
ISBN 0-673-99986-6




Tuesday, June 19, 2012

Object Oriented Programming With Turbo C++

The book Object Oriented Programming With Turbo C++ has received mixed reviews on the Internet. This book is not a tutorial on C++. The book explains and provides the code for Object Oriented Programming applications.

After a brief introduction to Object Oriented Programming, the book explains and presents two versions of a File Browser Program. The first version does not use Object Oriented Programming. The second version uses Object Oriented Programming.

The book can be very confusing if the reader tries to read it like a text book. Reading it does not suffice. As the reader reads it, the reader should create an index of functions, classes, data and the pages they are on.

The disadvantage is that the program was written in Turbo C++ 1.0.  However, there is a free version of Turbo C++ that works on Windows ME, Windows 2000, Windows XP, Windows 7 and Windows NT.
You can download it at the following site:


In addition, there is a book
Turbo C++: The Complete Reference
written by Herbert Schildt
available on the Internet.

I am not affiliated in any way with the web sites and the author or publisher of the Turbo C++ books presented in this blog.

Sunday, January 22, 2012

Introduction to C++ Functions


This blog assumes that the reader understand how to create a C++ program containing a single statement that displays the phrase "Hello World!" Therefore this blog focuses solely on functions and does not explain the main function nor the class libraries.

A function is a group of C++ statements that collectively perform a specific well defined task. Functions can be executed repeatedly throughout a program. The advantage of a function is that the programmer does not have to repeat the C++ statements each time the task needs to be performed.

First, I will explain each statement in the example, then I will present the complete tested and debugged example.

/* The first statement lists the iostream class. */

#include <iostream>

/* The second statement invokes namespace. */

using namespace std;

/* For more details on iostream and namespace see my blog titled
An Introduction to C++ Programming. */

/* Now we can insert our function header. You can name your function any name you like. I recommend that the function name describes what the function does. This will make it easier to understand the program when you come back to modify it. The word void at the far left of the function name means that the function does not return anything to the calling function. In this example, the calling function is the main function. The word void in the parenthesis means nothing is passed to the function from the main function. */

void Display_Hello_World(void)

/* The beginning of the function is defined by an opening curly bracket. */

{
/* The function only has one statement. That statement displays the words "Hello World" on the monitor. The cout function is defined in the iostream class library. */

cout << "Hello World!" << endl;

/* The end of the function is defined by a closing curly bracket. */

}

/* The main function invokes the function name Display_Hello_World. */

int main (void)
{
Display_Hello_World();
}

/* A function can return a value. The following function declares an integer, assigns a value to that integer and returns the integer value to the calling function. */

int FReturn_A_Value (void)
{
int a_value = 5;
return a_value;
}

/* The main function calls the FReturn_A_Value funtion and  and stores the value returned in my_value. */

int main (void)
{
int my_value;
my_value = FReturn_A_Value();
}

/* A variable can be passed to a function. The function FPass_A_Variable accepts an integer from the main function and displays it. */

void FPass_A_Variable(int my_value)
{
cout << my_value << endl;
}

/* The main funtion declares an integer, assigns the integer the value of 5 and passes the value to the function FPass_A_Variable. */

int main (void)
{
int value = 5;
FPass_A_Variable(value);
}

We can implement each defined task in a function. The function makes the program easier to read and easier to troubleshoot. The name of the function should describe what the function does. Likewise, the name of the variables should describe those variables. We know that the variable is an integer. The variable name should describe what the variable is.

An example is:
int temperature;

Here are examplies of function names
Read_Temperature().
Test_temperature_range().
Display_temperature().
Display_warning_message().

Note how easy it is to understand each function does.
The more clearly one describes variables and functions, the easier it is to read and understand the program.
The function should execute a single well defined task. The inputs and outputs of each function could be defined in the comments before the actual function.

/*****************************************************************
Function name
Inputs: Description of each input
Outputs: Describe the each output
Description: Describes what the function does
*********************************************************************/
/* Place function here */

The advantage of these comments is the time it saves if the programmer should have to modify the program months or years after the program was designed.

Friday, January 13, 2012

Basic Concepts of Computer Programming

 

I originally published this article on Yahoo Voices under the pen name John Mario.

This article is intended for those who have not had any exposure to computer programming and have no knowledge of electronics. This article does not define how to write a program in a specific language. It only covers the basics.

In order to write a computer program, you need a compiler. A compiler allows you to use a specific set of instructions to create a computer program and then convert that program into machine language.

Each compiler is for a specific programming language. A programming language is a specific set of instructions available for use in any program. Two very popular programming languages are Visual Basic and Visual C++. The modern compilers provide the user with an editor that allows the user to type in the program. You would type selected instructions in a specific order to perform a specific task. For example, you might want to collect information from the user and display that information on the monitor.

One instruction found in compilers is the print instruction.

If you wrote a program to display the phrase "Hello World," you would use the print instruction.

It would look like this:

print "Hello World!"

Each compiler may require a different syntax for the print instruction. For example: the C++ compiler requires a semicolon at the end of each instruction. Hence in C++ you would type

print "Hello World!";

There are other requirements for a complete C++ program to print "Hello World." But the exact contents of the complete program in C++ is beyond the scope of this article.

After writing and saving your program, you have to build your program. Building a program means converting the program to machine language. The resulting machine language file contains binary codes. When you build a program, the program may list syntax errors. These errors are instructions that are typed in wrong. They may be missing punctuation marks or they may contain unrecognized words.

When you execute the program, the binary code is converted into voltage levels that are applied to the electronics inside your computer to cause the computer to perform a specific action.

After you build the program, you have to test it. You start by executing the program. If the program does not run correctly, you have to examine the program to find out what is wrong. Debugging a program is an art by itself.

Learning programming is a challenging task that will consume a significant portion of your time. I highly recommend taking a course in school. However, if you prefer to learn on your own, you might join a programmer's forum on the web.Then you can ask questions in the forum about which is the best compiler for you and which books they recommend. Your best bet is to go to your local book store where you can read a few pages of the book to find out if you can understand it.

Reference:

My experience as an embedded systems software engineer.

Cplusplus: Understanding Arrays, Character Strings, and Pointers



I originally published this article on Yahoo Voices under the pen name John Mario.

We learned in earlier lessons that a variable is the name of a memory location that holds data. In computers, we also need a way to find that memory location. In real life, the US Post Office finds our residences via our address. Each memory location in a computer is assigned a numeric address.

Before we learn about pointers, arrays and strings, let's become familiar with the American Standard Code for Information Interchange (ASCII).

The ASCII code is a set of numbers that all keyboard characters are converted to. You can find the ASCII code at

http://www.asciitable.com/

When you press and release a key of your keyboard, the actual character shown on the key is not stored in memory. Instead, a number is stored in memory. That number is the ASCII code for that character.

The ascii code for the character 'a' is 141 in octal. The following program assigns the character 'a' to my_character and displays it. Then it assigns the ASCII code octal value 141 to my_character and displays it. The ASCII octal value 141 is displayed as the character 'a'

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* Declare a character variable */

char my_character;

/* Assign my_character the letter 'a' */

my_character = 'a';

/* This statement displays the letter 'a' */

cout << my_character << endl;

/* Assign my_character the ASCII code for the letter 'a' */

/* The forward slash tells the compiler that the ASCII code is used instead of the letter. */

my_character = '\141';

/* This statement also displays the letter 'a' */

cout << my_character << endl;

} /* end of main function */

/******* End of program *******/

In C++, the ampersand sign means the address of when a variable name is appended to it.

&my_variable means 'the address of my_variable. A pointer points to a variable. In other words, a pointer holds the address of a variable.

The following program displays an integer in two ways. First it displays the integer via the variable my_variable which holds the integer. Then it displays the integer via the pointer my_pointer that points to my_variable.

**

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* Lets declare a variable that holds an integer */

int my_variable;

/* Now lets declare a pointer*/

/*The asterick denotes a pointer to

a variable of type integer. */

int *my_pointer;

/* The pointer is declared but it does not point to any variable. Let my_pointer point to my_variable */

my_pointer = &my_variable;

/* Lets assign a value to my_variable */

my_variable = 5;

/* Display the integer stored in my_variable. */

cout << my_variable << endl; /* Displays the integer 5 */

/* Use the pointer my_pointer to display the integer in my_variable. */

cout << *my_pointer << endl; /* Displays the integer 5 */

} //end of main function

/******* End of program *******/

ARRAYS

An array is a group of contiguous memory locations holding a string of values. The following program creates an array of integers named my_array[2]. The number 2 means there are two locations in this array. Those locations are my_array[0] and my_array[1]. The program places integer values in each location and then prints them one at a time.

**

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* The following statement declares an array of two memory locations designated as holding integers. Each location holds one integer. The two memory locations are my_array[0] and my_array[1] */

int my_array[2];

/* Assign the value 4 to the first location of my_array */

my_array[0] = 4;

/* Assign the value 3 to the second location of my_array */

my_array[1] = 3;

/* Display the contents of the first location of my_array */

cout << my_array[0] << endl;

/* Display the contents of the second location of my_array */

cout << my_array[1] << endl;

} // end of main function

/******* End of program *******/

The following program is the same as the last program except that the integers are assigned to my_array in the declaration of my_array.

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* The following statement declares an array of two memory locations designated as holding integers.and assigns the value 4 to the first location of the array and the value three to the second location of the array */

int my_array[2] = {4, 3};

/* Display the contents of the first location of my_array */

cout << my_array[0] << endl;

/* Display the contents of the second location of my_array */

cout << my_array[1] << endl;

} // end of main function

/******* End of program *******/

We can also create an array of characters. The following program creates an array of characters. The array is named my_greeting. The program sets up a pointer to the array my_greeting and uses the pointer to display the greeting. The array of characters must be terminated with a null character. The null character denotes that all the characters have been printed.

**

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

char *my_pointer;

/* declare an array that will contain five characters

and a null character. */

char my_greeting[6];

/* my_pointer must point to my_greeting */

my_pointer = my_greeting;

/* We can fill the array locations one by one with the following inefficient code */

my_greeting[0] = 'h';

my_greeting[1] = 'e';

my_greeting[2] = 'l';

my_greeting[3] = 'l';

my_greeting[4] = 'o';

/* We must add a null character to tell the compiler

that this is the end of the array */

my_greeting[5] = '\0';

/* Print only the first character of the array */

cout << *my_pointer << endl;

/* Print the whole array */

cout << my_pointer << endl;

} /* end of main function */

/******* End of program *******/

The above program could have been written using two C++ statements in the main function.

The following program is the same as the previous program except that it defines the characters in the pointer declaration. Note that the pointer declaration include the characters "hello." This is called a character string. When defining the character string in this manner, the programmer need not worry about the terminating null character.

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* We could save time by filling the array in the declaration of the pointer */

const char *my_pointer = "hello"; /* generates compiler error */

/* "hello" is a character string that exists in the array my_greeting[]

my_greeting[0] is pointed to by the pointer my_pointer. */

/* Display the message "hello" */

cout << my_pointer << endl;

/* Print only the character 'h" */

cout << *my_pointer << endl;

} //end of main function

/******* End of program *******/

The following program uses the variable i as an index into my_array. Then it uses the pointer my_pointer to display the contents of my_array.

**

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* declare integer i and set it equal to 0. */

int i = 0;

/* declare a pointer */

char *my_pointer;

/* Declare an array of two characters */

char my_array[3];

/* my_pointer must point to my_array */

my_pointer = my_array;

/* Use the value of i as the index into the array. */

/* Save the character 'H' in my_array[0] */

my_array[i] = 'H';

/* Increment i by 1 */

i++;

/* Save the character 'e' in my_array[1] */

my_array[i] = 'e';

i++;

/* Save a null character in my_array[2] */

my_array = '\0';

/* Display my_array */

cout << my_pointer << endl;

} /* end of main function */

/******* End of program *******/

We can also increment and decrement pointers.

The following program declares an array my_array and then uses the pointer my_pointer to point to specific locations of the array and store integers in the array.

**

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* declare the index variable i */

int i = 0;

/* declare the character array my_array */

char my_array[3];

/* declare the pointer my_pointer */

char *my_pointer;

/* my_pointer must point to my_array */

my_pointer = my_array;

/* Store an 'H" in my_array[0] */

*my_pointer = 'H';

/* point to my_array[1] */

my_pointer++;

/* Store an 'e' in my_array[1] */

*my_pointer = 'e';

my_pointer++;

/* store a null character in my_array[2] */

*my_pointer = '\0';

/* Reset the pointer to the first location of the string */

my_pointer = my_array;

/* Display the character string in my_array. */

cout << my_pointer << endl;

} /* end of main function */

/******* End of program *******/

The following programs shows a property of the increment operator. The statement

my_array[i++] = 'T';

places the letter T in my_array[i] and then increments i.

The statement

my_array[++i] = 'T';

increments i and then stores the letter T in my_array[i].

After placing the characters 't', 'e', 's', 't' and a null character in the array. The program displays the word text.

/**** place the include iostream statement here ****/

using namespace std;

int main (void)

{

/* declare a character pointer */

char *array_ptr;

/* Declare a array of characters */

char my_array[7];

/* Declare and initialize the array index i */

int i = 0;

/* The pointer must point to the array *?

array_ptr = my_array;

/* store the character 'T' in my_array[i] and then increment i. */

my_array[i++] = 'T';

/* Store an 'e' in my_array[1] */

my_array[i] = 'e';

/* This statement increments i and then stores a the character 's' in my_array[i] */

my_array[++i] = 's';

i++; /*increment i */

/* This statement stores the character 't' in my_array[i] and then increments i. */

my_array[i++] = 't';

/* Insert a null character in my_array */

my_array[i] = '\0';

/* display the contents of my_array */

cout << array_ptr << endl;

} /* end of main function */

/******* End of program *******/

References: My own experiences during my career as a embedded systems software engineer.

The book 'C++ THE COMPLETE REFERENCE' by Herbert Schildt.

ISBN 0-07-222680-3


The Cplusplus Programming Language Switch Statement

I orignally published this article on Yahoo Voices under the pen name John Mario.

This Tutorial covers the C++ switch statement.

The basic form of the switch statement is shown below. The names of the variables in this switch statement describe their function. The case_identifier_value defines which case will be executed. Each case begins with a case statement ends with a break statement as shown below. Each time the switch statement is called, only one case is executed. The C++ statements between the case statement and the break statement comprise the response for that particular input. The case_identifier_value can be an integer or a letter of the alphabet. If the switch statement receives an invalid case_identifier_value, the default case is executed. The default case starts with 'default:' and ends with a break statement.

BASIC FORM OF SWITCH STATEMENT

switch (case_identifier)

{

case(case_identifier_value) // case for a specific value of case_identifier_value

// case_identifier_value value must be number or letter

//C++ statements for responding to a specific case_identifier_value

break; // end of case

break;

// one case exists for each

// valid case_identifier_value

default:

// The default case contains C++ statements

// that respond to

// invalid case_identifier_values

break; //end of default case

}

FIRST C++ PROGRAM CONTAINING SWITCH STATEMENT

A sample program containing a switch statement is shown below. In this program, the switch statement excutes a case based on an integer.

// place include iostream statement here

using namespace std;

int main(void)

{

int count; //declare the variable count

cout << "Type a number less than 6 " << endl; //instruct user

cin >> count; // await keyboard entry

switch(count)

/******************************

This switch statement executes

one of the cases below based on the

value of count.

Note that each time the switch statement

is executed only one case is executed

or the default case is executed.

******************************/

{

case 0: //If count equals 0, this case is executed

cout << "count = " << count << endl; //display count of 0

break; // exit from switch statement

case 1: //If count equals 1, this case is executed

cout << "count = " << count << endl; //display count of 1

break; // exit from switch statement

case 2: //If count equals 2, this case is executed

cout << "count = " << count << endl; // display count of 2

break; // exit from switch statement

case 3: //If count equals 3, this case is executed

cout << "count = " << count << endl; //display count of 3

break; // exit from switch statement

case 4: //If count equals 4, this case is executed

cout << "count = " << count << endl; // display count of 4

break; // exit from switch statement

case 5: //If count equals 5, this case is executed

cout << "count = " << count << endl; // display count of 5

break; // exit from switch statement

default: // default case: execute if count is not between 1 and 5

cout << "count out of range" << endl; // display count out of range

break; //exit switch statement

} //end of switch statement

} // end of main

SECOND C++ PROGRAM USING SWITCH STATEMENT

The switch statement can also execute cases based on a character input. In the following program we use the switch statement to accept one of the following letters: a, b, c, d, e.

//place include iostream statement here

using namespace std;

int main(void)

{

char answer; //declare the variable answer

cout << "Type in one of the first five letters of the alphabet" << endl;

cin >> answer; // await keyboard entry

switch(answer) //Execute case based on answer

// Note that each time the switch statement

// is executed only one case is executed

// or the default case is executed.

{

case 'a': //If answer equals 'a', this case is executed

cout << "answer = a" << endl; //display answer

break; // exit from switch statement

case 'b': //If answer equals 'b', this case is executed

cout << "answer = b" << endl; // display answer

break; // exit from switch statement

case 'c': //If answer equals 'c', this case is executed

cout << "answer = c" << endl; //display answer

break; // exit from switch statement

case 'd': //If answer equals 'd', this case is executed

cout << "answer = d" << endl; // display answer

break; // exit from switch statement

case 'e': //If answer equals 'e', this case is executed

cout << "answer = e" << endl; // display answer

break; // exit from switch statement

default: // default case: execute if answer is not a, b, c, d or e

cout << "invalid answer" << endl; // display error message

break; // end of default case

} //end of switch statement

} //end of main function

A PRACTICAL USE OF THE C++ SWITCH STATEMENT

The following is a practicle example. The actual C++ statements in each case are replaced with an explanation of what those C++ statements do.

//Place include iostream statement here

using namespace std;

int main(void)

{

int command_input;

cout << "select item number from menu" << endl;

cout << "1 Print list of employees" << endl;

cout << "2 Print list of employee wages" << endl;

cout << "3 Print list of new employees" << endl;

cout << "4 Print list of managers" << endl;

cout << "5 Print list of manager salaries" << endl;

cin >> command_input;

switch (command_input)

{

case 1:

//The C++ statements for this case

// print a list of employees

break;

case 2:

//The C++ statements for this case

//print a list of employee wages

break;

case 3:

//The C++ statements for this case

//prints a list of new employees

break;

case 4:

//The C++ statements for this case

//Prints a list of managers

break;

case (5):

//The C++ statements for this case

//Print a list of manager salaries

default:

//The C++ statements for this case

//responds to the invalid command_input

break;

} //end of switch statement

} //end of main function

References:

My own experiences during my career as a embedded systems software engineer.

The book 'C++ THE COMPLETE REFERENCE' by Herbert Schildt.

ISBN 0-07-222680-3