How to get a subtracted %var% to jump a code segment

January 19, 2020 at 16:34:54
Specs: Android
So I need %var% when it reaches 0 to jump to a code segment
I have tried:

Set /a gold=%gold%-500
If %gold% LSS '0' goto a

Set /a gold=%gold%-500
If %gold% == '0' goto a

Set /a gold=%gold%-500
If %gold% NEQ 500 goto a
I am several thousand keystrokes in and would like to finish my project.


See More: How to get a subtracted %var% to jump a code segment


#1
January 19, 2020 at 22:00:41
Right before you do the set /a, put an echo: echo "%gold%"
( the quotes are simply to show any spaces within the variable)
pause
right after the set /a, put another echo of "%gold%"
pause
do the compare but only report "yes" or "no" as per zero, then pause.
That should be enough info to figure this out.

message edited by nbrane


Report •

#2
February 6, 2020 at 08:11:06
I would say:

if %gold% LEQ 0 goto :a


LSS is less than, while
LEQ is less or equal than

Don't use EQU for when evaluating a range, because if it isn't exactly that value, you may miss the border value and fall into the wrong range (lower than zero), and never get out.

message edited by Looge


Report •
Related Solutions


Ask Question