12-18-2012 10:00 AM
Hello,
I have a vi that eventually writes certain data to a log (.txt) file. Within the data that gets written, there are a few arrays. In one particular section, I have three string arrays that I am attempting to manipulate with no luck. Below is an example of what I have now, and subsequently, where I want to be:
Present:
x1
x2
x3
y1
y2
y3
z1
z2
z3
Desired:
x1 y1 z1
x2 y2 z2
x3 y3 z3
Where x, y, and z represent the three sepreate string arrays. These arrays are then concatenated with other data to produce the log file. It seems that no matter what I do ( build, transpose, index, etc...) I still end up with the vertical arrangement in my log file -- I am sure that I am overlokking something trivial, but it is eluding me at the moment.
I cannot post my code due to security, but will provide any more detais that are needed. Thanks in advance.
Solved! Go to Solution.
12-18-2012 10:16 AM - edited 12-18-2012 10:17 AM
I think you're looking to do a Build Array followed by a transpose.
Your build array should have 3 inputs.
Feed it X, Y, and Z and you should get
x1, x2, x3
y1, y2, y3
z1, z2, z3
Hit that result with the transpose and you should get
x1 y1 z1
x2 y2 z2
x3 y3 z3
What are you using to write to the log file?
12-18-2012 10:23 AM
Let me make sure I have this straight. You have 3 arrays of string: {x1, x2, x3}, {y1, y2, y3}, and you want a 2D array in the end:
x1 y1 z1
x2 y2 z2
x3 y3 z3
?
If I'm correct, then you should just use a Build Array with "Concatinate Inputs" off (it is a right-click option for the build array) and then transpose.
12-18-2012 10:51 AM - edited 12-18-2012 10:58 AM
Thanks. That got me a little further. I now have the data grouped, which is better, but it is not how I would like it... cosmetically speaking. Now it is:
x1
y1
z1
x2
y2
z2
It seems as though Labview is coercing the data into a single cloumn and will not write more than one piece of data to the row.
To write the log file, I am using a "File Dialog" coupled with a "Write to Text File".
12-18-2012 11:29 AM
Can you show up your code for this little operation. It still seems to me that you are using the "Concatinate Inputs" on the Build Array.
12-18-2012 12:01 PM
I cannot post the code, but the the inputs are not concatenated.
12-18-2012 12:22 PM - edited 12-18-2012 12:25 PM
12-18-2012 12:29 PM
So after reading NUMEROUS posts and replies all with good input, I determined that there must be something I was overlooking -- as the solution seemed so trivial and and was reiterated by numerous labview experts.
Turns out that the build array and transpose was the correct solution.
In my case, I dug back into my code and found where I had concatenated the string AND a carriage return constant (on three separate occasions). Labview was always coercing to the next line because I had told it to do so.
Thanks for the quick replies. Amazing forums!