1

I'm trying to make a CYOA game through .bat files. I want the user to be in a loop until they want to leave but I can't get an IF inside the loop (the conditional to exit) to work.

set "can1=0"

:w1
    :: vvv I think it's this line that doesn't work vvv
    if not "%can1%"=="1" (
        if /i "%r1%"=="look around" (
            echo Anything else?
            set /p r1=":: "
            goto :w1
        )
        :: ...
    ) else (
        echo Can continue...
    )

    endlocal

I want the loop to continue until the player says something specific (I'll determine that later), but it gives the

The syntax of the command is incorrect.

error that seems to be case-specific.

  • 2
    Don't use `::` for comments, it's actually a label definition that *pretends* to be a comment, and it stuffs up complex loops and conditionals. Use `rem` instead. – paxdiablo Oct 22 '19 at 01:21
  • @paxdiablo Thanks! That worked. (like it actually got rid of the error) – FirePhoenix555 Oct 22 '19 at 02:02
  • Possible duplicate of [Which comment style should I use in batch files?](https://stackoverflow.com/questions/12407800/which-comment-style-should-i-use-in-batch-files) – phuclv Oct 22 '19 at 06:58

0 Answers0