LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I retrieve the strings from an ActiveX text ring?

Greetings,

I am attempting to use an ActiveX component which returns several values per method, and has a large number of methods. The desired implementation would be to have a single case per method, and return these results to generic indicators outside of the case.

In some cases, when I right-click the output element for a I32 value and select create indicator, it generates a wonderful text ring, complete with string descriptions.

I wish to retrieve these string descriptions, and display them with a string indicator outside of the case structure without the necessity of creating an indicator for each element--this would make a monstrous front panel considering the number of methods.

How can I achi
eve this?
0 Kudos
Message 1 of 10
(3,825 Views)
Create a property node for that indicator and choose the "Strings[]" property. This would return the array of strings contained within that text ring. Now use the "Index array" function to index out the desired element from this array using the output of the ActiveX method(i.e., the I32 value).
0 Kudos
Message 2 of 10
(3,825 Views)
As I mentioned, the intent is to avoid creating an indicator... hence, I cannot use the Strings[] property.

Another alternative (should I wish to create an indicator) would be to use the Ringtext.text property of that ringtext indicator, and send this to a string indicator.

With an enum return, it is possible to cast the enum to a variant, using the enum constant created from the COM function as the type, and then to display the text using a variant. Unfortunately, this method does not work when using the ring data type.

I have attached an example to demonstrate this.

Greg
0 Kudos
Message 3 of 10
(3,825 Views)
Greg,
I have read and reread your post and I am still unclear what you want to do. I suspect that you want a universal indicator so that no matter what you pass to it, it can display the data. The only thing LabVIEW offers like this is a string because you can convert numbers, booleans, any data into a string. It is not pretty or easy, but it will do the job.
0 Kudos
Message 4 of 10
(3,825 Views)
This is exactly what I wish to do.

The issue is that the data from the text ring is represented by an integer value, so displaying this to a string will merely display the integer (once converted).

When an indicator is created, it creates a text ring which includes a description for each possible integer value being returned. If I could create a function to return the strings[] property WITHOUT first making an indicator, then I could display the information to a generic or "universal" indicator.

This can be done easily with an enum as demonstrated in the example vi on my previous posting, but is elusive in the case of a text ring, which is also demonstrated in the example.

Greg
0 Kudos
Message 5 of 10
(3,825 Views)
There is a fundamental difference between a ring and an enum.
In a ring, the Strings[] property belongs to the control itself and then exists only if the is a control/constant to hold them. The control maps the strings to the integer value. These strings can be modified programmatically. In LabVIEW only the integer value flows through the wire, not the string value.

On the other hand, for an enum, the Strings[] are part of the enum datatype itself and flows in the wire along with the value. The strings exist even if there is no enum control to hold them e.g. an ActiveX output that is a variant enum can be displayed in a variant indicator with its string value.

That is why you need an indicator to read Strings[] fro
m a ring but you can display the string value of an enum without the enum being in an indicator. The variant indicator can show the string value of the enum because it is part of the datatype.

To come back to your problem, when ring constants are created from the ActiveX node, there is no way you can recover the string value. It can be recovered if you create an indicator from the ActiveX node. When LabVIEW creates the ring, I think it seeks the string information in the input/output definitions of the ActiveX object but it is not directly available for you on the diagram if you didn't create a control first.


LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 10
(3,826 Views)
Jean-Pierre,

I have resorted to creating a plethora of pop-up sub-vi's to reduce the number of indicators on my main vi's front panel. I can then use these indicators to display (and/or capture) the string properties from the various ring indicators.

Thank-you very much for the answer!
0 Kudos
Message 7 of 10
(3,827 Views)

Do I understand you correctly: there is no way that the string value of a ring constant can be programmatically retrieved (and used as a string in the program)?

Btw, is there any good explanations anywhere for how to  program constants etc in LabVIEW that are to be used throughout the program, and need to be altered at a central location? Possible problems occur for instance when comparing a value to another, and then you would like to change both these values.I have used some typedefs, but it doesn't always work out as intended :~\

0 Kudos
Message 8 of 10
(3,554 Views)

@Rodnebb wrote:

Do I understand you correctly: there is no way that the string value of a ring constant can be programmatically retrieved (and used as a string in the program)?

Btw, is there any good explanations anywhere for how to  program constants etc in LabVIEW that are to be used throughout the program, and need to be altered at a central location? Possible problems occur for instance when comparing a value to another, and then you would like to change both these values.I have used some typedefs, but it doesn't always work out as intended :~\




You cannot access the strings of a constant because of the nature of a constant.  It does not have accessible properties or methods.

Instead of placing many constants on the block diagram, why not use a control or indicator?  If cluttering the front panel is a problem, note that you can hide controls and indicators by right clicking on them in the block diagram and selecting "Hide Control/Indicator."  To update values later in your block diagram, use a local variable.

If you are distributing applications, the shared variable engine may be useful.

http://zone.ni.com/devzone/cda/tut/p/id/4679
0 Kudos
Message 9 of 10
(3,533 Views)


@Rodnebb wrote:

Do I understand you correctly: there is no way that the string value of a ring constant can be programmatically retrieved (and used as a string in the program)?

Btw, is there any good explanations anywhere for how to  program constants etc in LabVIEW that are to be used throughout the program, and need to be altered at a central location? Possible problems occur for instance when comparing a value to another, and then you would like to change both these values.I have used some typedefs, but it doesn't always work out as intended :~\




Take a look at this community nugget which describes different techniques for creating global constants.
0 Kudos
Message 10 of 10
(3,515 Views)