hi,

I have the following code which asks user a question and gets response. I
need to check response for validity but the following if statement is always
evaluated as true even when correct response is entered:

wscript.stdout.write "What is the SOURCE file type? (user/computer/group): "
strSourceFileType = trim(ucase(wscript.stdin.readline))
if strSourceFileType <> "user" or strSourceFileType <> "computer" or
strSourceFileType <> "group" then
err.raise 449
ErrHandler
end if

Even when I enter "user" or "computer" or "group" (without quotes) at the
prompt the condition evaluates as true and returns "Microsoft VBScript
runtime error: Argument not optional"

I have witten value of strsourcefiletype to screen and it is populated
correctly with no spaces, etc. as expected by the condition right after it is
read. Now if i simply specify:
if strSourceFileType <> "user" then

without the other two OR conditions and type "user" at the prompt all works
fine. I don't understand why I cannot look for the other values in the field
too. ???

thanks again.

Re: checking response from readline by Ayush

Ayush
Wed Feb 28 10:35:21 CST 2007

Replied to [RdS]s message :
> hi,

> I have the following code which asks user a question and gets response. I
> need to check response for validity but the following if statement is always
> evaluated as true even when correct response is entered:

> wscript.stdout.write "What is the SOURCE file type? (user/computer/group): "
> strSourceFileType = trim(ucase(wscript.stdin.readline))
> if strSourceFileType <> "user" or strSourceFileType <> "computer" or
> strSourceFileType <> "group" then
> err.raise 449
> ErrHandler
> end if


Change ORs to ANDs


Good Luck, Ayush.
--
Scripting Solutions Center : http://snipurl.com/Scripting_Solutions

RE: checking response from readline by urkec

urkec
Wed Feb 28 11:58:03 CST 2007

'you should use AND instead of OR


wscript.stdout.write "What is the SOURCE file type? (user/computer/group): "
strSourceFileType = Lcase(trim(wscript.stdin.readline))
if strSourceFileType <> "user" and strSourceFileType <> "computer" and
strSourceFileType <> "group" then
err.raise 449
ErrHandler
end if
--
urkec


"RdS" wrote:

> hi,
>
> I have the following code which asks user a question and gets response. I
> need to check response for validity but the following if statement is always
> evaluated as true even when correct response is entered:
>
> wscript.stdout.write "What is the SOURCE file type? (user/computer/group): "
> strSourceFileType = trim(ucase(wscript.stdin.readline))
> if strSourceFileType <> "user" or strSourceFileType <> "computer" or
> strSourceFileType <> "group" then
> err.raise 449
> ErrHandler
> end if
>
> Even when I enter "user" or "computer" or "group" (without quotes) at the
> prompt the condition evaluates as true and returns "Microsoft VBScript
> runtime error: Argument not optional"
>
> I have witten value of strsourcefiletype to screen and it is populated
> correctly with no spaces, etc. as expected by the condition right after it is
> read. Now if i simply specify:
> if strSourceFileType <> "user" then
>
> without the other two OR conditions and type "user" at the prompt all works
> fine. I don't understand why I cannot look for the other values in the field
> too. ???
>
> thanks again.

RE: checking response from readline by v-wywang

v-wywang
Thu Mar 01 04:53:45 CST 2007

Hi,

I think so. It should be
if strSourceFileType <> "user" and strSourceFileType <> "computer" and
strSourceFileType <> "group" then

Do you have met any further question? Please feel free to let us know. We
are glad to assist you.

Have a great day.
Sincerely,
Wen Yuan