current stable:
cvs (0.99.7)
  Home / News
  The Team

  Source Tarball
  CVS Web View
  Misc. Files

The Manual
  Download [html]
  Download [pdf]
  View Online
  Download [html]
  View Online
  Script Examples

Developer Guide
  Download [html]
  Download [pdf]
  View Online
Ferite C API
  Download [html]
  View Online

Open Source Approved

SourceForge Logo - browse the Keyword Map of

[previous] Types[up][toc]Expressions [next]


Variables are simply instances of types and can be declared within a initializer and with other variables using the following syntax:
    modifier type name [= <expression>] [, ...] ;

  • modifier

    This is used to define properties of a variable. Current properties are: final and this sets, whether or not after a variables first assignment, whether the variable is constant and therefore can't be changed. This is the same behavior shown by the final keyword within Java. static, which tells ferite whether or not the variable is tied to a class or object (discussed later on). And atomic which tells ferite to guarantee that all operations on the variable are atomic (and therefore threadsafe). It is up to the programmer to tell ferite this because atomic variables have an added overhead which is simply not necessary for 99% of program code.

  • type

    This is the type of variable that you wish to declare. It can be void, number, string, array or object.

  • name

    The name of the variable to be declared. The name must start with a alpha character or underscore and after that may contain underscores _, numbers [0-9] and other alpha characters.

  • [= <expression>]

    Variables can be declared with a non-default value rather than the internal defaults. (number = 0, string = "", object = null). It is recommended that you make sure that your variables are initialised before you use them purely to make the programs behavior more understandable.

    Please Note!

    When it is declared within a function you can specify any valid expression to be used as the variable's initialiser - eg. a return from a function, the adition of two previously declared variables. When the variable is declared globally, in a class or a namespace you can only use a simple initialiser by this I mean you can only initialise a number with a integer or real number (eg. 120 or 1.20), and a string with a double or single quoted string. It is not possible to initialise an array or object in a namespace, global, or class block - these will have to be done using a function.

  • [, ...]

    Rather than having to declare modifiers and type again for a set of variables it is possible to simply add more names in a comma seperated list. Please see below for an example.

  • [;]

    This terminates the statement.


    number mynumber = 10, another_number;
    final string str = "Hello World";
    object newObj = null;
    array myarray;

A variable's scope is as local as the function they are declared in with the exception of explicit global variables. This means that a variable declared in function X can only be accessed within function X. Global variables can be accessed anywhere within a script, and are declared using the following syntax:

    global {
    	<variable declarations>

Unless explicitly defined a variable is considered local. There are a number of predefined global variables within a ferite script, these are null and err. null is used to allow checking of objects and instantiating, and err is the error object used for exception handling.

[previous] Types[up][toc]Expressions [next]
ferite et al © 2000-2004, Chris Ross