1.

Solve : Check If Variable Contains Anything But Numbers?

Answer»

I have a batch program that you run like:
wait.bat 20 < That will wait 20 seconds.
It works with the help from VBScript but it brings up a window if there is an error which I wan't my own error message, so how can I check the %1 variable for ANYTHING but numbers?
PLZ HELP!

THANX!

Code: [Select]@echo off
if "%1"=="" goto error2
set /a sec=%1*1000
>%temp%\$$$.vbs echo WScript.Sleep(%sec%)
start /wait %temp%\$$$.vbs
goto end
:error1
echo Wait.exe
echo ------------------------------
echo ERROR#1: DO NOT USE LETTERS.
echo USAGE: wait.exe (seconds)
echo ------------------------------
pause
goto end
:error2
echo Wait.exe
echo ------------------------------
echo ERROR#2: NO SECONDS GIVEN TO WAIT.
echo USAGE: wait.exe (seconds)
echo ------------------------------
pause
:end

If it detects anything but numbers I would like it to goto :error1

When it's done I'm compiling with Quick BFC

[attachment deleted by admin]since you are using a hybrid, you can do CHECKING easily with vbscript function called IsNumeric(). use it somewhere before the Wscript.Sleep() line...
check my sig for vbscript MANUAL for more informationQuote from: gh0std0g74 on September 13, 2009, 05:34:17 AM

since you are using a hybrid, you can do checking easily with vbscript function called IsNumeric(). use it somewhere before the Wscript.Sleep() line...
check my sig for vbscript manual for more information

Thanx I'll try that after!


Discussion

No Comment Found