LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create an array Station Globals programmatically in CVI?

Hello all,

I want to create an array Station Globals programmatically in CVI. Where can I find some examples?

Thanks,
Zhonghui Ning
0 Kudos
Message 1 of 4
(3,555 Views)
Zhonghui,

There is a KnowledgeBase on our website that describes the methods needed to do this. You can find the KnowledgeBase at http://digital.ni.com/public.nsf/websearch/C7C81F4AE5A46BB686256CDA005FA4C6?OpenDocument.

I found this by searching for "teststand create variable". You can find TestStand examples on our Developer Library by going to http://www.ni.com/devzone and clicking on the link for Developer Library. This page has example code as well as tutorials and application notes on many aspects of TestStand. There are quite a few examples there that already address this type of question: Creating Sequence File Global Variables Using the TestStand API with LabWindows/CVI

and Creating and Inserting a New Data Type into a Sequence File using LabWindows/CVI
.

We continually add examples to these web pages, so it is always a good place to look for examples. While they may not have the exact answer to your questions, the examples usually cover a topic that is close enough for you to be able to apply the example to your question.

Hope that helps.
Regards,
Shannon R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,555 Views)
Hello Shannon,

Thanks for your help. TS_PropertyNewSubProperty() can work in my project. It can successfully create an teststand dynamic array by the following first statment.

TS_PropertyNewSubProperty (myglobals, NULL, "Array", TS_PropValType_String, VTRUE, "", 0);

TS_PropertySetValStringByOffset (myglobals, NULL, 0, 0, newValue);

I want to assign newValue to the first element of the StationGlobals Array by the above second statement. It doesn't work.

Do you have any example about assigning values to a teststand array programmatically? If there are no extra website for assigning values to a teststand array, I will continue to study the website you have told me.

Thanks,
Zhonghui
0 Kudos
Message 3 of 4
(3,555 Views)

Just for future reference.

You can do this:

 

// create the global if it does not exist

tsErrChk(TS_PropertyNewSubProperty (TS_Globals, NULL, "globalname", TS_PropValType_Number, VTRUE, "", 0));
// get a property object reference to the new global that was created
tsErrChk(TS_PropertyGetPropertyObject (TS_Globals, NULL, "globalname, 0, &MyGlobal));

// Set the size of the array
tsErrChk(TS_PropertySetNumElements (MyGlobal, NULL, numElements, 0));
 // set a value
tsErrChk(TS_PropertySetValNumber(TS_Globals, &errorInfo, "globalname[0]", 0, 2));

CA_DiscardObjHandle(MyGlobal);
//Release Object
CA_DiscardObjHandle(TS_Globals);

 

To copy a full array over use the following example:

C:\Users\Public\Documents\National Instruments\TestStand 2010 SP1\Examples\AccessingArraysUsingAPI\UsingCVI

Jacob R. | Applications Engineer | National Instruments

0 Kudos
Message 4 of 4
(2,977 Views)