Source language: Translate to:

arrange in order

General questions about NeoBook

Moderator: Neosoft Support

arrange in order

Postby martinp » Fri Mar 25, 2016 2:46 am

Hi Guys,
Trying to produce a quiz night scoring system and having trouble trying to get the names and scores in order of highest score first, then arranged in descending order.

[Team1] - name of team1
[T1S] - team 1 score
...etc upto team 20

Looking for scripting so that when a button is pressed it arranges them in order of highest score (with team name) first, then the rest in descending score (and team name)

Any ideas would be greatly appreciated.

Thanks
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: arrange in order

Postby virger » Fri Mar 25, 2016 7:29 am

Intenta esto.
Try this.

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=10
Name=LsYesSort
X=212
Y=290
W=130
H=210
Anchor=0
Text=012,ZZZ¶023,AAA¶045,CCC¶009,YYY¶123,KNM¶987,AAB¶780,LOP¶001,ZWY
VarName=[LsYesSort]
VarType=0
Sorted=Yes
XPTheme=Yes
LineColor=0
LineWidth=1
LineStyle=0
FillColor=15856113
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=17
ObjectType=10
Name=LsNoSort
X=75
Y=289
W=130
H=210
Anchor=0
Text=012,ZZZ¶023,AAA¶045,CCC¶009,YYY¶123,KNM¶987,AAB¶780,LOP¶001,ZWY
VarName=[ListBox4]
VarType=0
XPTheme=Yes
LineColor=0
LineWidth=1
LineStyle=0
FillColor=15856113
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=16
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: arrange in order

Postby martinp » Fri Mar 25, 2016 4:30 pm

Thanks Virger,
Each team is recognised as follows:

[TextEntry1] is the team name
[T1] is the team score

Everything works fine as you suggested but if more than one team has the same score, it struggles to display properly
The sort alphabetically option lists them in order of same value...

example:
1
14
19
2
22
28
34
39
4
41
etc.

Whereas, looking for scripting that starts at the highest score and the lists in order of highest to lowest

Thanks you again for your advise
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: arrange in order

Postby virger » Sat Mar 26, 2016 9:05 am

Para usar sólo NB (sin plugins), intentaría el "truco" siguiente:
1) Los números del 0 al 9 0=J, 1=I,....9=0
2) Creo un "código" para cada número del 'score' (IGE-135,
987-ABC...)
3) Y le agrego el dato respectivo:
IGE-135-Barak Obama
987-ABC-Ronaldo Cristiano
4) Incluyo la lista en un 'ListBox' y le activo el SORT
5) Puede cubrirse, la parte del 'código' con un rectángulo y listo
6) Al seleccionar el dato se hace un "strparse" del mismo para separar el código del resto strparse "[vData]" "-" "[Inf]" "[x]"
[Inf1]...es el codigo
[Inf2]...es el score
[Inf3]...es el Dato

Te adjunto el script. Buen día.

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

To use only NB (without plugins), try the following "trick":
1) The numbers 0 to 9 0 = J, 1 = I, .... 9 = 0
2) I create a "code" for each number 'score' (IGE-135,
987-ABC ...)
3) And I add the relevant data:
IGE-135-Barak Obama
987-ABC-Cristiano Ronaldo
4) enclose the list in a 'ListBox' and active SORT
5) Can be covered, the part of 'code' with a box and ready
6) When you select the data it gets a "strparse" just to separate the code ussing strparse "[vData]" "-" "[Inf]" "[x]"
[Inf1] ... it is the Code
[INF2] ... it is the Score
[INF3] ... is the Team

We attached the script. Good day.

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=10
Name=ls
X=6
Y=103
W=300
H=200
Anchor=0
Text=[ls]
VarName=[vData]
VarType=0
Sorted=Yes
XPTheme=Yes
ObjAction=strparse "[vData]" "~" "[inf]" "[x]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Terminal
FontSize=14
FontStyle=0
FontCharset=255
TextColor=0
TabOrder=1
ObjectType=3
Name=BtList
X=6
Y=18
W=300
H=29
Anchor=0
Text=Enter Data List Init
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[ls]" "IHG~123~James Bond[#13][#10]JAB~098~Barak Obama[#13][#10]JIH~012~Lula Lula[#13][#10]BCA~879~Zambia Poor[#13][#10]GGF~334~Costa Rica[#13][#10]JCE~075~Sky Failed"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14671839
FillPattern=0
Font=Arial
FontSize=12
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=0
ObjectType=8
Name=Over
X=7
Y=104
W=40
H=198
Anchor=0
Font=Terminal
FontSize=14
FontStyle=0
FontCharset=255
TextColor=0
HMargin=0
VMargin=0
DropTarget=ls
LineColor=0
LineWidth=0
LineStyle=0
FillColor=5306440
FillPattern=0
TabOrder=7
ObjectType=9
Name=EnScore
X=6
Y=73
W=62
H=27
Anchor=0
Text=666
VarName=[vScore]
Align=1
EditNumber=Yes
EditLen=3
LineColor=0
LineWidth=1
LineStyle=0
FillColor=15990768
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=9
Name=EnTeam
X=70
Y=73
W=167
H=27
Anchor=0
Text=GdoSan Virger
VarName=[vTeam]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=15990768
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=3
Name=BtInclue
X=239
Y=73
W=68
H=27
Anchor=0
Text=Include
Align=2
Key=13
ImageStyle=0
XPTheme=Yes
ObjAction=strparse "I.H.G.F.E.D.C.B.A" "." "[Code]" "[x]"¶setvar "[Code0]" "J"¶¶strlen "[vScore]" "[ln]"¶substr "000[vScore]" "[ln]+1" "3" "[vScore]"¶¶setvar "[vCode]" ""¶loop "1" "3" "[x]"¶    substr "[vScore]" "[x]" "1" "[ch]"¶    setvar "[vCode]" "[vCode][Code[ch]]"¶endloop¶¶ListBoxAddItem "ls" "0" "[vCode]~[vScore]~[vTeam]"¶setvar "[vScore]" ""¶setvar "[vTeam]" ""¶setvar "[vCode]" ""
LineColor=0
LineWidth=1
LineStyle=0
FillColor=15724527
FillPattern=0
Font=Arial
FontSize=12
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=8
Name=Inf1
X=6
Y=49
W=300
H=24
Anchor=0
Font=Comic Sans MS
FontSize=11
FontStyle=1
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset1 Comic Sans MS;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red0\green0\blue0;}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\margh720\margf720{\*\pnseclvl1\pnucrm\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl2\pnucltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl3\pndec\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl4\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{)}}}¶{\*\pnseclvl5\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl6\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl7\pnlcrm\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl8\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl9\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶\endnhere\sectdefaultcl{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs22\cf0\b Score\tab \tab \tab \tab \tab \tab Team}}¶}
HMargin=6
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14737656
FillPattern=0
TabOrder=8
ObjectType=8
Name=Inf2
X=6
Y=305
W=300
H=61
Anchor=0
Font=Terminal
FontSize=14
FontStyle=0
FontCharset=255
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset255 Terminal;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red0\green0\blue0;}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\margh720\margf720{\*\pnseclvl1\pnucrm\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl2\pnucltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl3\pndec\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl4\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{)}}}¶{\*\pnseclvl5\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl6\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl7\pnlcrm\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl8\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl9\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶\endnhere\sectdefaultcl{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs28\cf0  Code:[inf1]\par¶\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs28\cf0 Score:[inf2]\par¶\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f1\fs28\cf0  Team:[inf3]}}¶}
HMargin=6
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14741752
FillPattern=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: arrange in order

Postby Gaev » Sat Mar 26, 2016 12:26 pm

martinp:

example:
1
14
19
2
22
28
34
39
4
41
etc.

Whereas, looking for scripting that starts at the highest score and the lists in order of highest to lowest

When you make up the ListBox entries using combination listedTeamScore - teamName ...
Code: Select all
SetVar "listedTeamScore" "1000000 - [actualTeamScore]"

... assuming actualTeamScores are less than one million ... so actual values like ...

7 for Portugal
42 for Belgium
355 forCanada

... will form entries like ...

999993 - Portugal
999958 - Belgium
999645 - Canada

... this will take care of scores with differing number of digits AND sort by highest actualTeamScore (999645 - Canada) ahead of lowest (999993 - Portugal).

Then, when you want to show the users their actualTeamScores, loop through the ListBox entries ... remembering to subtract the listedTeamScores from one million to get back to actualTeamScores.

f.y.i. you can loop through the ListBox entries using Loop/EndLoop, ListBoxSize, ListBoxGetItem commands.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: arrange in order

Postby martinp » Sun Mar 27, 2016 4:33 am

thanks Gaev
Will study and try to understand
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: arrange in order

Postby dpayer » Mon Mar 28, 2016 7:29 am

martinp wrote:Hi Guys,
Trying to produce a quiz night scoring system and having trouble trying to get the names and scores in order of highest score first, then arranged in descending order.

Thanks


You may find my Advanced Listbox functions helpful:

http://neosoftware.com/community/viewtopic.php?t=19299
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: arrange in order

Postby virger » Wed Mar 30, 2016 7:27 am

Más simple ?!
More simple ?!

Este código es para un Botón
This code is for a Button

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5.80
ObjectType=3
Name=BtExe
X=38
Y=33
W=147
H=27
Anchor=0
Text=Exe
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=.1) Create a ListBoxSize "LsSort"   'SORT'  Append ALL Data¶.2) Create a ListBoxSize "LsUnSort" 'NOT-SORT'¶.3) Execeute Button Actions¶¶ListBoxSize "LsSort" "[LenSort]"¶loop "[LenSort]" "1" "[i]"¶    ListBoxGetItem "LsSort"   "[i]" "[vDatSort]"¶    ListBoxAddItem "LsUnsort" "0"   "[vDatSort]"¶endloop¶.Free Memory¶ListBoxDeleteItem "LsSort" "All"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=15856113
FillPattern=0
Font=Arial
FontSize=14
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4


By JAMAICA
Hello Russian !!
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: arrange in order

Postby stu » Wed Mar 30, 2016 7:42 am

Why not using a database for such purpose?, sounds like the perfect task for it... No need to go enterprise level, you could do with a small SQLite, even better, you can have historical records...
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: arrange in order

Postby Gaev » Wed Mar 30, 2016 6:17 pm

stu:

Why not using a database for such purpose?, sounds like the perfect task for it.

That would be the logical answer ... however, if I recall, in the past, user martinp has stated a desire not to use any kind of Database in his various applications.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: arrange in order

Postby martinp » Thu Mar 31, 2016 6:28 am

Hi guys, Gaev is correct......I would prefer not to use databases.
Still studying the various suggestions and trying to understand the scripting behind it - something that is not my strong point!

Its a case of making sure that the score matches the team name.

[TextEntry1] = team one's name
[T1] = team one's score.

etc, upto 16 teams.

Can anyone help????

Thanks
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: arrange in order

Postby virger » Thu Mar 31, 2016 7:12 am

Ya hiciste la prueba con el boton que te envie ?
Ahi esta la solucion mas simple, realizada con 10000 lineas [Nombre/Valor (1000 puntos)]

You've done the test with the button that sent you?
There is the simplest solution, made with 10000 lines [Name / Value (1000 points)]
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: arrange in order

Postby martinp » Thu Mar 31, 2016 11:12 am

Hi, yes, tried it but it listed them in a 'strange' order

ex: scores where
6
9
10
11
27

When the button was pressed it re-arranged in this order

9
6
23
11
10
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: arrange in order

Postby Gaev » Thu Mar 31, 2016 11:19 am

martinp:

When the button was pressed it re-arranged in this order

9
6
23
11
10

This is because 9 is larger than 6 ... which is larger than 2 ... which is larger than 1 ... and 11 is larger than 10.

As stated before, you should add (e.g. 100000) to all scores first ... so you get ...

1000009
1000006
1000023
1000011
1000010

... and subtract 1000000 when extracting the sorted entries (to get back to the original scores).


Alternative is to add zeroes in front of scores e.g. 009, 006, 023, 011, 010 ... but the scripting for this is more complex than just adding/subtracting a large number.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: arrange in order

Postby martinp » Thu Mar 31, 2016 11:31 am

thanks Gaev,
Trying to work out how to implement it.

The current format of the software:
Names of teams are on screen.
If the team answers a question correctly, I click their name and it adds 1 to their score [T1] - this score is displayed via a button.
If they answer the question incorrectly, I click their score [T1] and it subtracts 1 from the score..

There are 16 teams [T1] to [T16]

Hope you understand...

Thanks again for your valued time
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Next

Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest