LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

concatenate strings vi

I have made a concatenate strings vi in LV 6.0. However I am not able to save my readings in the save file. I cannot save the data. Notice the broken line. The vi is attached.
0 Kudos
Message 1 of 14
(3,559 Views)
Frame 0 of your sequence structure looks okay.  Frame 1, however, you have done 2 things wrong:

1) you cannot attach a wire to a tunnel out of a sequence structure from more than one location.  If you wish to pass info out from both frames, you need to add a second tunnel.
2) The waveform datatype you are passing out in frame 1 is not compatible with the Write Characters to File.  You need to convert this to a string before using Write Characters to File (using, for example, "Format Into String" on the String pallete).

Hope this helps!

Message Edited by Joe Gerhardstein on 08-10-2005 01:23 PM

Joe Gerhardstein
Viasat
Certified LabVIEW Architect
Certified TestStand Developer
Certified Professional Instructor
http://www.viasat.com
Message 2 of 14
(3,551 Views)
You've mad two very basic mistakes. You can't connect two different sources to the same output of a sequence structure and you can't connect a waveform to Write Characters to File because the Write Characters to File will only accept strings as an input. Move the Write Characters to File inside frame 0, pass the file name to frame 1 with a sequence local, and in frame 0, wire the sequence local to either Write to Spreadsheet File or Export Waveforms to Spreadsheet File.
Message 3 of 14
(3,546 Views)
How to create a sequence local?
0 Kudos
Message 4 of 14
(3,535 Views)
Right-mouse click on the edge of the sequence frame, and select "Add Sequence Local"
Joe Gerhardstein
Viasat
Certified LabVIEW Architect
Certified TestStand Developer
Certified Professional Instructor
http://www.viasat.com
Message 5 of 14
(3,534 Views)
This is all explained in the LabVIEW help. You should always be working with context help (Help menu) turned on. It explains how to create a sequence local in the main context help window when you move your mouse over the sequence structure and you can get a lot more details if you click the "Click here for more help".
Message 6 of 14
(3,536 Views)
I have done the vi. I believe it is according to your advice. It has no broken lines. Is it okay? The vi is attached.
0 Kudos
Message 7 of 14
(3,517 Views)
You should also learn how to get away from sequence structures.  They are frowned upon because they hide code.  You have to flip through frames to see the rest of the code.  In your vi, the sequence structure is very unnecessary.  It seems like your intentions were to write some sort of heading to the file containing the items you are concatenating into a string, then to write the data collected into the file.  I have modified your vi to do this, take a look at the attachment (LV7.1, if you are using a different version, let us know which one).  The entire code is visible in one screen, and this makes it much easier to read and understand.  I used the open/create/replace file, write file, and close file to show that this can be done differently.  If writing just once, you can replace the three functions with the higher level Write Characters to File function.  The file operation will not take place until all of its inputs are present (this is what we call data dependency).  That is why the sequence is unnecessary.  By using data dependency with the way things are wired, the data must be collected first by the AI function.  The concat will not execute until all of its inputs are present.  After the data is collected, the output of the AI function will go through the conversion to string, and then to the concat function.  At this time, all of the concat inputs are present and it will execute.  Then the output of the concat will go to the File Write and then all of its inputs will be present, and it will write the total string to the file all at one time.  The Error Out from the file write is wired to the Close File function so that the file will only close after the write has finished executing.  I hope you understand the data depencency concept, then you won't have to use sequence structures again, except in some special cases to force execution flow where data dependency cannot be created by wiring.
- tbob

Inventor of the WORM Global
Message 8 of 14
(3,516 Views)
Well, the code is no longer "broken", but only you can tell if it is doing what you want...
Joe Gerhardstein
Viasat
Certified LabVIEW Architect
Certified TestStand Developer
Certified Professional Instructor
http://www.viasat.com
Message 9 of 14
(3,503 Views)

As always tbob gave an excellent discussion of the very bad effects of sequence structures...

But what with it being late and my not being able to get to sleep, I took his good example and played with it a bit to show something else that might be of value to you. A common way of building a large string is to use a concatenator to paste everything together. However, this can cause readability problems if you have a large number of items because often you will endup essentially having two terminals for each item you want to add to the string (one for the item and one for the delimiter separating it from the next item).

Something I have found that aided readability in these situations is to us a string formatter as shown in my (further) modified version. There are far fewer wires cluttering the diagram and looking at the formatting string makes the basic structure of the output immediately apparent. This becomes even more valuable in situations where the various items have labels associated with them. For example, with a format string like:

Operator: %s
Test Number: %d
Time/Date: %s %s
Results:
%s

The resulting report is very easy to visualize.
 
Well 'nighters folks...
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 10 of 14
(3,484 Views)