LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing string data problem

Dear readers,
I came across some problem in my labview VI where I try to pass a string (stored in a local variable) to other string variables connected to that local variable. In this case, I have a local string variable called 'output_string1', which contains the string '123'. I have it set to 'write'. Then I connect 3 string Indicators to this local variable, called 'string1', 'string2', and 'string3'. I would expect these connected string indicators to also contain the string '123', as they're simply connected to the 'output_string1'. But the strange thing is that only 'string2', and 'string3' contains '123', but 'string1' contains a '.' (ie a dot). Would someone be able to provide some kind advice about what I might be doing wro
ng to get this result? I've attached the vi that I was making that demonstrates what I described. Thank you very much for your help.
0 Kudos
Message 1 of 3
(2,672 Views)
In the last sequence you have intended to concatinate a string from three inputs; the local variable before, a "." and a local of string1. BUT instead of reading the local of string1 you have it in write mode...and the "." is wired into it! So you really wire 123 to that indicator as well in sequence 5, but it is immediately overwritten by a "." in the next sequence.

That aside though there's two other things about the code that needs to be commented:

a) You use locals as you would use them if G was a textual language; like variables. In G though we try to avoid locals all together, in G the wire is the variable! The wire in addition ensures the next thing the code lacks; execution control.

b) Instead of sequences, use data flow. By working
with the wire instead of locals you can ensure that things execute in the order you want it to, without the need for a sequence structure. And without a sequence structure the code becomes much easier to read and maintain.

I have attached a modified version of your code that applies these two conversions to a "G" way of programming.

Removing trailing zeroes can be done much easier though, attached is also an example of one such way.
Message 2 of 3
(2,672 Views)
Hello Mads! Thanks so much for helping me out with this! You were absolutely right about the string1 being set to read instead of write. I had no idea that it was possible to connect that variable to the input of the concatenate string function without getting an error detected. This really helps me a lot in the future to look out for that. Thanks so much for including a modified vi as well, and a way to remove trailing zeroes more easily. I'll change to the methods you showed from now on so that I can improve on my labview programming techniques. I think labview is great, and I appreciated your very kind help a lot. Thank very much once again Mads!
0 Kudos
Message 3 of 3
(2,672 Views)