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
Post a Comment