Work with user variables
In addition to the variables provided by KINGSTAR, you can create your own variables, record them into a log, or display them in KINGSTAR Analysis Console to track their changes. In this section, you'll learn how to create user variables and set their attributes.
Functions
AddVariable: adds a user-defined variable.
GetVariable: gets the details of a user-defined variable. It is called when an application or function wants to use the user variables added by another program.
GetVariables: gets the list of user-defined variables.
RemoveVariable: removes a user-defined variable.
Code
We break the steps down into a few parts so you can easily learn how each function works.
Before we start, in Log.cpp
, add the following preprocessor directives and function. We include the header wchar.h
because wide characters will be used; using namespace std
is for strings use. We are writing code in the CreateUserVariables function. The first line of code, RtPrintf("Work with user variables.\n\n");
, displays the message that describes what this function is going to do.
NOTE: Some header files overlaps with others in different sections.
#include "RT_Project_01.h"
#include <wchar.h>
using namespace std;
int CreateUserVariables()
{
RtPrintf("Work with user variables.\n\n");
return 0;
}