Multiple Call commands in batch file

July 7, 2010 at 08:51:39
Specs: Windows XP
Hi all,

I have a problem with using a call command more than once in a batch file. the code is:

@echo off
set HP=50
set HPMAX=100
set Pot=set /a hp=%hp%+20
set slot1=%pot%
if %hp% GEQ %hpmax% (set /a hp=%hpmax%) ELSE (Call %slot1%)
echo %hp%
pause >null
goto start

The idea is for the code to keep on adding 20 until it reaches 100. But it only adds once and stops.

Thanks for the help.

See More: Multiple Call commands in batch file

Report •

July 7, 2010 at 17:24:15
wow, what a gordian knot, Lol! I've never encountered code as convoluted as this. No offense, there's some neat ideas and potential for creativity therein, but i don't see how it could ever work for the simple task you've undertaken.
Here's the dummy's (ie: me, not you) version:
set hp=50
set hpmax=100
set /a hp+=20
if %hp% geq %hpmax% goto :eof
echo %hp%
goto :start
::-------- end
or, one-liner version:
for /L %%a in (50 20 %hpmax%) do echo %%a
::------- end
but you might have very good reasons for wanting to try to code it as you did, so i may be way out in left field. Maybe followup posts will reveal the mysteries...

Report •

July 8, 2010 at 01:20:01
lol thanks... it is pretty mest up but I do have some kinda reason for it. Was trying to create a little game which had a inventory and you would receive items (pot was one) and when used would increase the hp. Cause there will probably be a hell load of items, I thought that might be one of the easiest ways, that i know.....

Anyway thanks for the help. I appreciate it.

Report •
Related Solutions

Ask Question