none
TextWindow.ReadNumber() and TextWindow.Read() not working. Is this a bug? RRS feed

  • Question

  • Hi there forum. I have just started learning programming using small basic with the beginners guide provided.

    I entered the following code which is exactly the same as the code in the guide but my console only displays the "Enter a number: " then does not display any number entered, and closes when i hit enter. what am i doing wrong? 

    TextWindow.Write("Enter a number: ")
    num = TextWindow.ReadNumber()
    remainder = Math.Remainder(num, 2)
    If (remainder = 0) Then
      TextWindow.WriteLine("The number is Even")
    Else
      TextWindow.WriteLine("The number is Odd")
    EndIf

    Saturday, April 21, 2012 12:51 PM

Answers

  • Enter a number is a request for YOU to enter a number - for example type "13" and return to enter it.

    Saturday, April 21, 2012 1:10 PM
    Moderator
  • Can you type into a normal cmd console?  Get one using the shortcut Windows Key+r then type cmd, or from Start|All Programs|Accessories|Command Prompt and the type cmd.

    Also try modifying the code to be TextWindow.Read() instead of TextWindow.ReadNumber().  The ReadNumber variant would behave as you describe if you enter a letter or for some reason it is not interpreting your input as a number.


    PS if you are usinhg the number keypad on the right rather than the numbers on the top row you need to press NumLock first
    Saturday, April 21, 2012 2:39 PM
    Moderator
  • If you use ten keys, push [Num Lock] key before using.

    Nonki Takahashi

    Thursday, April 26, 2012 1:22 PM
    Moderator

All replies

  • Enter a number is a request for YOU to enter a number - for example type "13" and return to enter it.

    Saturday, April 21, 2012 1:10 PM
    Moderator
  • My console opens as yours has displaying "Enter a number" but when I type in a number, where you have entered "13" it does not display what I am inputting, the line stays blank and when I hit enter it just exits as it would after the "press any key to continue..." prompt.

     

    Saturday, April 21, 2012 2:29 PM
  • I dont know what has just happenned but it just started to let me input numbers.

    Thanks for your help on such a basic problem.

    Saturday, April 21, 2012 2:38 PM
  • Can you type into a normal cmd console?  Get one using the shortcut Windows Key+r then type cmd, or from Start|All Programs|Accessories|Command Prompt and the type cmd.

    Also try modifying the code to be TextWindow.Read() instead of TextWindow.ReadNumber().  The ReadNumber variant would behave as you describe if you enter a letter or for some reason it is not interpreting your input as a number.


    PS if you are usinhg the number keypad on the right rather than the numbers on the top row you need to press NumLock first
    Saturday, April 21, 2012 2:39 PM
    Moderator
  •  

    Hello Yipman

    I am novice also. Windows 7 Starter. Small Basic 1.0, with Extensions.

    I've written this code
    TextWindow.Write("Enter a number: ")
     num = TextWindow.ReadNumber()
     remainder = Math.Remainder(num, 2)
     If (remainder = 0) Then
       TextWindow.WriteLine("The number is Even")
     Else
       TextWindow.WriteLine("The number is Odd")
     EndIf

    and this is the output

      

     

    It would not be desirable reinstall the product?

    Best regards


    carlosfmur - Buenos Aires

    Wednesday, April 25, 2012 9:52 PM
  • If you use ten keys, push [Num Lock] key before using.

    Nonki Takahashi

    Thursday, April 26, 2012 1:22 PM
    Moderator