samedi 28 novembre 2015

(Batch file)Value not expected in IF statement? [duplicate]

This question already has an answer here:

Finally decided to ask a question myself after not being able to find it.

So here's the deal: I'm trying to make a simple settlement management game for my homework assignment in DOS. In it you select an action (looking for food, new settlers) and there's an IF statement inside a FOR loop. The problem is that when the loop starts the first IF statement says that the chance value was unexpected.

Here's the bit of code:

echo how many people to send? set /p ppl= for /l %%y in (1,1,%ppl%) do ( set /a rand=%random% * 100 / 32768 + 1 if %rand% GEQ %foodch% ( set /a food=%food%+%foodc% ) ) set /a fooduse=%ppl%*275 goto turn

where: rand: a random number between 1 and 100; food: total amount of food in the settlement; foodch: the chance for a person to find food(depends on selected difficulty); foodc: the amount of food a person finds if the check passes(depends on selected difficulty)

The problem occurs at if %rand% GEQ %foodch%, where the program says "(value of %foodch%) was unexpected at this time.

Aucun commentaire:

Enregistrer un commentaire