====== zvar_Create ======
===== Description =====
Create a variable.
===== Files =====
^ Declaration | ''Zeolite.h'' |
^ Implementation | ''Zeolite.cpp'' |
===== Function prototype =====
ZVAR zvar_Create(long VarID);
===== Arguments =====
^ Name ^ Type ^ Comment ^
| VarID | long | The [[zeolite:VarID|type ID]] of the variable to be created. |
===== Return value =====
Null if an error occurred, and a non-nullZVAR handle otherwise.
===== Comments =====
==== Garbage collection ====
ZVARs never go 'out of scope', so your plugin is responsible for deleting variables when they are no longer needed using the [[zeolite:functions:zvar_Delete]] function. If your plugin doesn't delete its variables, L3DT will do the garbage collection when it closes, and it may mock you for not cleaning up after yourself.
To restore normal scoping rules, use the C++ wrapper classes ([[zeolite:classes:CzVar]], [[zeolite:classes:CzStr]], [[zeolite:classes:CzMap]], etc.). These classes automatically delete their variable handles when going out of scope, so you don't have to.
==== Variable size ====
A variable created with ''zvar_Create'' occupies more memory than using, say, the //new// operator in C++. This is because the ZVAR structure stores, in addition to the data, such things as the variable type and name string. Thus, if you wish to create a large array of variables (e.g. a million floats) you should not use [[zeolite:functions:zvar_Create]], [[zeolite:functions:zvar_CreateShared]] or [[zeolite:functions:zlist_CreateItem]] for each item in the array, but instead use the provided buffer functions (''zbuffer_xxx''), which store the data in an array without decoration.