04-29-2015 01:16 AM
Hi everibody
I am nephiew with labview and i am trying to use "to variant" block.
In the atteachment there is a picture of my VI.
Where am i wrong?!
Best regards
Giovanni
04-29-2015 02:01 AM
Are you trying to convert the string to number?. There is a direct function "decimal string to number"
04-29-2015 02:04 AM
muks is correct.
Furthermore you have connected the reference of the string and not its value.
04-29-2015 02:46 AM
You are right but the problem is more complex.
This is only a short vi.
I am communicating with a PLC and to do that i have used a .NET library.
The problem is that the library gives me some data from the plc in a To string variable. See the atteachment.
Trhough the variable datatype i select the corrisponding case. In the case of boolean is not a metter. In the case of an int16 i don't know how i can do. I would like to make a different thing for all type of variables...
is it clear?!
in the atteachment there is the vi and two screenshot of it.
04-29-2015 04:54 AM
You can't send a string value into a numeric control and expect it to understand the number. You need to convert the string into a number using the String to Number functions in the String palette.
04-29-2015 05:06 AM - edited 04-29-2015 05:07 AM
To expand on what RavensFan wrote, if you are setting the value of a generic control - LabVIEW doesn't know what the 'type' of the value should be at run-time so the node displays a variant which is the most generic data type that you can read/write. LabVIEW doesn't do any sort of conversion on the data contained in the variant so it has to match the appropriate format for the control that you're setting the value property of. Therefore, what you wire into the 'value' property has to match the data type (which you then convert to a variant) of the control/indicator.
04-29-2015 05:27 AM
Ok... but if i have to convert a structure that comes from To String variable?!?!?!?
How can i make?!??!?!
04-29-2015 05:53 AM
04-29-2015 06:47 AM
You are getting the data type. So your case structure is fine. I would add comments to the cases for what each representation means. But inside all you need to do for the I32 case is to just use Decimal String To Number and wire the output of that to your indicator.
04-29-2015 07:25 AM
I agree with you, infact i have used that block.
The problem is... When, instead of a bool or a number, i receive a structure... how can i make to manage it?!?!