Variable Functions
Functions:
MTK_BlockModel_GetDefaultNumber
int MTK_BlockModel_GetDefaultNumber( MTK_BlockModel* bmodel, const char *varName, double* value );
Description
Get default double value for variable specified.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
value
the number (double*)
Return Value
0
success
other
failure
MTK_BlockModel_GetDefaultString
int MTK_BlockModel_GetDefaultString( MTK_BlockModel* bmodel, const char *varName, char *value );
Description
Get default string value for variable specified.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
value
buffer of length MTK_BUFFER_SIZE to receive the string (char*)
Return Value
0
success
other
failure
MTK_BlockModel_GetNumber
int MTK_BlockModel_GetNumber( MTK_BlockModel* bmodel, const char* varName, double* value );
Description
Get double value for variable specified
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
value
the number (double*)
Return Value
0
success
other
failure
Example
// MTK_BlockModel_GetNumber Example
int main()
{
int status;
// Authorisation code
// Open a block model and get an MTK_BlockModel*
// Navigate to the desired block
double value;
status = MTK_BlockModel_GetNumber(bmodel, "someVariable", &value);
if (status)
{
char error[MTK_BUFFER_SIZE];
MTK_API_GetError(error);
printf("%s\n", error);
return 1;
}
// Do something with that value
// Close the block model
return 0;
}
MTK_BlockModel_GetNumericVariableName
int MTK_BlockModel_GetNumericVariableName( MTK_BlockModel* bmodel, const int& index, char* varName );
Description
Get a numeric variable name based on the index. Note that this does not include predefined variables
Parameters
bmodel
pointer to an MTK_BlockModel struct
index
the index of the variable to retrieve (int)
varName
buffer of length MTK_BUFFER_SIZE to receive the variable name (char*)
Return Value
0
success
other
failure
See Also
MTK_BlockModel_GetPredefinedVariableName
MTK_BlockModel_NPredefinedVariables
MTK_BlockModel_GetPredefinedVariableName
int MTK_BlockModel_GetPredefinedVariableName( MTK_BlockModel* bmodel, const int& index, char* varName );
Description
Get a predefined variable name based on the index.
Parameters
bmodel
pointer to an MTK_BlockModel struct
index
the index of the variable to retrieve (int)
varName
buffer of length MTK_BUFFER_SIZE to receive the variable name (char*)
Return Value
0
success
other
failure
MTK_BlockModel_GetString
int MTK_BlockModel_GetString( MTK_BlockModel* bmodel, const char* varName, char* value );
Description
Get string value for variable specified.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
value
buffer of length MTK_BUFFER_SIZE to receive the string (char*)
Return Value
0
success
other
failure
MTK_BlockModel_GetStringVariableName
int MTK_BlockModel_GetStringVariableName( MTK_BlockModel* bmodel, const int& index, char* varName );
Description
Get a string variable name based on the index. Note that this does not include predefined variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
index
the index of the variable to retrieve (int)
varName
buffer of length MTK_BUFFER_SIZE to receive the variable name (char*)
Return Value
0
success
other
failure
See Also
MTK_BlockModel_GetPredefinedVariableName
MTK_BlockModel_NPredefinedVariables
MTK_BlockModel_GetTranslationName
int MTK_BlockModel_GetTranslationName( MTK_BlockModel* bmodel, const char* varName, const int& index, char* translation );
Description
Get a translation name based on the variable and index.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
string variable name (const char*)
index
the index of the translation to retrieve (int)
translation
buffer of length MTK_BUFFER_SIZE to receive the translation name (char*)
Return Value
0
success
other
failure
MTK_BlockModel_GetVariableDescription
int MTK_BlockModel_GetVariableDescription( MTK_BlockModel* bmodel, const char* varName, char* description );
Description
Get the description of a variable.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
string variable name (const char*)
description
buffer of length MTK_BUFFER_SIZE to receive the description (char*)
Return Value
0
success
other
failure
MTK_BlockModel_GetVariableName
int MTK_BlockModel_GetVariableName( MTK_BlockModel* bmodel, const int& index, char* varName );
Description
Get a variable name based on the index. Note that this does not include predefined variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
index
the index of the variable to retrieve (int)
varName
buffer of length MTK_BUFFER_SIZE to receive the variable name (char*)
Return Value
0
success
other
failure
See Also
MTK_BlockModel_GetPredefinedVariableName
MTK_BlockModel_NPredefinedVariables
MTK_BlockModel_GetVariableType
int MTK_BlockModel_GetVariableType( MTK_BlockModel* bmodel, const char* varName, MTK_BlockModel_VariableType *type );
Description
Test the variable type.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
type
variable type (MTK_BlockModel_VariableType*) (see below)
Return Value
0
success
other
failure
enum MTK_BlockModel_VariableType
{
BM_VAR_UNKNOWN,
BM_VAR_BIT,
BM_VAR_BYTE,
BM_VAR_INT16,
BM_VAR_UINT16,
BM_VAR_INT32,
BM_VAR_INT64,
BM_VAR_FLOAT,
BM_VAR_DOUBLE,
BM_VAR_STRING
};
MTK_BlockModel_IsNumber
int MTK_BlockModel_IsNumber(MTK_BlockModel* bmodel, const char* varName);
Description
Check if variable is numeric.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
Return Value
1
it is numeric
0
it is not numeric
-1
failed
MTK_BlockModel_IsString
int MTK_BlockModel_IsString(MTK_BlockModel* bmodel, const char* varName);
Description
Check if variable is string.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
Return Value
1
it is a string
0
it is not a string
-1
failed
MTK_BlockModel_NClassificationVariables
int MTK_BlockModel_NClassificationVariables(MTK_BlockModel* bmodel);
Description
Gets the number of 'classification' variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
Return Value
int
number of 'classification' blockmodel variables
-1
failed
MTK_BlockModel_NNumericVariables
int MTK_BlockModel_NNumericVariables(MTK_BlockModel* bmodel);
Description
Retrieves the number of numeric variables. Note that this does not include predefined variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
Return Value
int
the number of numeric blockmodel variables
-1
failed
See Also
MTK_BlockModel_GetPredefinedVariableName
MTK_BlockModel_NPredefinedVariables
MTK_BlockModel_NPredefinedVariables
int MTK_BlockModel_NPredefinedVariables(MTK_BlockModel* bmodel);
Description
Retrieves the number of predefined variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
Return Value
int
number of predefined blockmodel variables
-1
failed
MTK_BlockModel_NStringVariables
int MTK_BlockModel_NStringVariables(MTK_BlockModel* bmodel);
Description
Retrieves the number of string variables. Note that this does not include predefined variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
Return Value
int
the number of string/character blockmodel variables
-1
failed
See Also
MTK_BlockModel_GetPredefinedVariableName
MTK_BlockModel_NPredefinedVariables
MTK_BlockModel_NTranslations
int MTK_BlockModel_NTranslations(MTK_BlockModel* bmodel, const char* varName);
Description
Get the number of translations for a string variable.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
Return Value
int
number of translations for the variable
-1
failed
MTK_BlockModel_NVariables
int MTK_BlockModel_NVariables(MTK_BlockModel* bmodel);
Description
Retrieves the number of variables. Note that this does not include predefined variables.
Parameters
bmodel
pointer to an MTK_BlockModel struct
Return Value
int
the number of blockmodel variables
-1
failed
See Also
MTK_BlockModel_GetPredefinedVariableName
MTK_BlockModel_NPredefinedVariables
MTK_BlockModel_SetNumber
int MTK_BlockModel_SetNumber( MTK_BlockModel* bmodel, const char* varName, const double& value );
Description
Set double value for variable specified.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
value
the number (double)
Return Value
0
success
other
failure
MTK_BlockModel_SetString
int MTK_BlockModel_SetString( MTK_BlockModel* bmodel, const char* varName, const char* value );
Description
Set string value for variable specified.
Parameters
bmodel
pointer to an MTK_BlockModel struct
varName
variable name (const char*)
value
the string (const char*)
Return Value
0
success
other
failure