Page 1 of 1

Listbox Shorting

PostPosted: Thu Nov 16, 2017 6:47 am
by Dudus
Dear All,

can you please help me again? I have a listbox with these lines:
DE HU 2017-11-16
GB ES 2017-11-21
PL FR 2017-11-19

how can i make a button if I want to arrange by ascending and descending dates?
DE HU 2017-11-16
PL FR 2017-11-19
GB ES 2017-11-21

Thank you!
Dudus

Re: Listbox Shorting

PostPosted: Thu Nov 16, 2017 1:04 pm
by dpayer
Take a look at the options available on this listbox function:

viewtopic.php?f=22&t=21587

Re: Listbox Shorting

PostPosted: Fri Nov 17, 2017 5:57 am
by Dudus
Thank you but im looking for an easier option without right click etc...
Any other easy solution? :)

Thank you!
D

Re: Listbox Shorting

PostPosted: Fri Nov 17, 2017 10:17 am
by Gaev
Dudus:

There is no easy way to sort items within NeoBook.

However, if your items are already stored on a file on disk, you can make use of the sort command offered in DOS ... something like this ...
Code: Select all
Run "sort" "/+7 c:\gk\unsorted.txt /O c:\gk\ascending.txt" "RunOnce+Wait+Hidden" "" ""

Run "sort" " /R /+7 c:\gk\unsorted.txt /O c:\gk\descending.txt" "RunOnce+Wait+Hidden" "" ""

... then load the sorted output into the Listbox.

Note 1: if your items are not on a disk file, you can always Loop through the items in the ListBox and write them out to a temporary file

Note 2: as I found out, this command does not work with folder/file names that contain spaces

Note 3: if you are running on a machine with a version of Windows older than XP, there is a slightly different syntax for the sort command ... see this web page for details ... https://www.computerhope.com/sorthlp.htm

Re: Listbox Shorting

PostPosted: Fri Nov 17, 2017 10:29 am
by dpayer
Dudus wrote:Thank you but im looking for an easier option without right click etc...
Any other easy solution? :)

Thank you!
D


If ease is what you want, you can always hire someone to do your programming for you.

If you were to look at the functions, not just the demo app or the picture provided in the post, you would see that one of the functions is a sort. You don't even need to use the menuing option for that function. It is there for eye candy.

Read the full post. Download the function, look at the code that does the sorting (it is notated). It may be helpful.

Re: Listbox Shorting

PostPosted: Fri Nov 17, 2017 8:00 pm
by virger
Y si probas esta solucion ? Me cuentas como funciona
And if you try this solution? You tell me how it works

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=3
Name=PushButton7
X=219
Y=14
W=80
H=30
Anchor=0
Align=2
ImageStyle=0
ObjAction=strparse "DE HU 2017-11-16`GB ES 2017-11-21`PL FR 2017-11-19`JN RD 2016-09-21`GU JN 2017-03-04" "`" "[arr]" "[nArr]"¶¶loop "1" "[nArr]" "[i]"¶.for (var i in arr) {¶        tempArr[i] = arr[i].match(/([^0-9]+)|([0-9]+)/g);¶        ¶setvar "[tempArr[i]]" "[arr[i]]"¶¶loop "¶        for (var j in tempArr[i]) {¶            if( ! isNaN(n = parseInt(tempArr[i][j])) ){¶                tempArr[i][j] = n;¶            }¶        }¶    }
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14277081
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=9

Re: Listbox Shorting

PostPosted: Wed Nov 22, 2017 3:15 am
by Dudus
Gaev wrote:Run "sort" "/+7 c:\gk\unsorted.txt /O c:\gk\ascending.txt" "RunOnce+Wait+Hidden" "" ""

Run "sort" " /R /+7 c:\gk\unsorted.txt /O c:\gk\descending.txt" "RunOnce+Wait+Hidden" "" ""[/code]


Thank you Gave! This working fine for me :)
Dudus

Re: Listbox Shorting

PostPosted: Wed Nov 22, 2017 6:52 am
by virger
Magnifico, años de jugar con DOS y primera vez veo a plenitud el poder de SORT.
Gracias

Magnifico, years of playing with DOS and the first time I fully see the power of SORT.
Thank you