06-02-2015 05:02 PM
I am trying to find a coding example of the overloads for the "CreateVariable" function in Measurement Studio. The goal is to define a variable type at creation time.
Thanks
06-03-2015 09:12 AM
Hi JohnnieM,
You can see the three overloads for the CreateVariable method in the help here: http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/3c1ef3de/. I couldn't find an example snippet of code but if you wanted to explicity define the type you need to use CreateVariable(VariableCreationOptions) like this:
string processName = "myProcess";
string variableName = "myVariable";
ServerProcessInfo procInfo = ServerProcess.Create(processName, true);
VariableCreationOptions varOptions = new VariableCreationOptions(processName, variableName);
varOptions.VariableType = typeof(Double); //this is where you specify the type
ServerVariableInfo varInfo = procInfo.CreateVariable(varOptions);
Hope this helps!
Kevin
06-03-2015 02:08 PM
This is close but when I try to assign the variable type the IDE won't allow the assignment. The message is that a type can not be used
06-04-2015 01:27 PM
I had tried out the code to make sure it worked so I think it should be fine. Can you post the line of code you are using to assign the type?
Thanks,
Kevin
06-11-2015 05:03 PM
Kevin,
I got the basics to work. The trick was in the way the variable name is required when you create the variable options object.
I can create variables with standard system variable types.
Is there a further trick to creating the NI specific array types?
THanks
06-12-2015 09:47 AM
Hi,
The list of types that this function can create are listed on the VariableType property help here: http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/393be5d5/ at the bottom of the page.
-Kevin