I'm trying to retrieve the min value in an array that I have created calling this from another batch file.
Array has been created fine but the for /l
is not working. I think, there is something with the if statement:
@echo off
for /f "usebackq" %%a in ('%2') do set d=%%~a
for /f "usebackq tokens=* delims=%d%" %%G in ('%3') do set %1=%%~G
set /a i=-1
for %%h in (!%1!) do (
set /a i+=1
set %1[!i!]=%%h
)
if %4==min (
set /a n=%i%
for /l %%j in (0,1,%n%) do (
if %%j==0 (
set %4=!%1[%%j]!
) else (
if !%1[%%j]! lss !%4! (
set %4=!%1[%%j]!
)
)
) else (
set %4="Please write the name of the function correctly"
)
:::: below the file im calling this function
@echo off
setlocal EnableDelayedExpansion
call test char "," "30,10,40" min
echo !min!
:: char is %1
:: "," is %2
:: "30,10,40" is %3
:: min is %4
pause