Community
    • Login

    how to add questions in Notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 2.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mohammed BismillahM
      Mohammed Bismillah
      last edited by

      Below is my code for a simple game as a batch file using notepad++. i have tried to add another questions but having problems with it. please can someone help me

      @echo off
      title game
      :menu
      echo 1) start
      echo 2) intro
      echo 3) exit
      set /p menu=

      if %menu% == 1 goto game
      if %menu% == 2 goto help
      if %menu% == 3 exit

      :help
      cls
      echo hit the correct answer and press enter.
      pause

      :game
      echo what is your name?
      set /p name=
      echo hello %name%!
      pause
      cls
      echo who was the first president of the USA?
      echo 1) George Washington
      echo 2) Pierre Desperau
      set /p ab=

      if %ab% == 1 goto cr1
      if %ab% == 2 goto wr1

      :cr1
      echo correct
      pause
      goto menu

      :wr1
      echo wrong
      pause
      goto game
      cls

      1 Reply Last reply Reply Quote -1
      • PeterJonesP
        PeterJones
        last edited by

        The answer for how do edit your batch file with Notepad++ is to “open the file in Notepad++. Move the cursor to the appropriate line of code. Type to add new code, or highlight and type-over to replace code, or backspace to remove code. Remember to save often.” We could even help you with how to automate running the code from inside Notepad++, either by spawning a new window (Run > Run > cmd /c "$(FULL_CURRENT_PATH)") or by using a plugin which can show the results in a subwindow of Notepad++ (like NppExec)

        This is a forum about Notepad++, and how to use it. This is not a general programming forum. There are plenty of forums out there that can help with programming questions (stackoverflow.com comes to mind).

        The question you have asked is the functional equivalent of going onto a Microsoft Office forum, and saying “Here is the novel I wrote with Word. Is there anyone who can tell me how to give my climax more oomph?” Novel-writing questions go in a novel-writing forum, not a forum for the word processor or other application used to type in novel; coding questions go in coding forums, not in the forum for the wonderful text editor you happen to be using to type in that code.

        That said, some general question-asking advice:

        As written, this question will get downvoted on stackoverflow, not just here[*]: when you ask a coding question in a coding forum, don’t expect people to do your problem solving for you without any effort on your part, and don’t expect them to write your code for you (which is basically what your request amounts to). You gave very little information, and didn’t show much effort (either in your posting, by giving details, or in your problem, by explaining what you’ve tried and how it didn’t work). Help people help you.

        What you should do is list the code you’re using (which you have, so that’s a slight point in your favor), what you want the code to do (which you don’t have), what’s wrong with what you’re getting now (which you don’t have), what you’ve tried (which you don’t have) and why what you’re trying doesn’t work (which you don’t have). You need to approach requests for help in coding forums with good explanations, showing that you’ve actually put effort into solving the problem yourself, and with a willingness to learn from the answers you’ve given.

        Also, if this is homework, you should clearly mark it as such: doing your homework for you will not help you learn. This looks like homework: that’s the most reasonable situation when someone inexperienced in batch programming would do something like write a quiz “game” in a batch file. Also, this looks like code that someone else gave you, that you’re trying to edit – like would happen in a homework assignment – because if you had the skills to be able to get that much written on your own, you problem of adding another question would be quite doable for you. If this is not homework, then it looks like you have taken someone else’s code and are trying to get someone else to edit it for you without your even trying to understand it or put effort into it (because all the programming techniques you would need to add another question are already present in the code you have listed).

        *: no, it wasn’t me; I only downvote spam or abuse. but whoever did was trying to indicate that this question doesn’t belong in this forum.

        1 Reply Last reply Reply Quote 4
        • guy038G
          guy038
          last edited by guy038

          Hello, @mohammed-bismillah,

          I rather agree with Peter’s post. To that purpose, read also this valuable article :

          http://www.catb.org/~esr/faqs/smart-questions.html

          Nevertheless, here is a simple solution for your batch file, below, which should clarify a bit how to proceed !

          @echo off
          
          title Game
          
          cls
          
          :menu
          
          echo.
          echo.
          echo     Start :  1
          echo     Help  :  2
          echo     Exit  :  3
          echo.
          
          set menu=
          set /p menu=
          
          if %menu%! == ! goto :EOF
          if %menu%  == 1 goto game
          if %menu%  == 2 goto help
          if %menu%  == 3 goto :EOF
          
          
          :help
          
          cls
          echo.
          echo.
          echo      Hit the CORRECT number and press ENTER.
          echo.
          echo.
          
          :game
          
          echo.
          echo.
          echo What is your name?
          echo.
          
          set name=
          set /p name=
          
          echo.
          echo     Hello %name%!
          echo.
          echo.
          echo.
          
          :qt1
          
          echo Who was the FIRST president of the USA?
          echo.
          echo   Pierre Desperau   :  1
          echo   George Washington :  2
          echo.
          
          set qt=
          set /p qt=
          
          if %qt%! == ! goto qt1
          if %qt%  == 1 echo     Incorrect & goto qt2
          if %qt%  == 2 echo     Correct !
          
          :qt2
          
          echo.
          echo Who is the LAST president of the USA?
          echo.
          echo   Donald Trump    :  1
          echo   Guy Thevenot    :  2
          echo   Emmanuel Macron :  3
          echo.
          
          set qt=
          set /p qt=
          
          if %qt%!  == ! goto qt2
          if %qt%   == 1 echo     Correct ! & goto qt3
          if %qt%   == 2 echo     Incorrect & goto qt3
          if %qt%   == 3 echo     Incorrect
          
          :qt3
          
          REM  And so on ....
          

          Best Regards

          guy038

          PS :

          if you prefer to quit the batch file, with a simple hit on the ENTER key, on each question, just change each line

          if %qt%! == ! goto qt##
          

          by the line :

          if %qt%! == ! goto :EOF
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors