From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Make an array of the items clicked in a list

Solved!
Go to solution

1. i managed to get the file names which are clicked. but how do i make all the clicked items to an array? I tried wiring it to a build array. but it does not seem to be working like i thought.

 

2. also cliking out of the list bound area before activating the search button, the vi was found to hang. what could be the reason.

 

3. on following stopping sequence where first the internal while loop and then the external was also hanging the vi. surprisingly stopping the outer loop first and then the inner seemed to work. what's the reason for this and what's the work around for the problem.

 

vi has been attached. please help

 

thanks in advance 🙂

0 Kudos
Message 1 of 9
(4,934 Views)
Solution
Accepted by topic author amithkuttan

Hi Amith,

 

2. Wrong usage of the event structure. Did you read the LabVIEW help on them? Never hide event structures inside of case structures…

 

3. Same as 2. Why do you need two stop buttons at all?

 

Now on to 1:

- Never use tunnels set to "default if unwired" when you want to keep data! THINK DATAFLOW!

- Why do you use events of the pane? Why not use events of the listbox?

- Why not use the listbox terminal to read the selected element?

- Why don't you put the (inner) stop button terminal inside of the corresponding event?

 

Just a sketch:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(4,911 Views)

You do lots of things wrong. No surprise your VI hangs... First of all, you never set up an Event structure as you do! Just delete the outest while loop and case structure. You only need a single while loop, and an Event structure inside. Also delete the timeout case, you do not use it for anything! Why to timeout after 5 msec???

The mouse down mouse up events with coordinates are not really an option here...

Go to your Listbox on your Front Panel, right click on it, and select "Selection mode" --> "1 or more item" . In this way the user can select multiple files. By default, you can only select one single element from the list!

 

EDIT: i always write very slow my posts, GerdW was faster 🙂

EDIT2: what is below, is a snippet, save it, and drag&drop it onto an empty block diagram to get the VI...

 

A_get file name on click.png

 

 

Message 3 of 9
(4,903 Views)

Thank you so much GerdW. You showed me much more than what I wanted. Learned a lot.

 

Hmm, I'm still in the initial stages of understanding the correct data flow. I usually work things out by trial and error method or understanding how others have done and modifying it to my needs. Guess it's high time to start understanding data flow and build efficient vis

 

0 Kudos
Message 4 of 9
(4,875 Views)

Thank you so much Blokk. You did make a point about the timeout. I've still not quite understood the purpose of timeout in an event case structure. Will look that up right away.

 

I was not able to appreciate your vi completely, said could not load v15 on v13. but with the little what I understood from your code, it is more of a strict ordering. The strings are not recorded in the order i click, which is one of the important factor. I'm sorry for not mentioning that in the first place. It'd be nice if I could see ur code completely.

 

Thanks again 🙂

 

0 Kudos
Message 5 of 9
(4,870 Views)
Solution
Accepted by topic author amithkuttan

It is very strange that you could not open the snippet. Must be something wrong with my LAVA Code Capture Tool, I set it to save into LV2013, it even shows version number 13.0 at the header...

 

Anyway, I modified the VI for you, and attach it as a proper VI too, not only a snippet. Now it simply records where you click, and incrementally builds up a string array. I also set the Listbox to only accept single selection in order to simplify to code (also set the data type to scalar from array; Selection mode: 1 item, Data type: scalar from the settings menu of the Listbox).

 

EDIT: so obviously this solution is the same what GerdW already showed you...

EDIT: actually his one is even better, since a double click more "user safe" compared to an accidental "mouse up" event in my example!

 

Example_VIvvvvvv.png

 

 

 

Message 6 of 9
(4,848 Views)

Thank you once again Blokk for spending time on this. This looks cool. 🙂 🙂 🙂 🙂

 

note: the snippet still showed the same error while loading.

 

Also, I wanted to add the feature of deletion from the new list incase of an accidental click, delete row option is there upon right clicking on the listbox in the front panel while the VI is not running. I went through all the property nodes, but din't find any. I googled and found row delete for multicolumn. Applied the same idea keeping in mind that mine is a single column. But I could not succeed.Any tips on that ?

0 Kudos
Message 7 of 9
(4,788 Views)

@Blokk wrote:

It is very strange that you could not open the snippet. Must be something wrong with my LAVA Code Capture Tool, I set it to save into LV2013, it even shows version number 13.0 at the header...


Looks like something's wrong on your end. I also can't open your snippet in 2013, but if I open it in 2015 and then create a snippet of the code for 2013, it does work and I can open it. My best guess would be that the save for previous method didn't work on your PC for some reason but did save something. Since the relevant code in the CCT doesn't do any error reporting, it's possible for such an error to go unnoticed. If you want to figure it out, I think you'll have to open the relevant VI, add a breakpoint and then run the CCT and see what happens inside it.


___________________
Try to take over the world!
0 Kudos
Message 8 of 9
(4,777 Views)

@amithkuttan wrote:

Thank you once again Blokk for spending time on this. This looks cool. 🙂 🙂 🙂 🙂

 

note: the snippet still showed the same error while loading.

 

Also, I wanted to add the feature of deletion from the new list incase of an accidental click, delete row option is there upon right clicking on the listbox in the front panel while the VI is not running. I went through all the property nodes, but din't find any. I googled and found row delete for multicolumn. Applied the same idea keeping in mind that mine is a single column. But I could not succeed.Any tips on that ?


Well, in my example you fill the listbox with a list which corresponds to file names located in the specified folder. I guess you do not want to delete a line from the Listbox itself, but the last element from the propagated array indicator (to be more precise, delete an element from the shift register storing the incrementally growing string array). You can easily add an Event for a button which will delete the last line from this array. See below this new Event case (is this what you want?):

 

Example_VImmm.png

 

 

 

0 Kudos
Message 9 of 9
(4,758 Views)