Table of Contents
var_GetValueDescriptionRetrieve the value of a variable. Function prototypebool CExtAPI::var_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 var_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 var_GetValueEx function, which includes a test of the variable type. Incompatible typesThe following variable types are not compatible with var_GetValue (and var_SetValue, var_GetValueEx and var_SetValueEx):
Example// get a variable called 'radius' ZVAR hVar = theAPI.var_GetVar("radius"); // check it is the correct type (a double, in this example) if(!theAPI.var_IsType(hVar, VarID_double)) { ReportError("Incorrect variable type!"); return false; } // get the value using var_GetValue double radius; if(!theAPI.var_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
|