locked
input RRS feed

  • Question

  • Hi I have included this code fragment below. My problem is that it works in the downloaded version of Small Basic but it does not work with the online version and I cannot see why?

    In the SmallBasic application when you run the code it gives the options then waits for input and ENTER. In the online version the code runs straight through avoiding the selection?

    Have I missed anything?

    The extended program with all parts is at the bottom marked 'INTRO

    TextWindow.Writeline("What would you like to do?")
    TextWindow.Writeline("Press M to grab the mirror and add to you inventory.")
    TextWindow.WriteLine("Press F to get the flare and add to your inventory.")
    TextWindow.WriteLine("Press S to get the stick and add it to your inventory.")
    inv1=Textwindow.Read()' inventory
    If inv1="S" Or inv1="s" then
    TextWindow.Clear()
    Goto scene1

    EndIf

    scene1:

    I would write what happens here.

    'INTRO

    nL = Text.GetCharacter(010)
    TextWindow.ForegroundColor="green"
    TextWindow.WriteLine("##########################################################")
    TextWindow.WriteLine("############### Welcome to Cave Adventure ################")
    TextWindow.WriteLine("##########################################################")
    TextWindow.WriteLine("")
    Program.Delay(2000)
    TextWindow.Write("Hello What is your name? ")
    name=TextWindow.Read()
    TextWindow.Clear() 
    TextWindow.WriteLine("It is now "+Clock.Time)
    TextWindow.WriteLine("")
    TextWindow.WriteLine(name+" ...you are awake, the sky is dark, with millions of stars on show. "+nL+"As you try to stand you wince in pain as you realise that your "+nL+ "leg is chained to the ground.")
    'scene 1 options
    TextWindow.Writeline("What would you like to do?"+nL)
    TextWindow.Writeline("Press M to grab the mirror and add to you inventory.")
    TextWindow.WriteLine("Press F to get the flare and add to your inventory.")
    TextWindow.WriteLine("Press S to get the stick and add it to your inventory.")

    inv1=Textwindow.Read()' inventory
    If inv1="S" Or inv1="s" then
      TextWindow.Clear()
      Goto scene1
    EndIf

    If inv1="M" Or inv1="m" then
      TextWindow.Clear()
      Goto scene2
    EndIf

    If inv1="F" Or inv="f" then
      TextWindow.Clear()
      Goto scene1
    EndIf

    scene1:'world 1
    TextWindow.WriteLine("")
    TextWindow.ForegroundColor="red"
    TextWindow.Write("There is a bubbling sound, I didn't eat beans? Oh no, I am sinking... I can see "+nL+"some keys hanging on a tree but I cannot reach them. What can I do?"+nL)
    TextWindow.ForegroundColor="white"

    TextWindow.Writeline("Press S to use the stick.")
    TextWindow.WriteLine("Press F to use the flare.")
    inv1=Textwindow.Read()' inventory
    If inv1="F" Or inv="f" then
      TextWindow.Clear()
      TextWindow.WriteLine("cannot light the flare")
      TextWindow.WriteLine("")
      TextWindow.WriteLine("Choose again")
      EndIf
    If inv1="S" Or inv="s" then
      TextWindow.WriteLine("You grab the stick and manage to hook the keys. As you sink you are able to unlock your chains")
    EndIf
    scene2: 'world 2
    TextWindow.WriteLine("")
    TextWindow.WriteLine("Just to test that World 2 loads!!!!!!!")
    TextWindow.WriteLine("")
    TextWindow.WriteLine("Press Q to Quit")

    Quit=Textwindow.Read()' inventory
    If Quit ="Q" Then
      TextWindow.Clear()
      Program.Delay(2000)
      TextWindow.WriteLine("Game Over")
    EndIf

    end:

    Wednesday, May 27, 2020 2:13 PM

Answers

  • Hi tayTeach, SBO v1.0 doesn't work well with 'Textwindow.Read' instead of 'TextWindow.Read'.  Case insensitive seems to be allowed in compile time but not in runtime...

    Nonki Takahashi

    Wednesday, May 27, 2020 3:12 PM