Solved I need some help with an if statement.

June 2, 2017 at 18:30:46
Specs: Windows 10
@echo off
set /a x=0

set /p input=
if %input%== test goto test
If %input%== begin goto beginning

I want to make it where the if statement "if %input%== test goto test" only shows up after the variable "x" = 100. Can I please get some help.


See More: I need some help with an if statement.

Reply ↓  Report •

#1
June 2, 2017 at 21:31:03
✔ Best Answer
set /a x=0
...
rem add for safety, clear 'input' first:
set input=
set /p input=
rem recommend ALWAYS allow for case of user enters a null entry
if not defined input goto ...

::-------
a couple of ways, 1:

if "%input%%c%"=="test100" goto :test

or 2:
if "%input%"=="test" if "%c%"=="100" goto :test
...
If "%input%"=="begin" goto :beginning

message edited by nbrane


Reply ↓  Report •

#2
June 2, 2017 at 21:55:01
Thank you for the help those methods worked nicely. I found the reason why nothing I tried worked though, I set the variable to 0 after the label. *face plam*
:a
SET /a x=0
set /p input=
if not defined input goto a
If. . .
If. . .
goto a

message edited by CarbonCuber


Reply ↓  Report •
Related Solutions


Ask Question