windows - %x was unexpected at this time. batch script -
@echo for off / f "tokens = 1,2 delims =", "% x (my CSV ) Sometimes it works fine, sometimes it fails with the following error: (If% M% LSS% x set M = %% x) Max X value =% M%
< / Pre>
% x was unexpected at this time.
The problem is that you use % m% loop inside a
(before any iteration). In other words, before the execution, before the closing bracket and the entire loop is read and evaluated. Therefore,
% m%
will always be its initial value even if you are actually setting it in the loop.
For example, this example should be given:
Set Val = 7 in% i (1) (set val = 99 echo% wal%) resonance% Val%
resulting in unexpected (something):
7 99
Just because in the first echo statement < Code>% val% is interpreted (i.e., the whole code before that, before anybody is running) loop is interpreted.
In which m
is forced to set Should be the first %% x
using setlocal
command and ! M!
instead of % m%
Time will be delayed to evaluate m
Additionally, do not do anything initially with m
and it should be % x < When compelling to be / code>, is nothing will ensure that the first value of
% x x
is loaded into m
.
@echo off setlocal enableextensions enabled extension set m = to / f "to CAN = 1,2 DELAYED = "," %% x (my.csv) (if "! M! "==" "Set M = %% x if! M! Lss %% x set m = %% x) Using the above code with Max X value!!!!!! my.csv
Do: Your sample data in one more comment, as expected for Max X value = 10
, and
422,34 464,55 455, 65 421,88
You get:
Maximum X value = 464
Comments
Post a Comment