lite-C Variables

Fundamental Variable Types
Defining a Variable
typedef
Struct
Pointer
Array
define

Naming convention

(Items marked with  l  are lite-C specific only, and not supported in standard C/C++.)

Fundamental Variable Types

Type Size Values
var  l  4 bytes -999999.999 to 999999.999
long, int 4 bytes -2,147,483,648 to 2,147,483,647
char 1 byte 256 character values
short 2 byte -32768 to 32767
float 4 bytes 1.2e-38 to 3.4e38
double 8 bytes 2.2e-308 to 1.8e308

The var variable is unique to lite-C and makes programming easy for beginners. It can serve as a floating point or integer variable or as a pointer or handle.

Defining a Variable

Syntax:
Type_specifier identifier;

Example:
int x;

typedef

Syntax:
typedef Type_specifier identifier;
Example:
typedef long DWORD;

Pointer

Syntax:
Type_specifier *identifier;
Type_specifier* identifier;

Example:
int *p;

Struct

Syntax:
struct [tag] { member-list } [declarators];
struct tag declarators;

Example:

struct SPOT_S
{
    int x;
    int y;
} SPOT; 

 l  Struct pointers can be initialized with a static struct with default values for members. Syntax:
Struct_specifier *identifier = { member = value; [...] }

Example:
SPOT *myspot = { x = 1; y = 2; }

 l  Members of both structs and struct pointers are accessed by the struct_identifier.member syntax in the lite-C code. The compiler automatically detects whether it's a struct or a struct pointer. In standard C, members of structs are accessed by struct_identifier.member and members of struct pointers are accessed by struct_identifier->member. lite-C supports both the standard C and the lite-C syntax.

Example:
myspot->x = 1; // standard C
myspot.y = 2; // lite-C

Multidimensional Array

Syntax:
Type_specifier identifier[n][[n]..];

Example:
int p[10][20];

#define

Syntax:
#define name [value]
#define macro(variables) expression(variables)

Example:
#define NULL 0
#define USE_DIRECTX
#define WINAPI __stdcall
#define SUM(a,b) (a+b)

Naming Convention

Names are case sensitive. For making your code easier to read, we recommend a convention for naming variables. We're writing #defines in UPPERCASE, local variables as well as engine and template variables in lowercase with underscore (my_variable) and global variables with a type prefix and Mixed Case (vMyVariable). We're using the following type prefixes:

Type Prefix Example
var v vMyVariable
long, int i iMyInteger
char c cMyChar
short sh shMyShort
float f fMyFloat
double d dMyDouble
VECTOR vec vecVelocity
COLOR col colLight
STRING* s sMyString
BMAP* b bMyBmap
SOUND* w wMySound
PANEL* p pMyPanel
TEXT* t tMyText
ENTITY* e eMyEntity

If you are using several code modules in your script, add a module prefix to your variables and functions. In the default.c module we've prefixed all variables with 'def_'.