LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can you access multiple lines anywhere from a multi-line string?

I want to be able to access multiple lines of string from a multi-line string. I need to keep a line count each time because I need to access the rest of the string. I tried using pick line and doing a for loop until I get the amount I want, but it's too slow. It seems to be incrementing in execution time. I also tried putting the string into a string array, and accessing multiple lines by using the index array in a for loop, but that again is too slow as the size of the string gets bigger. By too slow, I mean it's taking a little over 500 ms to finish on my machine. We can't upgrade our machine and I need it to access about 70 lines at a time in around 300ms so I need someway of efficiently a
ccessing multiple lines at a time. Can anyone help me?
0 Kudos
Message 1 of 8
(4,698 Views)
Need more information on what you are trying to do to suggest a better alternative. Offhand, you may try to keep track of the line positions & lengths within a larger string but that is a guess as well.
Stu
0 Kudos
Message 2 of 8
(4,698 Views)
Hi,
I need to pick a line from a multiline string.So i used pick line function from library. In the front panel i created a control (v16type-line index
i created a multiline string constant string seperated by carriage return.
In order to run the vi I need to enter the line index
as 0,1,2,3 etc. I need to display the menu along with this control.Suppose 0 is for mode 1 . 1 is for mode 2, so while entering the line index a 0 it should display the menu as mode 1.
I will really appreciate if any one can help.
thanks
Prasad
0 Kudos
Message 4 of 8
(4,698 Views)
Hi,
I need to pick a line from a multiline string.So i used pick line function from library. In the front panel i created a control (v16type-line index
i created a multiline string constant string seperated by carriage return.
In order to run the vi I need to enter the line index
as 0,1,2,3 etc. I need to display the menu along with this control.Suppose 0 is for mode 1 . 1 is for mode 2, so while entering the line index a 0 it should display the menu as mode 1.
I will really appreciate if any one can help for creating this Vi.An example vi is given which is cut and paste from a driver
thanks
Prasad
0 Kudos
Message 5 of 8
(4,698 Views)
So what's the question in here? The attached VI works fine..

Ah, the joys of SCPI.

sunnyvale wrote in message
news:50650000000500000038490000-1003545641000@exchange.ni.com...
> Hi,
> I need to pick a line from a multiline string.So i used pick line
> function from library. In the front panel i created a control
> (v16type-line index
> i created a multiline string constant string seperated by carriage
> return.
> In order to run the vi I need to enter the line index
> as 0,1,2,3 etc. I need to display the menu along with this
> control.Suppose 0 is for mode 1 . 1 is for mode 2, so while entering
> the line index a 0 it should display the menu as mode 1.
> I will really appreciate if any one can help for creating this Vi
.An
> example vi is given which is cut and paste from a driver
> thanks
> Prasad
0 Kudos
Message 6 of 8
(4,698 Views)
Hi
Yeah thats works fine
But I need to draw a new diagram .But i dont know how that is doing coz its only a cut and paste..
So please help me how i can do this ?
Prasad
0 Kudos
Message 8 of 8
(4,698 Views)
.... I need
> someway of efficiently accessing multiple lines at a time. Can anyone
> help me?


I'm not sure I understand what you are doing with the lines, but
assuming you can process multiple lines at a time, then you there are
ways to speed up both the string and array approach.

For the large string control, rather than picking a line at a time, you
can search the string looking for the End of Line characters. Then use
the string subset node to copy the lines out in one read. You can also
convert the string to an array of characters and do any access using
array functions.

For the Array of strings datatype, you do not need to index each element
and put them back together one at a time. You can read out an array
subset and process it all at once.

An
other thing that may be happening is you might be using read and write
local variables to access the string and modify it for each line. You
really shouldn't use controls and locals as variables. Use shift
registers or loop auto- indexing instead.

Greg McKaskle
0 Kudos
Message 3 of 8
(4,698 Views)
One idea is to use a '2 x N' array in order to store the start and end positions for each line in that string:

Array[0,k-1] = start position of line k in your string
Array[1,k-1] = end position of line k in your string

Thus, you can access easier every line you want (line i - substring starting at A[0,i-1] and (A[1,i-1]-A[0,i-1]) length) or multiple lines at a time (similar, using the end position of the last line), without searching.

Hope this helps somehow.
Message 7 of 8
(4,698 Views)