Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 7:49 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Sorting
PostPosted: January 9th, 2009, 6:41 pm 
Offline

Joined: July 11th, 2008, 7:44 pm
Posts: 16
Location: Oss, The Netherlands
Hi you All,

I am working on a Result Board and therefor i made an input screen.
There are 20 lines (text inputs) to set name, and score.
On the display page i make the variables visible for the audience.
Now i would like to sort the outcome (is that english?) so that the highest score is on top etc.
It must run in real time because the score is changing during the game.

Who can help me.


Marian Hausman


Top
 Profile Visit website  
 
 Post subject:
PostPosted: January 9th, 2009, 11:13 pm 
Offline

Joined: May 24th, 2007, 11:02 am
Posts: 132
Location: UK - Wales - Ceredigion
Opus: illuminatus > Evolution
OS: Windows 10 Pro
System: i7 8GB RAM
This is how I would do it, but I don't think Multi-dimensional Array's are working in Opus at the moment :(

Code:
function sortMe(){
myScores[0] = (name1,score1)
myScores[1] = (name2,score2)
myScores[2] = (name3,score3)
myScores[3] = (name4,score4)
myScores.sort(compare);
}

function compare(a, b)
{
  return a[1] - b[1];
}


Top
 Profile Visit website  
 
 Post subject:
PostPosted: January 10th, 2009, 12:16 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
No multidimensional arrays don't work in Opus but objects can be used in their place.

myCards = new Array()


for (a=0;a<10;a++)
{
myCards[a] = new card(a,String.random(100))
Debug.trace(myCards[a].ordinal+' : ' +myCards[a].rnd+'\n')
}
Debug.trace('\n\n\n')


myCards.sort(sortByRnd)

for (a=0;a<10;a++)
{
Debug.trace(myCards[a].ordinal+' : ' +myCards[a].rnd+'\n')
}

function card(a,b)
{
this.ordinal = a
this.rnd = b
}

function sortByRnd(a, b)
{
var x = a.rnd
var y = b.rnd
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: January 10th, 2009, 8:20 am 
Offline

Joined: July 11th, 2008, 7:44 pm
Posts: 16
Location: Oss, The Netherlands
OK... Let's start to try it. It's a lot of scripting (for a nono like me) but i'll try.
Thanks.


PS
may i ask for help if it's to much for me? :)


Marian


Top
 Profile Visit website  
 
 Post subject:
PostPosted: January 10th, 2009, 9:57 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
I think you jumped into the deep end :-)

Yes of course you can ask for help. I'd check the post on Tip For Posting first though:

viewtopic.php?t=3514

Attached is a working example of a scoreboard that returns the top three players and their scores as new results are added as it will probably help to see this working.

Mack


You do not have the required permissions to view the files attached to this post.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: January 10th, 2009, 3:59 pm 
Offline

Joined: July 11th, 2008, 7:44 pm
Posts: 16
Location: Oss, The Netherlands
Thanks Mackavi, Your great. Thanks


Marian


Top
 Profile Visit website  
 
 Post subject:
PostPosted: February 21st, 2009, 6:19 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Good solution, I needed something similar in a publication that used a database. As I already had a database I just created a table, then in the Opus Publication I wrote the scoreboard to the table and using SQL pulled the scoreboard and ordered by score.

It's an easy way to get it done requiring only a few lines of SQL if you already use a database. I'll dig the code out if anyone wants it.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 46 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group