Calling function from included batch file with a parameter

Viewed 5565

In my main batch file I include another batch file and want to call a function defined in there, code looks like following:

@echo off
call define_wait.bat

if "%1"=="WAIT" (
    call :WAIT_AND_PRINT 5
    echo.
)

REM rest...

My define_wait.bat looks like following:

:WAIT_AND_PRINT
set /a time=%1
for /l %%x in (1, 1, %time%) do (
    ping -n 1 -w 1000 1.0.0.0 > null
    echo|set /p=.
)
goto :EOF

:WAIT
set /a time="%1 * 1000"
ping -n 1 -w %time% 1.0.0.0 > null
goto :EOF

The problem is that if I define the wait function in another batch file it does not work, calling call :WAIT_AND_PRINT 5 does not hand on the parameter correctly (Error: missing operand)... If I copy my code from my define_wait.bat int my main batch file, everything works fine...

How would I make that correctly?

3 Answers
Related