LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding string to array

Solved!
Go to solution

Hello,

 

I am facing issue in write a string into array. I am reading a text file using Read from Text File.vi in a For loop and matching a string match pattern. VI which gives me desired string. Now the string which I have got at output, I am not able to put this string into array. I have tried doing the auto index function of for loop for creating the array. Please suggest a way to build the array.

0 Kudos
Message 1 of 8
(848 Views)

Your task is really easy. Please post your code possibly in LabVIEW <= 2021 (maybe also a snippet or picture) to let us see where's the error.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 8
(841 Views)

Hi Swami,

 


@Rohan1612 wrote:

I have tried doing the auto index function of for loop for creating the array. Please suggest a way to build the array.


When you want to "build an array" you should consider using the BuildArray function!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(836 Views)

ReadTextFile.PNG

 Please see the snippet for the code.

Thanks in advance.

0 Kudos
Message 4 of 8
(815 Views)
Solution
Accepted by topic author Rohan1612

When Match Pattern function fails to find a match, a -1 is issued in offset past match. Use this value to filter the output.

Unless your LabVIEW version is rather old, you may right click on the output tunnel making it conditional, then wire offset past match  >= 0 the conditional terminal:

match.png

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 5 of 8
(802 Views)

Hi Rohan,

 


@Rohan1612 wrote:

Please see the snippet for the code.


This is not a snippet, it's just an image of your code. Snippets are special to LabVIEW: read the LabVIEW help to learn about them!

 

You already create an array of strings, so I don't know why you claim "you are not able to put the string into array"!?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(790 Views)

Thanks for the solution. I could build an array.

0 Kudos
Message 7 of 8
(760 Views)

Thanks GredW for the input on Snippets. I will surely look into it.

0 Kudos
Message 8 of 8
(759 Views)