Originally Posted By: Mpot
I can't say I'm sure of when a script needs to be halted, or when it's going to halt itself, it seems safer to just add the line than to not. I can't see it hurting anything. Furthermore, when several if statements works just as well as ifelse and else, why use them and create something more confusing? The idea of my scripts most of the time isn't absolute speed, functionality, or properness. They're about me being able to understand them, how I wrote them, know exactly what they do, and they do what I want.

A script halts automatically when nothing else is in it or when nothing else will run (ie. You just did an IF that matched, so an ELSE that follows it won't run). So there's no reason to halt a script in these situations. And, as mentioned, don't use HALT anyhow. Use RETURN. Others can get into the reasons why using HALT for this form of halting can cause problems, but you should avoid using HALT for this type of halting.

As far as IF/ELSEIF/ELSE, yes it does affect speed, but that's not why I said that you should use it. If you look at my posts in topics that discuss speed, you'll find that I often point out that minor speed improvements aren't really that important. The main reason, imo, that you should use IF/ELSEIF/ELSE is just what you said... ease of understanding. If all you see are a lot of IFs, then you will have to go through and read every single one to figure out what needs done or not done. If you have IF followed by 6 ELSEIFs and then an ELSE at the end, you know automatically that you can ignore the rest if the first IF matches, or ignore everything after the first ELSEIF if that matches, and so on. ELSEIF isn't any more difficult to understand and it prevents you from having to TRY to understand it in the first place if you know that you already matched the IF or ELSEIF before it.

Trust me, you should always try to learn and use good and efficient programming/scripting methods at all times even if they are confusing to you when you're learning. Otherwise you get into bad habits that can make your scripts harder to understand and more prone to bugs and problems than you would otherwise have. That isn't to say that you need to do the most efficient method every time (ie. you don't have to use regex if you don't know how to if you can use another method instead). It does mean that if you know how to do something mroe efficiently and you're choosing not to just because you don't feel like it, *that* is when it's a bad idea.

Invision Support
#Invision on irc.irchighway.net