Chaining boolean expressions

Hello!

I've got a fairly legnthy script that I'm having trouble getting to work. When I run the script, I get the following error:
Eggplant wrote:
STInvalidBooleanException Value is not true or false, or yes or no: 2K

The offending loop in my script is:
if currOS is equal to "XP" or "2K" or "ME" or "98" then
	typetext shiftdown &controldown &"N" &shiftup &controlup
else 
	typetext "\s\aN\S\A"
end if

The variable currOS is coming in from another script and is properly set to XP for this particular run.

Do I need to separate all these into separate else if/then loops? If not, what did I do wrong?

TIA,

Allen

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    Hi, Allen:

    The problem is that all of the items you've joined by "OR"s need to be boolean expressions. Your code should look like this:
    if currOS is equal to "XP" or currOS is equal to "2K" or currOS is equal to "ME" or currOS is equal to "98" then 
    ? ?typetext shiftdown & controldown & "N" & shiftup & controlup 
    else 
    ? ?typetext "\s\aN\S\A" 
    end if
    

    You could also do something like this:
    if currOS is in ( "XP", "2K", "ME", "98" ) then...
    

    If you're going to be making this comparison frequently, then you might want to put the list into a variable:
    put ( "XP", "2K", "ME", "98" ) into WinOS
    if curOS is in WinOS then...
    
Sign In or Register to comment.