[thelist] if else if sanity check

.jeff jeff at members.evolt.org
Wed Sep 12 17:38:44 CDT 2001


joel,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: spinhead
> 
> When an if-then finds a true condition to act on, does
> it exit, or could it continue checking for other true
> conditions?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

it exits, ignoring any further conditions.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> I've got an bit more or less like this:
> 
> If type = computer Then
>     do the computer stuff
>     ElseIf
>     type = test Then
>     do the test stuff
>     ElseIf
>     total > limit Then
>     go somewhere totally different
> End If
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

in basic logic it actually looks like this:

if(type == computer)
{
  do the computer stuff
}
else
{
  if(type == test)
  {
    do the test stuff
  }
  else
  {
    if(total > limit)
    {
      go somewhere total different
    }
  }
}

you can just shorthand it to:

if(type == computer)
{
  do the computer stuff
}
else if(type == test)
{
  do the test stuff
}
else if(total > limit)
{
  go somewhere total different
}

it makes more sense in the first one, why it works that way, right?

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list