Table of Contents
zvar_GetValueDescriptionRetrieve the value of a variable. Files
Function prototypebool zvar_GetValue(ZVAR hVar, void* pValue); Arguments
Return valueFalse if:
True otherwise. CommentsCheck the variable type, or use var_GetValueExBefore retrieving the value of a variable it is strongly recommended that you check the type using zvar_IsType (see example below.) This is to ensure that the variable type is what you think it is, so that your pValue handle is the correct storage type. If, for instance, you don't check the variable type and provide a pValue handle to a char data type (1 byte) when the variable is actually a long (4 bytes), you will have corrupted memory somewhere and the world may end. Alternatively, you can use the zvar_GetValueEx function, which includes a test of the variable type. Incompatible types
The following variable types are not compatible with
Example// get a variable called 'radius' ZVAR hVar = zvar_GetSharedVar("radius"); // check it is the correct type (a double, in this example) if(!zvar_IsType(hVar, VarID_double)) { zeoReportError("Incorrect variable type!"); return false; } // get the value using zvar_GetValue double radius; if(!zvar_GetValue(hVar, &radius)) { ReportError("Cannot retrieve variable data!"); return false; } // now use radius for something... Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|