Tuesday, September 13

Wil's first program

As noted here, Wil started a little programming on Saturday.
RFI: I told Wil I wrote a BASIC program before I was his age to randomly generate D&D characteristics. He wants to start tomorrow. Start him on BASIC or something else like Javascript (which I have only the slightest familiarity with)?
I decided to go with Small Basic because of the simplicity and because I was confident I could help him quickly and we could get the program up and running.

 He really enjoyed it and spent a lot of time on it. Instead of working on the S&D characteristic generator, he spent most of his time on this Tron-inspired dialogue:
TextWindow.WriteLine("Hello Wil")
TextWindow.Write("Enter your Answer: ")
answer = TextWindow.Read()
If (answer = "Hello computer.") Then
  TextWindow.WriteLine("Shall we begin?")
Else
  TextWindow.WriteLine("Sorry Sir?")
 EndIf
 
TextWindow.WriteLine("Enter your Response: ")
response = TextWindow.Read()
If (response = "Yes.") Then
  TextWindow.WriteLine("Good.")
EndIf
  If (response = "Pardon me computer. Let's begin.") Then
  TextWindow.WriteLine("Yes, lets.")
EndIf
  If (response = "Yes." Or "Pardon me computer. Let's begin.") Then
  Else
    TextWindow.WriteLine("I don't understand.")
  EndIf
TextWindow.WriteLine("Enter your command: ")
command = TextWindow.Read()
If (command = "Begin scan.") Then
  TextWindow.WriteLine("Begining sweep.")
EndIf
  If (command = "Enter camera mode.") Then
    TextWindow.WriteLine("Camera mode is already active.")
EndIf
TextWindow.WriteLine("Enter specific instruction: ")
 
  instruction = TextWindow.Read()
 
  If (instruction = "What's my sister doing?" And Clock.Hour < 7) Then
    TextWindow.WriteLine("Sleeping.")
EndIf
  If (instruction = "What's my sister doing?" And Clock.Hour = 7) Then
    TextWindow.WriteLine("She is on her Ipod.")
EndIf
  If (instruction = "What's my sister doing?" And Clock.Hour > 12) Then
    TextWindow.WriteLine( "She's on the computer.")
EndIf

2 comments:

Amy said...

Very fun! I love the way he speaks. And I'm sure Elizabeth is just thrilled with the last part. :)

How do you do this? I know I got a degree in computers at Grove City, but I don't have the first clue on how to find a way to write a program (other than Excel macros!). Where do you get Small Basic?

Sean Meade said...

hey, Amy. glad you liked it :-)

http://smallbasic.com/default.aspx

the Small Basic app that you download is very light and has helps that make it easy to get up and running. eg, you start to type a word and it provides options in the right sidebar.