none
Please Could You Help

    Question

  • Hi I'm New To Small Basic And I'm Wondering if anyone could teach me the basics because i have chose computing science as a GCSE and i am aiming for a high mark and the porgram we are using to program a game is Small basic could anyone help thanks :)
    Thursday, September 13, 2012 10:05 PM

Answers

  • Glad to see someone new! The best starting point is the PDF that comes with Microsoft Small Basic. It should be on the start menu in the same folder as Small Basic and is called "Introducing Small Basic". That is how I started programming and it really works. I have since moved on to C#/C++/Assembly and OS-development, but that PDF really got the ball rolling for me. Good luck with SB, and post any questions here (in a new thread) if you have any!
    Thursday, September 13, 2012 10:14 PM
  • Like this:

    randomNumber = Math.GetRandomNumber(50)
    While(guess < randomNumber Or guess > randomNumber)
      TextWindow.WriteLine("I'm Thinking Of A Number Between 1 And 50. Enter A Guess: ")
      guess = TextWindow.Read()
      
      If guess > randomNumber Then
        TextWindow.WriteLine("Your guess is too high!")
      EndIf
      
      If guess < randomNumber Then
        TextWindow.WriteLine("Your guess is too low!")
      EndIf
    EndWhile
    TextWindow.WriteLine("Well Done") 
    This will make the code more organized and readable to others. You wrote very nice code, but teachers usually rail against the use of "goto" because it makes the code harder to read =)


    Thursday, September 13, 2012 11:03 PM

All replies

  • Glad to see someone new! The best starting point is the PDF that comes with Microsoft Small Basic. It should be on the start menu in the same folder as Small Basic and is called "Introducing Small Basic". That is how I started programming and it really works. I have since moved on to C#/C++/Assembly and OS-development, but that PDF really got the ball rolling for me. Good luck with SB, and post any questions here (in a new thread) if you have any!
    Thursday, September 13, 2012 10:14 PM
  • Thanks Gungan :)
    Thursday, September 13, 2012 10:20 PM
  • Sure, no problem!
    Thursday, September 13, 2012 10:23 PM
  • Welcome xBasicsx!

    For a fast crashing course, I recommend  the Small Basic Curriculum or even download all of them as Power Point slides.

    It also helps a lot to study someone else's code in this very forum.

    Later, you can publish some code of yours here and we can try to advise you or even resolve them!   ;-)


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Thursday, September 13, 2012 10:25 PM
  • Is This Right?

    randomNumber = Math.GetRandomNumber(50)
    TextWindow.WriteLine("I'm Thinking Of A Number Between 1 And 50. Enter A Guess")
    MAKEGUESS:
    guess = TextWindow.Read()

    If guess = randomNumber Then
      TextWindow.WriteLine("Well Done") 
    EndIf 
      
      If guess > randomNumber Then
        TextWindow.WriteLine("your guess is to high")
        Goto MAKEGUESS
      EndIf
        
        If guess < randomNumber Then
          TextWindow.WriteLine("your guess is to low")
          Goto MAKEGUESS 
    EndIf
    Thursday, September 13, 2012 10:29 PM
  • Yes, looking great! However, you might want to consider removing the goto loop to avoid "spaghetti code" and use a "while" loop to determine if the guess is correct (keep going through the loop if it is not) then print the "Well done!" message.
    Thursday, September 13, 2012 10:39 PM
  • i actually don't know what you mean sorry mate but it still works so why change it?
    Thursday, September 13, 2012 10:47 PM
  • Like this:

    randomNumber = Math.GetRandomNumber(50)
    While(guess < randomNumber Or guess > randomNumber)
      TextWindow.WriteLine("I'm Thinking Of A Number Between 1 And 50. Enter A Guess: ")
      guess = TextWindow.Read()
      
      If guess > randomNumber Then
        TextWindow.WriteLine("Your guess is too high!")
      EndIf
      
      If guess < randomNumber Then
        TextWindow.WriteLine("Your guess is too low!")
      EndIf
    EndWhile
    TextWindow.WriteLine("Well Done") 
    This will make the code more organized and readable to others. You wrote very nice code, but teachers usually rail against the use of "goto" because it makes the code harder to read =)


    Thursday, September 13, 2012 11:03 PM
  • Goto statement is the most controversial programming feature ever!
    Even Java's creators purposefully have left it outta their 'precious'!
    However, it is present in the very core of CPU's machine language in the form of Jmp!

    We gotta remember though that SB learning materials mention Goto.
    And also, there are situations in which Goto is a viable genuine option as well!
    One of them is to go back to a program's initial point to start over again indefinitely.

    In xBasicsx's 'Guess a Number' program, after a player guesses it right, program just ends.
    A Goto placed at the very end to get back where a number is randomly picked is an easy practical & logical solution!

    Personally, I think the worst choice a programmer can make of Goto is when it is used in lieu of subroutines; going to someplace else within code to do some task, instead of that task being placed inside a Sub, where it is kept organized and separated from the main part!

    In short, if it's used sparingly, it's not a big deal at all!!!

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Friday, September 14, 2012 1:32 AM
  • I agree, goto is so controversial.  And yes, in assembly you have jmp, ja, jb, je, jnz, jne, jae, jbe, jno, and jo (think that's all =) ) And of course, you see that in any program (I guess "call proc..." is much less common). Enough assembly talk though...

    I agree with you that goto should never be used to replace subroutines. However, I still avoid them at all costs (except when programming in assembly language or when there is a need for infinite recursion)--- they just make the code to difficult to follow. Almost any time you can use goto, you can use a for loop, a while loop, an if ... elseif ... else tree. 


    Friday, September 14, 2012 2:32 AM