logo
down
shadow

"if" statements in batch: file crashes when the input is supposed to be a number, but instead has words with s


"if" statements in batch: file crashes when the input is supposed to be a number, but instead has words with s

By : Auto Load Board
Date : November 22 2020, 02:42 PM
wish helps you So, I have a set /p thing in a batch file. For the user to proceed, they must type "2". I can't seem to find my specific problem anywhere. , You can check if your answer is a number using this:
code :
set /a test=%oneplusone%*1
if %test%==0 goto notValid
@echo off
echo "What is 1+1"

set /p oneplusone=Type Answer Here: 
set /a test=%oneplusone%*1
if %test%==0 goto notValid
if %oneplusone%==2 goto correct
if %oneplusone% neq 2 goto incorrect

:correct
cls
echo Correct!
pause
goto youranswer

:incorrect
cls
echo Wrong.
pause
goto youranswer

:notValid
cls
echo Your input is not valid

pause
goto youranswer

:youranswer
cls
echo You answered: %oneplusone%


Share : facebook icon twitter icon
"Programming" a Batch file, IF statements inside IF statements?

"Programming" a Batch file, IF statements inside IF statements?


By : Roch Guillot
Date : March 29 2020, 07:55 AM
this will help cmd can handle nested ifs just fine. Your problem is a different one. As it stands all your if checks, except for the first will not do what you want.
Use delayed expansion by putting a
code :
setlocal enabledelayedexpansion
if not errorlevel 1 ...
if %errorlevel%==0
How would I select only the number "2007" from the number "20071406" in an input file and store it i

How would I select only the number "2007" from the number "20071406" in an input file and store it i


By : lorebandi
Date : March 29 2020, 07:55 AM
hop of those help? Input File:
code :
#include <iostream>

int main()
{
  char n1[5];
  char n2[3];

  n1[4] = 0;
  n2[2] = 0;

  for(int i = 0; i < 4; i++)
    std::cin >> n1[i];
  for(int i = 0; i < 2; i++)
    std::cin >> n2[i];

  std::cout << n1 << " " << n2 << std::endl;
  return 0;
} 
How to use Scanner in java to count the number of words seperate by "," from a input .txt file?

How to use Scanner in java to count the number of words seperate by "," from a input .txt file?


By : Ting
Date : March 29 2020, 07:55 AM
With these it helps I like shorter answers. ;) This reads the text, removes spaces and builds an int[][] from the text.
batch "set /p" crashes when no input

batch "set /p" crashes when no input


By : Serkan Çobanoğlu
Date : March 29 2020, 07:55 AM
I wish this help you (I'll use this script as an example) , Common problem - most, but not all of which is solved by
Make "x" number of copies based on user input in Windows batch file

Make "x" number of copies based on user input in Windows batch file


By : alexreiling
Date : March 29 2020, 07:55 AM
I wish this helpful for you Since the files will have to have different names, I'll assume you want to append the sequence number to the file name, such as %Output%\%PtID%_X.txt where X is the sequence number.
In that case, you can simply use for to do a loop, something like:
code :
for /l %%a in (1,1,%SeriesInstance%) do (
  (
    echo 0020000D   %TestNum%
    echo 0020000E   %%a
    echo 00080018   %%a
    echo 00080020   %StudyDate%
    rem rest of echo statements here
  ) >%Output%/%PtID%_%%a.txt
)
shadow
Privacy Policy - Terms - Contact Us © animezone.co