1

Topic: [BAT] a problem with if

There is a following code:

@echo off
set/P aud_c = "aud:"
set/a aud_v=0
:audid
if not %aud_c % equ 0 (
set/a aud_v = % aud_v % + 1
set/P aud_id. % aud_v % = "ID %aud_v %:"
if not "%aud_v %" equ "%aud_c %" (goto audid))

the Problem that for the first time does not work "set/a aud_v = % aud_v % + 1", i.e. the variable and remains equal to zero.
After variable input (set/P aud_id. % aud_v % = "ID %aud_v %:") and goto - the variable is already equal to unit.
Please, prompt in what a problem.

2

Re: [BAT] a problem with if

cdmad
Please, prompt in what a problem.
In early substitution of values. In the script beginning add "setlocal enabledelayedexpansion", expression rewrite as "set/a aud_v =! aud_v! +1". For judgement read help set.

3

Re: [BAT] a problem with if

Black Tiger
Thanks, helped!