Source language: Translate to:

Listbox Shorting

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Listbox Shorting

Postby Dudus » Thu Nov 16, 2017 6:47 am

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
User avatar
Dudus
 
Posts: 115
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: Listbox Shorting

Postby dpayer » Thu Nov 16, 2017 1:04 pm

Take a look at the options available on this listbox function:

viewtopic.php?f=22&t=21587
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Listbox Shorting

Postby Dudus » Fri Nov 17, 2017 5:57 am

Thank you but im looking for an easier option without right click etc...
Any other easy solution? :)

Thank you!
D
User avatar
Dudus
 
Posts: 115
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: Listbox Shorting

Postby Gaev » Fri Nov 17, 2017 10:17 am

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
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Listbox Shorting

Postby dpayer » Fri Nov 17, 2017 10:29 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Listbox Shorting

Postby virger » Fri Nov 17, 2017 8:00 pm

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
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: Listbox Shorting

Postby Dudus » Wed Nov 22, 2017 3:15 am

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
User avatar
Dudus
 
Posts: 115
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: Listbox Shorting

Postby virger » Wed Nov 22, 2017 6:52 am

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
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 3 guests