Page 1 of 1

NB Function - Advanced Listbox Functions

PostPosted: Fri Apr 06, 2012 1:48 pm
by dpayer
UPDATE: April 7, 2016
I have written an update that does some of these functions better. See this link:

viewtopic.php?f=22&t=21587

=====================================================================

Original post:
I have created a NB function (not JScript / VBS - just using NB commands) that enhances the use of the NB Listbox.

This will allow you to:

Move - selected items between listboxes

Copy - selected items between listboxes

Delete - if items are selected, these will be removed, otherwise the entire contents will be deleted.

Import - Import the contents of a variable array (which is what you get when you do a StrParse). Imported items will be appended to the Listbox and not replace existing items.

Export - Export the contents of a listbox to a variable array. The contents will append to the array and not replace the current contents.

Dedupe - remove duplicate listings from a ListBox. This can be set to be case sensitive, or not. I was able to remove duplicates from a 1000 entry listbox in less than 15 seconds with a compiled app.

There are 4 text parameters to this NB Function.

[%1] - the action you want to use (Move, Copy, Delete, Import, Export, DeDupe)
[%2] - primary listbox (moving FROM, copying FROM, deleting FROM, importing TO, exporting FROM, deduping in, etc.)
[%3] - secondary listbox (if used). Listbox you are moving TO, copying TO.
[%4] in Move, Copy & Delete - give the name (w/o brackets) of the variable that contains the selected items of the listbox. For Import/Export give the name (w/o brackets) of the variable array you are working with. For DeDupe - indicate yes if you require case sensitive search for duplicates ( example: Hello <> hello)

example:
Code: Select all
Call "ListBoxFunctions" "Move" "Listbox2" "Listbox1" "listbox2"

In this case the list box is named ListBox2 and the variable that holds the selected items is [listbox2]. Don't use the brackets when calling the function.

I have created a demo pub to show how these functions are used. You can enter lists via the entry boxes at the bottom. Box on right is multiline. Click "Set Listbox2 w/ entry list" to put the text in the right side listbox. Then highlite groups and move/copy delete them as desired.

If you click the "Add to Array" button, it will put that entry into the respective array for importing.

Image

I have left some alertboxes in for clarity. They are easy to remove in the function.

Files:
ListBox Demo - compiled executable
ListBox Demo - NeoBook Pub file
NB Function file - must be placed in your NB installation folder / functions. Demo app calls it by ListBoxFunctions

Feedback is welcome.

David P.

PostPosted: Sat Apr 07, 2012 7:41 am
by Wrangler
Good stuff, David. Thanks!

PostPosted: Sun Apr 08, 2012 5:49 pm
by Luiz Alfredo
Very good. Thanks.

Re: NB Function - Advanced Listbox Functions

PostPosted: Thu Oct 10, 2013 7:21 am
by andybrock
Just wanted to say thank you for this. I know you posted it a while ago, but it just came in really handy for me :)

Andy

Re: NB Function - Advanced Listbox Functions

PostPosted: Mon Mar 28, 2016 7:47 am
by Gaev
David Payer:

Came to this post from here

You might consider adding these functionalities (with suggested action names in brackets)...

a) Rearrange the entries within a ListBox in Reverse Sorted Order (ReverseSort ?)

b) Copy selected items AND rearrange the resulting items in Reverse Sorted Order (CopyReverseSort ?)

c) Move selected items AND rearrange the resulting items in Reverse Sorted Order (MoveReverseSort ?)

d) Import items AND rearrange the resulting items in Reverse Sorted Order (ImportReverseSort ?)


You might even consider giving users a choice of specifying a regular (forward) Sort Order for above functions.

Re: NB Function - Advanced Listbox Functions

PostPosted: Mon Mar 28, 2016 8:58 am
by dpayer
Gaev wrote:David Payer:

Came to this post from here

You might consider adding these functionalities (with suggested action names in brackets)...

.


Thanks Gaev. I think it is time to revisit many of my posted functions as I can see they could use a bit of polishing.

David

Re: NB Function - Advanced Listbox Functions

PostPosted: Wed Apr 26, 2017 9:59 am
by fkapnist
I just added ListBoxFunctions to my library of Neobook functions.

Thank you.

:P