LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

concatenating strings automatically for loop

Solved!
Go to solution

Hi

Does anybody knows why does this doesn't work?

 

Forloop_concatenating_failure.png

 

 

Best regards,

Thijs

0 Kudos
Message 1 of 8
(10,118 Views)

I know this works:

 

concatenate_scucceed.png

 

But why not the other one, and is this operation time consuming for LabVIEW, it builds a new string every loop cycle....

 

Regards,

Thijs

0 Kudos
Message 2 of 8
(10,111 Views)
Solution
Accepted by ThijsBoeree

Hi Thijs,

 

the error message of the broken wire is quite unique: "incompatible arrays connected"...

 

The help only mentions arrays to be connected by an output tunnel. Scalar strings aren't mentioned anywhere!

 

That's the "traditional" way:

original.png

Use ConcatStrings to concatenate an array of strings into a single string...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(10,101 Views)

@ThijsBoeree wrote:

Hi

Does anybody knows why does this doesn't work?

 


Strings are a bit funny with the concatinating tunnel.  LabVIEW concatanating tunnels only work on rectangular arrays.  An array of strings is really a 2D ragged array since each string is an array of U8s and each string has its own length.  Concatinating "On the fly" inside the loop tunnel then is no more effecient than building the string on a SR since a new buffer must be allocated for each iteration.  Use Gerd's snipette to concat outside the loop for best performance.


"Should be" isn't "Is" -Jay
Message 4 of 8
(10,083 Views)

Thank you so much!

 

It's clear now

 

Regards,

Thijs

0 Kudos
Message 5 of 8
(10,072 Views)

@JÞB wrote:
An array of strings is really a 2D ragged array since each string is an array of U8s and each string has its own length. 

Not exactly. The array itself is a simple 1D array of pointers, where each pointer points to the relevant string - http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/how_labview_stores_data_in_memory/


___________________
Try to take over the world!
Message 6 of 8
(10,043 Views)

Well,  I'll take my lumps and a bit of new knowledge. Thanks again Yair!

 

But, then why does the concat tunnel have the problem the OP alluded to... if it does.???....OK FUN, I'm going to learn something!  (Really, I enjoy it!)


"Should be" isn't "Is" -Jay
Message 7 of 8
(10,024 Views)

@JÞB wrote:

But, then why does the concat tunnel have the problem the OP alluded to...


Because it's meant to concat arrays, not strings. It's true that the same term is used for both, and there's no reason in principle why NI can't make a concat tunnel concat strings as well, but since the code for concatting strings is so easy, I don't see the point. If anything, what's surprising there is that the wire coming out of the tunnel is not broken.


___________________
Try to take over the world!
0 Kudos
Message 8 of 8
(9,986 Views)