Page 1 of 1

should be numeric only

Posted: 30 Aug 2007 03:04
by sivaram.nv
I Want to check the string only numeric

for example

Port=1111 (which i want)

port=wjke111 (which i dont want)

how do i check above condition..

Thnaks & regards

Sivaram Nv

isNumeric function

Posted: 30 Aug 2007 15:13
by jeb
Hi Sivaram,

this should solve it.

@echo off

set myNum=%1

call :isNumeric %myNum% result
echo %result%
goto :eof


::************************
:isnumeric
setlocal
set rest=_
for /f "delims=0123456789" %%a in ("%~1") do set rest=_%%a
set return=false
if "%rest%"=="_" set return=true
( endlocal
if "%~2" NEQ "" set %~2=%return%
goto:eof
)