DOS Commands

From PeformIQ Upgrade
Revision as of 08:40, 17 September 2013 by PeterHarding (talk | contribs) (Created page with "=Handling Arguments= <pre> SET /A ARGS_COUNT=0 FOR %%A in (%*) DO SET /A ARGS_COUNT+=1 </pre> <pre> @echo off setlocal enableextensions enabledelayedexpansion call :...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Handling Arguments

SET /A ARGS_COUNT=0    
FOR %%A in (%*) DO SET /A ARGS_COUNT+=1    
@echo off
setlocal enableextensions enabledelayedexpansion
call :getargc argc %*
echo Count is %argc%
echo Args are %*
endlocal
goto :eof

:getargc
    set getargc_v0=%1
    set /a "%getargc_v0% = 0"
:getargc_l0
    if not x%2x==xx (
        shift
        set /a "%getargc_v0% = %getargc_v0% + 1"
        goto :getargc_l0
    )
    set getargc_v0=
    goto :eof