LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with listbox - double click

Solved!
Go to solution

Hello community,

 

I am trying to make a program in which I build a dialog box using the tab control and the user can double click one of the folder/files and this file should be read in the programm and the graphs should be plotted.

For this, i use a boolean control, if I activate it, I call a tab control with a listbox control in which i use the list folder function to display all the files/folders i have in the directory i set. I could manage to get the double click event to work and provide me the correct path to read the file using the function "read from spreadsheet". The plot part is all done but i am having issues when i try to run the programm.

 

The programm was meant to read the name of the cell that the user double click and only after it reads the name I change it to a path and then read. What its doing is reading the file the listbox starts selected, like if i run the programm one time and double click any file, in the next run it will read the last file selected. The problem is that I am trying to create a Invoke Node to reintialize the listbox but when i do this the programm opens a dialog box to make me select the file to read.

 

So what I  need is to figure it out how I make the programm runs only after the user double click one cell, it shouldnt read the file already selected from previous executions. But I dont know what to do. Can you help please?

 

Thank you for your attention

Lucas

Lucas Faquim
0 Kudos
Message 1 of 8
(3,646 Views)

Possible race condition?

 

Something wrong with the way you programmed the event structure?

 

Without seeing some code, there is no way we can do anything but guess as to what is going wroing.

0 Kudos
Message 2 of 8
(3,643 Views)

I am sorry about that.

Well I am attaching the Vi I made.

 

Ty for the attention

Lucas

 

Lucas Faquim
0 Kudos
Message 3 of 8
(3,616 Views)

Your code is way too chopped up to really make sense. Why the stacked sequence? Why all these local variables?

Why do you use seperate loops? All you need is a single loop and process everything on a double-click of the listbox. No button needed.

 

(Also note that reading the file as an array of strings using a format of %3f makes no sense. Read it as DBL and set the decimal point to comma in the format. Is the time axis spaced equally? If so, you can use plain graphs, no xy graph needed.

 

Your VI is also full of race conditions. There is no guarantee that all these unecessary property nodes on top execute before the loop start (all you probably need is to set the VI to clear indicators when called). Your left loop uses 100% CPU while doing nothing. Your VI cannot be stopped, only aborted. You can combine the two cancel events.

0 Kudos
Message 4 of 8
(3,602 Views)

Well, I am pretty new to the Labview, only a month using it. Also english is not my first language, so I dont get some of the terms you used, like "chopped up" or "race conditions" or how to clear indicators in the start of the programm?

 

Anyways, I really meant to make the programm to be unable to stop, only aborted and also this is a button for another programm, so the button there also is needed. This was build only for me to know how i should add this to the main programm which was not me that created. The 2 whiles were created by me because they are in the main programm.

 

The stacked sequence is there to make the actions happen in that order, thats how i learned. The local variables are also there because I dont know how to use the same variable twice or more times in a VI. Well I am still pretty young to that.

 

So, I really need the help to start understanding better and I need to figure out how to make the double click event act like I want. This Vi is reading a file in the start and i need it to read only the file I select.

 

But anyways, thanks for your time and understanding.

And sorry for any incovenience or my broken english

Lucas Faquim
0 Kudos
Message 5 of 8
(3,593 Views)
Solution
Accepted by topic author Faquim

@Faquim wrote:

Well, I am pretty new to the Labview, only a month using it. Also english is not my first language, so I dont get some of the terms you used, like "chopped up" or "race conditions" or how to clear indicators in the start of the programm?

...

The stacked sequence is there to make the actions happen in that order, thats how i learned. The local variables are also there because I dont know how to use the same variable twice or more times in a VI. Well I am still pretty young to that.


Well, you break up the dataflow by copying into invisible indicators, only to read them back a nanosecond later. Indicators are for the user, not for data storage. If you eliminate the sequence structure, you can wire things together directly. Dataflow determines the exact execution order automatically. No sequence needed.


@Faquim wrote:

The stacked sequence is there to make the actions happen in that order, thats how i learned. The local variables are also there because I dont know how to use the same variable twice or more times in a VI. Well I am still pretty young to that.


indicators and local variables are NOT "variables", they are UI elements.

Attached is a quick attempt at a code cleanup.

 

All your string operations on hardwired paths still make everything quite fragile. You should really operate on path datatypes. There are probably a few broken things because I cannot test. Still, it should give you some ideas.

 

Message 6 of 8
(3,577 Views)

Thank you a lot alten!

You really opened my mind! Now I see how clean it could be. This looks so amazing. This is exactly what I needed, I'll just need to fix some couple of things in the graphs and the stats bar but this is wonderfull!

 

Just one more question, i didnt understand the use of that for loop in which you use a re/im to complex function and how do u plot the graphs there.

 

Again, thank you for your time, your help and your patience!  😄

Lucas Faquim
0 Kudos
Message 7 of 8
(3,565 Views)

@Faquim wrote:

Just one more question, i didnt understand the use of that for loop in which you use a re/im to complex function and how do u plot the graphs there.


xy graphs take a variety of inputs (array of xy point clusters, cluster of x array and y array, complex arrays, cluster arrays of complex arrays, etc.) Typically, complex arrays are cleanest. You have a 1D array and the xy graph will simply plot IM vs RE. The first colum (or row, since we read transposed) is the X and the others are Y. The FOR loop just merges each of the Y data with the same X data into complex arrays. (the "build xy graph express VI" is a bit of a boat anchor 😄 and I almost never use them. It is really only useful with dynamic data or if you want to retain data between writes (express option, off by default).

Message 8 of 8
(3,560 Views)