Scripting Language FAQ (SEV)

From SEWiki
Jump to: navigation, search

This article contains various frequently asked questions about the language used for AI and script editing in SE5.

Logic Statements

Do conditional operators (and, or) short-circuit?

All portions of a conditional statement are evaluated; the language does not support short-circuiting.

Is AND higher precedence than OR?

No. These operators are of the same precedence and parsed in strict left-to-right fashion.

Control Flow Statements

Can you have multiple exit when clauses in a loop?


"Exitwhen" statements cause an immediate exit from the loop. This is in stark contrast to the strange way "return" statements work. For example, the following code will result in myval being 1:

   set myval := 1
   exitwhen true
   set myval := 2

Any problems with not covering all the cases in a case statement? Is there even a default mechanism?

No. Uncovered cases do nothing. There is apparently no default case.


Is there implicit type conversion from long to real? real to long?

The language uses strong typing.

Implicit upconversion from long to real will happen in an expression but not an assignment.

This will work:

 set myreal := mylong * 1.0

This will not work:

 set myreal := mylong

Real to long conversion must be explicit via Sys_Trunc(), Sys_Round(), etc.


Can you use a return statement to exit a function early?

No. Unlike most languages, return does not actually return from a function call. All that it does is set a value to be returned when the function's end statement is reached.

Must locally declared lists be cleared prior to function exit?

No, at least the default SE5 scripts don't.

Am I just missing it, or is Sys_Iifreal the only default trigraph function?

That appears to be the only one.

Is there some purpose I'm not seeing to the various operator simulating functions (Sys_Long_Add and such)?

No known reason.