取消
显示结果 
搜索替代 
您的意思是: 

concatenating strings automatically for loop

已解决!
转到解答

Hi

Does anybody knows why does this doesn't work?

 

Forloop_concatenating_failure.png

 

 

Best regards,

Thijs

0 项奖励
1 条消息(共 8 条)
12,107 次查看

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 项奖励
2 条消息(共 8 条)
12,100 次查看
解答
已被主题作者 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
3 条消息(共 8 条)
12,090 次查看

@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
4 条消息(共 8 条)
12,072 次查看

Thank you so much!

 

It's clear now

 

Regards,

Thijs

0 项奖励
5 条消息(共 8 条)
12,061 次查看

@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 - https://www.ni.com/docs/en-US/bundle/labview/page/how-labview-stores-data-in-memory.html


___________________
Try to take over the world!
6 条消息(共 8 条)
12,032 次查看

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
7 条消息(共 8 条)
12,013 次查看

@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 项奖励
8 条消息(共 8 条)
11,975 次查看