Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find an example of teh overload functions for the "Createvariable"

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

 

0 Kudos
Message 1 of 6
(5,203 Views)

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

0 Kudos
Message 2 of 6
(5,190 Views)

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

0 Kudos
Message 3 of 6
(5,186 Views)

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

0 Kudos
Message 4 of 6
(5,170 Views)

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

 

 

0 Kudos
Message 5 of 6
(5,101 Views)

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

0 Kudos
Message 6 of 6
(5,092 Views)