LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any faster of doing search in an array?

HI,
I am using this code to read file config_1.txt to create an array. Then I try to search all the S: in the array and then record there index in another array. But it talkes long time to do that. Can anyone suggest any improvment in the code. Text file's path needs to be change in the VI depending on the location of file before running it.

Thanks
Kanwar
0 Kudos
Message 1 of 7
(3,942 Views)
Please attach your VI and the txt file 🙂
0 Kudos
Message 2 of 7
(3,935 Views)
Here is the Vi. I lost the attachments path after I reviewed the post.

Thanks
Download All
0 Kudos
Message 3 of 7
(3,933 Views)

this one is yours Altenbach, I don't have LV8.0 installed on this machine.

 

P.M.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 7
(3,920 Views)
OK, first here's a simplified implementation (LAbVIEW 8.0).
 
 
Details:
  • First of all, "read lines from file" is evil! Don't use it if you want to read the entire file or if you want to read more than the first few short lines in a file. It is slow and probably the cause of the slowness in your version.
  • Read the entire file as a string, then convert it to a 1D array directly. (It is not healthy to read it into a 2D array, take a full subset (a NOOP!), then use delete from array to get the first column. ;))
  • You don't want to start searching at N at each iteration, but after the index of the previously found match.
  • Just keep searching until you run out of array, no need to keep track with all that other boolean stuff.
  • Use "built array" instead of "insert into array". No need to keep track of indices. 🙂
 

Message Edited by altenbach on 11-04-2005 12:52 PM

Download All
0 Kudos
Message 5 of 7
(3,915 Views)
The speed of the new code is amazing, I can not believe it ......

Thanks a lot.
Kanwar
0 Kudos
Message 6 of 7
(3,896 Views)


@Kanwar wrote:
The speed of the new code is amazing, I can not believe it ......

Yes, LabVIEW is very fast. No need to slow it down by setting the cursor to "busy". 😄
 
(I tried to measure the speed, but it was less than 1 ms, including the File I/O. ;))

Message Edited by altenbach on 11-04-2005 02:18 PM

0 Kudos
Message 7 of 7
(3,890 Views)