How to make a top ten score ? [Solved]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm
Location: France

How to make a top ten score ? [Solved]

Post by atout66 » Tue Apr 26, 2016 6:47 pm

Hi to all,

I wonder how I could build a top ten score.
I want to record the used of words and show to the user his habits when he click on a button.
I thought about an array but I clearly don't manage them well enought...
I also thought to put the 10 words the most used into 10 different fields and adapt their content, but I must say that I'm a litle bit confused at that time.

If you have some ideas, you're welcome :wink:

Jean-Paul.
Last edited by atout66 on Wed Apr 27, 2016 8:38 am, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to make a top ten score ?

Post by dunbarx » Tue Apr 26, 2016 7:19 pm

Hi.

This is a classic lesson in arrays. Put this into a button:

Code: Select all

on mouseUp
 put "one two three four five six seven eight nine ten" into tList
   repeat 100
      put any word of tList & space after temp
   end repeat
 
   repeat for each word tWord in temp
      add 1 to tWordCount[tWord] --ADD 1 TO THE ELEMENT OF A KEY
   end repeat
   answer tWordCount["three"]
end mouseup
Step through the second repeat loop until you get tired. I assume you can sort the results to find the most commonly occurring word. Do you know what the "combine" command does?

Craig

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm
Location: France

Re: How to make a top ten score ?

Post by atout66 » Wed Apr 27, 2016 8:28 am

Thanks Craig, I'm going to study your script.
No, I didn't know about the <combine> command but with the help of the dictionary I understand what it does now :wink:
Discovering LiveCode Community 6.5.2.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm
Location: France

Re: How to make a top ten score ?

Post by atout66 » Wed Apr 27, 2016 8:38 am

Hi Craig,

Very useful your example. I learned a lot with the debugger, and also discovered the keyword <any> :wink:

Thanks for your help, I should find my way now...

Cheers, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”