Does an If script always need an Else?

I'm more thinking of best coding practice here. I know it works, in Quest at least, without an else. I'm sure I saw Alex mention once that If scripts that didn't resolve with an else caused errors with questjs, although I could be remembering incorrectly.

I did a site search and can't find a reference to that. I would hope not, but perhaps you can email or PM Alex.

It's perhaps more likely that I've misread something. I thought he gave some reason behind the errors with questjs being something to do with If scripts. Anyway, I don't plan on using questjs, was just wondering.

A common error I've seen in questjs is where an "if" has no condition.

e.g.


if () {
// some code here
}


So... don't do that. I think it happens when people add an "if" in the editor and then forget to do anything with it.

Ah. Glad that got cleared up. I knew something had been mentioned but couldn't remember what.

I guess that means it doesn't flag up as an error in Quest.

Yep, Quest doesn't care, but JavaScript does. I suppose the converter should just remove an "if" with an empty condition. Who knows, maybe it already does - been a while since I last looked at it.

Alex wrote:Yep, Quest doesn't care, but JavaScript does. I suppose the converter should just remove an "if" with an empty condition. Who knows, maybe it already does - been a while since I last looked at it.


Given you're making Quest 6 use javascript as the internal language, I'm surprised you haven't experimented with using this to convert the internal aslx stuff. :P

(I'm pulling your leg, but it's a semi-serious proposition also.)

Although it works with .quest files not aslx ones, derr silly me.