Variable Definitions

The general syntax of a variable definition is
[numeric] type identifier [= initializer][, ...];
where type is one of the data or object types, identifier is the name of the variable, and initializer is a optional initial value.

Multiple variable definitions of the same type are separated by commas (,).

If identifier is followed by a pair of brackets ([]), this defines an array of variables of the given type. The size of an array is automatically adjusted at runtime.

The optional keyword numeric can be used with string arrays to have them sorted alphanumerically by the sort() function.

By default (if no initializer is present), data variables are set to 0 (or "", in case of a string), and object variables are "invalid".


int i; defines an int variable named i
string s = "Hello"; defines a string variable named s and initializes it to "Hello"
real a, b = 1.0, c; defines three real variables named a, b and c, initializing b to the value 1.0
int n[] = { 1, 2, 3 }; defines an array of int, initializing the first three elements to 1, 2 and 3
numeric string names[]; defines a string array that can be sorted alphanumerically
UL_WIRE w; defines a UL_WIRE object named w
The members of array elements of objekt types can't be accessed directly:

UL_SIGNAL signals[];
UL_SIGNAL s = signals[0];
printf("%s", s.name);

Index Copyright © 2005 CadSoft Computer GmbH