Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Check If Variable Contains Anything But Numbers  (Read 2659 times)

0 Members and 1 Guest are viewing this topic.

elel302

  • Guest
Check If Variable Contains Anything But Numbers
« on: September 13, 2009, 05:17:52 AM »
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]

gh0std0g74



    Apprentice

    Thanked: 37
    Re: Check If Variable Contains Anything But Numbers
    « Reply #1 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

    elel302

    • Guest
    Re: Check If Variable Contains Anything But Numbers
    « Reply #2 on: September 13, 2009, 05:58:20 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!