David Rios
David Rios

Reputation: 161

How to make a batch file differentiate numbers

I don't know if I worded this right, but how would I make a batch file differentiate numbers?

For example; In my code, I have a string of code:

IF %var% GTR 0 && LSS 3

When I launch it, it loads the variable and then crashes. I discovered that it was this command causing the prompt to crash.

I want to tell whether if or not a number is greater than 0 and less than 3. For example, 2.

Upvotes: 0

Views: 43

Answers (1)

foxidrive
foxidrive

Reputation: 41234

This will still error if %var% is empty, so you can add a test for that also.

IF %var% GTR 0 IF %var% LSS 3 echo %var%

Upvotes: 3

Related Questions