Sambar Server Documentation

CScript Variables


Important! In C, a variable must be declared before it can be used; in CScript, variable declarations are optional and always scope to the function block. While it is good practice to declare variables before their use, it is not required. A declaration begins with the type, followed by the name of one or more variables. For example,
int high, low, results[20];
Variables can also be initialised when they are declared, this is done by adding an equals sign and the required value after the declaration.
int high = 250;     /* Maximum Temperature */ int low = -40;     /* Minimum Temperature */ int results[20];     /* Series of temperature readings */
CScript provides a limited set of types (Imporant! Not all C types are supported):
intAn integer (char, short and long are mapped to this)
doubleA double precision floating point number (real and float are mapped to this)
char *An arbitrarily long character array
objectAn opaque object passed to and from an external interface (void * is mapped to this)
arrayAn arbitrary collection of types (dynamically grows, range checked)

Variable Names

Every variable has a name and a value. The name is used to identify the variable, the value is used to store data. There is a limitation on what these names can be. Every variable name in CScript must start with a letter, the rest of the name can consist of letters, numbers and underscore characters. CScript recognises upper and lower case characters as being different. Using FOOBAR for a variable name is not the same as using foobar, and neither of them is the same as using FooBar; all three refer to different variables. Finally, you cannot use any of C's keywords like main, while, switch, string, int etc as variable names.

The rules governing variable names also apply to the names of functions.

Keywords

There are several words defined as keywords in CScript. These have predefined uses and cannot be used for any other purpose in a CScript program. They are always written in lower case. A complete list follows:
break case catch char continue
default defined do double exit
else float for if int
long NULL return short sizeof
static switch throw try void
while

© 2001 Sambar Technologies. All rights reserved. Terms of Use.