next_inactive up previous contents
Up: HAFA Overlord Language Definition Previous: 2 Defining the System   Contents

Subsections

3 Scripting Commands

Often, you will need to specify to the overlord how to check a particular condition, or what to do when something fails. This is done using Overlord script.

All Overlord script statements end with semicolons.

3.1 Nebuloids

Nebuloids can be accessed from Overlord script in three ways: as part of an expression, as a statement on its own, or as having a value assigned to it.

To assign a value to a nebuloid, you simply use the assignment operator:

nebuloid = expression;
Where nebuloid is the name of the nebuloid you are assigning to, and expression is a mathematical expression (explained in Section 3.4).

To read a value from a nebuloid, either to use its value in an expression, or to perform a function (depending on the function of the module), you would use the following form:

nebuloid [(argument1[, argument2[, ...]])];

Where nebuloid is, rather obviously, the name of the nebuloid you wish to access, and the arguments are the various arguments passed to that nebuloid when it is accessed. For more information about what arguments should be passed to various nebuloids, please refer to the Nebuloid Type Reference.

It should also be noted that if the module does not require arguments to be accessed, the brackets around the argument list are unnecessary. This is for convenience, so that the code

...
VAR tmp (0)
PROC inctmp
{
  tmp = tmp + 1;
}
...

works as expected.

In addition, if no arguments are required for their instantiation, and no context is required to be kept between accesses, some nebuloids can be implicitly instantiated. The KILL module is a good example of this. To implicity instantiate a nebuloid, declare the module at the beginning of the script, then simply use the module name instead of an instantiated nebuloid's name when accessing the nebuloid. For example:

KILL ("SIGTERM", process3);

3.2 Procs

To call a proc from script code, simply use its name. Since procs must return true or false, these can be used in expressions. Note that you may only call procs which are local to your current process, or global to the entire system.

3.3 Processes

In the START condition of a process, there needs to be a way to specify to the Overlord what the pid of the newly-started process is. The Overlord language solves this by allowing process names to behave as variables which contain the pid of that process. This means you could have a system which looked something like this:

SYSTEM: process1
{
  PROCESS process1 100: process2
  {
    START { process1 = EXEC ("/bin/process1"); }
    DEPENDFAIL 
    { // If process2 fails, kill off process1 and restart it.
      KILL ("SIGTERM", process1);
    }
    ...
  }
  ...
}

Magic!


3.4 Expressions

Mathematical expressions work like in C, except there's no ``!'' operator. If we magically decide we need a ``!'' operator, it'd be pretty trivial to implement a ``!'' operator. Also, an assignment statement doesn't count as an expression, so no var1 = var2 = 5; or funny business like that.

3.5 IF

The IF statement is really simple, it works as follows:

IF (expression)
  code
[ELSE code]
ENDIF;

expression, of course, is a mathematical expression, zero being false and nonzero being true. The blocks of code can be as long as you feel like making them. And due to the clever use of ENDIF, no dangling ELSE problems! Pretty straightforward.

Note that the IF statement, while containing blocks of other statements, is still considered a statement, so ENDIF is immediately followed by a semicolon.

3.6 RETURN

Procs n' such must return true or false. This is done through the use of the following commands:

RETURN TRUE;
Returns a ``true'' value.
RETURN FALSE;
Returns a ``false'' value.

If no return statement is given for the proc, the proc by default returns true.

3.7 Comments

The Overlord languages uses C++-style comments; that is, everything until the end of line after ``//'' is ignored by the overlord compiler.


next_inactive up previous contents
Up: HAFA Overlord Language Definition Previous: 2 Defining the System   Contents
2003-01-03