Respond to this messageReturn to Index
Original Message
  • Some suggestions
    • Solitaire (Login Solitaire1)
      S
      Posted Aug 6, 2012 11:32 AM

      You have a multitude of bugs in your program. Here are a few simple suggestions to start you off:

      1. Add
      END SELECT
      just before the "wronganswer:"

      2. Add
      GOTO wordslist
      and delete the END in the wronganswer section.

      3. Add
      IF cont1$ = "EXIT" THEN END
      right after wordslist:
      This will allow user to end the program after any of the words.

      4. User input of a phrase to make a selection is very tricky. It's best to present a single number or letter for the user to enter. Here is how you can do it:

      menu:
      PRINT "Welcome to Learn French!"
      PRINT "Please select an option!"
      PRINT "1: Load Profile"
      PRINT "2: New Profile"
      PRINT "3: Start Learning"
      PRINT "4: Exit"
      INPUT "...", option1$
      IF option1$ = "1" THEN GOTO load
      IF option1$ = "2" THEN GOTO NEW
      IF option1$ = "3" THEN GOTO BEGIN
      IF option1$ = "4" THEN GOTO FIN1

      ===========================================================

      The overall design of your program leaves a great deal to be desired. If you are starting out with QB, then you should be learning how to use structured programming and NOT using GOTO at all. At the least, you should use subroutines with GOSUB and RETURN for each of the separate sections.

      Here is a simple example of a menu with subroutines. It uses a DO loop to repeat. Copy it and paste it into a new QB program to see how it works. Then see if you can adapt it to use with your own program.

      ============================================================
      DO
        CLS
        PRINT "MENU"
        PRINT : PRINT "1- Chess"
        PRINT "2- Checkers"
        PRINT "3- Monopoly"
        PRINT "4- Quit"
        PRINT : INPUT "Enter 1, 2, 3, or 4: ", choice$
        CLS
        SELECT CASE choice$
          CASE "1"
            GOSUB Chess
          CASE "2"
            GOSUB Checkers
          CASE "3"
            GOSUB Monopoly
          CASE "4"
            END
        END SELECT
      LOOP

      Chess:
      PRINT "Play chess here."
      INPUT "Enter to return to menu. ", E$
      RETURN

      Checkers:
      PRINT "Play checkers here."
      INPUT "Enter to return to menu. ", E$
      RETURN

      Monopoly:
      PRINT "Play Monopoly here."
      INPUT "Enter to return to menu. ", E$
      RETURN


    Your Name
    Your Email
    (Optional)
    Message Title
    Message Text
    Options Also send responses to my email address