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

Author Topic: Checking a list ...  (Read 2338 times)

0 Members and 1 Guest are viewing this topic.

CameronY

    Topic Starter


    Intermediate

    Checking a list ...
    « on: February 26, 2006, 05:13:03 AM »
    How do I check to see if the %Instance% entered by a user exists in space separated variable ....

    [highlight]set BOS-Instances=demo live qa train[/highlight]

    Not entirely sure how to write what I suspect will be a FOR routine to handle this.  If the %Instance% entered does not exist in the list, then I'll have it exit the script.

    Thanks in advance.

    carlos

    • Guest
    Re: Checking a list ...
    « Reply #1 on: February 26, 2006, 12:32:03 PM »
    You need to effort a little bit more.  ;D
    You can do it with the old FOR of MS-DOS

    Code: [Select]
    @echo off
    set BOS-Instances=demo live qa train

    set Instance=
    set /P Instance="Option: "
    for %%x in (%BOS-Instances%) do if /I "%Instance%" EQU "%%x" goto GOOD

    :BAD
    echo Bye
    goto :eof

    :GOOD
    echo Value: %Instance%
    « Last Edit: February 26, 2006, 12:33:14 PM by carlos »