Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>if %upts%*%utroop% LEQ %epts%*%etroopt%</code> does not calculate the value of each side, it strings together <code>the contants of upts</code>*<code>the contents of utroop</code> and compares that string against the RHS. You need to explicitly calculate the two values into variables using a <code>SET</code>.</p> <p>Your <code>ELSE</code> clause invokes a "block statement" that is, the ENTIRE contents of the parenthesised series of statements up to the closing <code>)</code> following <code>enddo</code>. Batch parses the statement from the <code>IF</code> through to the closing parenthesis of the <code>ELSE</code> block, substitutes for any <code>%var%</code> with the PARSE-TIME value of <code>var</code> and <strong>THEN</strong> executes the result. Consequently, <code>TYPE</code> will appear unchanged to the logic within the block.</p> <p>You'd need to invoke <code>delayedexpansion</code> mode and use <code>!var!</code> to access the RUN-TIME value of <code>var</code>. This is done with a <code>SETLOCAL ENABLEDELAYEDEXPANSION</code> statement, usually inserted after the opening <code>@echo off</code> at the start of the batch (hence turning delayedexpansion and the <code>!var!</code> facility ON for the entire duration of the batch)</p> <p>Actually, there's no need for an <code>ELSE</code> clause as you have it because you <code>GOTO</code> a label in the true part. This may simplify your code.</p> <p>Finally, there's no <code>DO/ENDDO</code> facility in batch - or at least, not in that form. I'll presume that you intend to do the intervening code <code>%dmg%</code> times. You can achieve this by using</p> <pre><code>for /L %%z in (1,1,%dmg%) do ( intervening code ) </code></pre> <p>where the metavariable <code>%%z</code> will be incremented from the first element in the parentheses to the last in steps of the second. <code>%%z</code> can be any letter, but is one of the very few cases in batch which <strong>IS</strong> case-sensitive.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload