They really aren't hard. This should help... I'll use text examples rather than script ones so it's easier to picture.

Premise:
I'm having a party and depending on the number of visitors who plan to attend, I'll have to decide how much food to buy.

Comparison (this is the IF/ELSEIF/ELSE part):
If 20 or more people come, I need to buy $100 worth of food. "Else" if 10-19 people come, I only need to buy $60 worth of food. "Else" if less than 10 come, I only need to buy $30 worth of food.

As you can see, only one of those will be true no matter what. I checked IF on the first one, then ELSEIF on the second, then ELSE (or ELSEIF works as well) on the third.

The way it works is:

; Check this line first. If it matches, skip all ELSEIF/ELSE that directly follow.
IF ()
; If the IF failed, check this. If it matches, skip any other ELSEIF's that follow as well as any ELSE at the end.
ELSEIF ()
; If the ELSEIF failed, check this. Only 1 ELSE can be used in a group of IF/ELSEIF/ELSE or IF/ELSE and can only be at the end of a group of IF/ELSEIF/ELSE or IF/ELSE. So if the ELSE matches or doesn't match, you just continue on from there as there isn't anything else to skip.
ELSE ()

A group of IF/ELSEIF/ELSE or IF/ELSE can have only 1 IF and only 0 or 1 ELSE, but can have an unlimited number (0+) of ELSEIF between them. If you have anything else in the middle, it will break/split the group.
---
This is a single group. After the first match, all following items will be ignored.

IF ()
ELSEIF ()
ELSEIF ()
ELSEIF ()
ELSE ()

---
This is 2 groups. Notice that the first doesn't use an ELSE and the second doesn't use an ELSEIF. That's up to you and what you're doing. If something matches in the first group, everything following that is IN that group will be skipped. Then, if anything matches in the second group, anything following that is IN that group will be skipped.

IF ()
ELSEIF ()
ELSEIF ()
MSG $CHAN ....
IF ()
ELSE ()
---

Basically, ELSEIF is just like IF, but follows the IF and does the same thing as IF except that it will be skipped if the IF or an ELSEIF that is before it matches. This prevents any need to halt the script and speeds things up as well rather than checking a lot of IFs that don't need to be checked if you already know they'll fail because of a match on an earlier IF.

An ELSE is always at the end (if used) and basically says that if nothing else matched in the group, this is done no matter what. It's only done if the IF and any ELSEIF's in the group don't match. You'd use ELSE anytime that you are covering all possibilities in a comparison, such as checking 3 things (0-9, 10-19, 20+). If those are the only possible matches, and you checked 0-9 and 10-19, then you already know that if they failed, then it has to be 20+. So rather than checking it, you can just use ELSE and avoid the check.

I hope that helps to explain it. If you have questions, just ask. ELSEIF and ELSE are really not any different from IF except that they can be skipped if something before them matches.


Invision Support
#Invision on irc.irchighway.net