Variable Functions

Function to access, query, and modify block model variables, including numeric and string types, defaults, descriptions, translations, and counts.

MTK_BlockModel_GetDefaultNumber()

Get default double value for variable specified.

Signature
int MTK_BlockModel_GetDefaultNumber(
    MTK_BlockModel* bmodel,
    const char *varName, double* value
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The variable name.

  • value: The default value of the variable.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetDefaultString()

Get default string value for variable specified.

Signature
int MTK_BlockModel_GetDefaultString(
    MTK_BlockModel* bmodel,
    const char *varName, char *value
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The variable name.

  • value Buffer of length MTK_BUFFER_SIZE to receive the string.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetNumber()

Get double value for variable specified

Signature
int MTK_BlockModel_GetNumber(
    MTK_BlockModel* bmodel,
    const char* varName, double* value
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The variable name.

  • value: The value of the variable.

Returns

0 on success; any other value indicates 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()

Get a numeric variable name based on the index. Note that this does not include predefined variables.

Signature
int MTK_BlockModel_GetNumericVariableName(
    MTK_BlockModel* bmodel,
    const int& index,
    char* varName
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • index: The index of the variable to retrieve.

  • varName: Buffer of length MTK_BUFFER_SIZE to receive the variable name.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetPredefinedVariableName()

Get a predefined variable name based on the index.

Signature
int MTK_BlockModel_GetPredefinedVariableName(
    MTK_BlockModel* bmodel,
    const int& index,
    char* varName
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • index: The index of the variable to retrieve.

  • varName: Buffer of length MTK_BUFFER_SIZE to receive the variable name.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetString()

Get string value for variable specified.

Signature
int MTK_BlockModel_GetString(
    MTK_BlockModel* bmodel,
    const char* varName, char* value
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

  • value: Buffer of length MTK_BUFFER_SIZE to receive the variable value.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetStringVariableName()

Get a string variable name based on the index. Note that this does not include predefined variables.

Signature
int MTK_BlockModel_GetStringVariableName(
    MTK_BlockModel* bmodel,
    const int& index,
    char* varName
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • index: The index of the variable to retrieve.

  • varName: Buffer of length MTK_BUFFER_SIZE to receive the variable name.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetTranslationName()

Get a translation name based on the variable and index.

Signature
int MTK_BlockModel_GetTranslationName(
    MTK_BlockModel* bmodel,
    const char* varName, const int& index,
    char* translation
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: String variable name.

  • index: The index of the translation to retrieve

  • translation: Buffer of length MTK_BUFFER_SIZE to receive the translation name

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetVariableDescription()

Get the description of a variable.

Signature
int MTK_BlockModel_GetVariableDescription(
    MTK_BlockModel* bmodel,
    const char* varName,
    char* description
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: String variable name.

  • description: Buffer of length MTK_BUFFER_SIZE to receive the description.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetVariableName()

Get a variable name based on the index. Note that this does not include predefined variables.

Signature
int MTK_BlockModel_GetVariableName(
    MTK_BlockModel* bmodel,
    const int& index, char* varName
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • index: The index of the variable to retrieve

  • varName: Buffer of length MTK_BUFFER_SIZE to receive the variable name.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_GetVariableType()

Test the variable type.

Signature
int MTK_BlockModel_GetVariableType(
    MTK_BlockModel* bmodel,
    const char* varName,
    MTK_BlockModel_VariableType *type
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

  • type: The variable type, one of the following enum values:

    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
    };
Returns

0 on success; any other value indicates failure.

MTK_BlockModel_IsNumber()

Check if a variable is numeric.

Signature
int MTK_BlockModel_IsNumber(MTK_BlockModel* bmodel, const char* varName);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

Returns
  • 1: The variable is numeric.
  • 0: The variable is not numeric.
  • -1: Failure.

MTK_BlockModel_IsString()

Check if a variable is a string.

Signature
int MTK_BlockModel_IsString(MTK_BlockModel* bmodel, const char* varName);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

Returns
  • 1: The variable is a string.
  • 0: The variable is not a string.
  • -1: Failure.

MTK_BlockModel_NClassificationVariables()

Gets the number of 'classification' variables.

Signature
int MTK_BlockModel_NClassificationVariables(MTK_BlockModel* bmodel);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

Returns
  • int: Thenumber of 'classification' block model variables.
  • -1: Failure.

MTK_BlockModel_NNumericVariables()

Retrieves the number of numeric variables. Note that this does not include predefined variables.

Signature
int MTK_BlockModel_NNumericVariables(MTK_BlockModel* bmodel);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

Returns
  • int: The number of numeric block model variables.
  • -1: Failure.

MTK_BlockModel_NPredefinedVariables()

Retrieves the number of predefined variables.

Signature
int MTK_BlockModel_NPredefinedVariables(MTK_BlockModel* bmodel);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

Returns
  • int: The number of predefined block model variables.
  • -1: Failure.

MTK_BlockModel_NStringVariables()

Retrieves the number of string variables. Note that this does not include predefined variables.

Signature
int MTK_BlockModel_NStringVariables(MTK_BlockModel* bmodel);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

Returns
  • int: The number of string/character block model variables
  • -1: Failure.

MTK_BlockModel_NTranslations()

Get the number of translations for a string variable.

Signature
int MTK_BlockModel_NTranslations(
    MTK_BlockModel* bmodel, const char* varName);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

Returns
  • int: The number of translations for the variable.
  • -1: Failure.

MTK_BlockModel_NVariables()

Retrieves the number of variables. Note that this does not include predefined variables.

Signature
int MTK_BlockModel_NVariables(MTK_BlockModel* bmodel);
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

Returns
  • int: The number of block model variables.
  • -1: Failure.

MTK_BlockModel_SetNumber()

Set double value for variable specified.

Signature
int MTK_BlockModel_SetNumber(
    MTK_BlockModel* bmodel,
    const char* varName, const double& value
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

  • value: The value to set the variable to.

Returns

0 on success; any other value indicates failure.

MTK_BlockModel_SetString()

Set string value for variable specified.

Signature
int MTK_BlockModel_SetString(
    MTK_BlockModel* bmodel,
    const char* varName, const char* value
    );
Parameters
  • bmodel: Pointer to an MTK_BlockModel struct.

  • varName: The name of the variable.

  • value: The string value to set the variable to.

Returns

0 on success; any other value indicates failure.