Wednesday, March 18, 2015

March LiveCode Madness: Building a Clickable Bracket

For the first time ever, I have filled out my own bracket for the upcoming NCAA basketball tournament. For many people here in the USA, this is an important annual ritual. One's bracket simply predicts every winning team in every match-up in the six rounds of the tournament. The tournament starts with a field of 64 teams with half being eliminated after each of the first five rounds. The sixth round pits the two remaining teams in the championship game to crown the national champion. I'm finally participating at the encouragement of my brother, Bill, who happens to teach economics at Butler University in Indianapolis, Indiana. Bill is our family's sports historian with particular expertise in baseball. But this is basketball season and basketball is very big in Indiana. The significance of basketball in Indiana is depicted very well in the movie "Hoosiers." (Trivia: The final championship game in the movie was filmed at Butler Field House where the actual state high school championship game had long been played.)

Basketball is also very big at Butler University. Butler is probably the smallest school ever to appear in the NCAA championship game, having done so in both 2010 and 2011. Unfortunately, Butler lost both times. The loss in 2010 was quite dramatic with Butler, down two points, taking the last shot of the game. Alas, the ball bounced off the rim and Duke won 61-59. The University of Georgia is also playing in the tournament this year and it is conceivable that they could face Butler in the championship game. More on that later.

Like a lot of work places, Bill's colleagues at Butler run a little competition each year where you can enter your bracket. The person with the best prediction wins the competition. Bill enters every year and this year, again with Bill's encouragement, I'm participating too. Our other brother, Mark, is also participating.

To fill out my bracket, I found a PDF online at printyourbrackets.com. For those not familiar with what a bracket looks like, here is a quick snapshot:



I find the visual design very appealing. Teams from the midwest and west are on the left-hand side and teams from the east and south are on the right. You can easily see how teams are quickly whittled down until there is one national champion in the center-most box. But, to fill out this PDF, I had to do a whole lot of copying and pasting. The first version I sent to Bill had a serious copy and paste error, which I'm glad I caught soon after I sent my PDF to him. I had Wisconsin winning the game between Kentucky and Buffalo. (Wisconsin is good, but they are not that good.) I showed Wisconsin continuing to win in Kentucky's spot until the championship game, when Kentucky "reappeared." I fixed the PDF and sent my brother an updated version.

But, I found myself wishing that I had found a "clickable" version of the bracket online instead of a PDF. Then, I could have just clicked my way from team to team with each click quickly pasting in the name of my pick in the slot to the right or left. (It's likely there is such a clickable version out there, but I didn't find one in the few minutes I allocated to my search.)

So, I created a very simple and very incomplete version of a basketball bracket using LiveCode. And, I learned something new by creating this little project. In order for the "on mouseUp" handler to work within a field field, the text in the field has to be set to locked. This makes sense because otherwise every time you clicked in the field to type something into it -- such as the names of the basketball teams in round 1 of the tournament -- the on mouseUp handler would take over. But, to enter the first set of team names, the fields need to be unlocked. So, I needed to have an easy way to lock and unlock the text fields, or at least the text fields to the far left or right of the bracket.

I created two buttons - "Lockdown" and "Unlock" - that, well, lock and unlock the text fields. Now, in my little example, I only have 4 of the 64 teams represented. This results in a total of seven text fields (or three open brackets). If I had all 64 teams, that would require 126 text fields (with 62 open brackets). That's a lot of fields to lock or unlock. But, I learned a good trick while creating a previous project based on the fact that LiveCode automatically numbers all fields on a card. With that knowledge, I used the following script in the button "Lockdown" to lock all the fields on the card:

on mouseUp
   put the number of fields on this card into L
   repeat with i = 1 to L
      set the locktext of field i to true
      set the backgroundcolor of field i to red
   end repeat

end mouseUp

The first line just counts up the total number of fields on the card and puts this number into the local variable L.

Then, I create a loop that repeats L times, starting by putting 1 into the local variable i. The next line sets the locktext property of field i (that is, field 1 or field 2 or field 50, depending on what loop it is) to true, thus locking down the field. Each loop automatically adds one to i.

I also went ahead and set the backgroundcolor of locked fields to red. I thought it would be nice to use some color coding to signal to the user whether the fields were in a locked or unlocked state.

In the button "Unlock" I simply changed true to false in the "set the locktext" line. I also changed the background color to yellow. Here's a snapshot of the screen in the unlocked state:

[ Get the free LiveCode Community version. ]


Here's a snapshot of the screen after the fields have been locked down, thereby allowing the user to click on the fields to make selections, going from left to right:



I then added a script to each field that put a copy of whatever text is in that field to the next field to the right. Here's an example:

on mouseup
   put me into field "r2g1t1"

end mouseup

I labeled all the fields with a scheme that would be helpful if I later choose to continue building this project with a complete bracket. This scheme starts with the tournament round number, then the game number, then the team number. So, "r2g1t1" means round 2, game 1, team 1. Using this scheme, I think I could automate the script for the fields so that each would know what field to send their contents to. For now, I just hard coded the destination.

Looking Forward to the Day When LiveCode Exports to HTML5


As I write this, many of us are waiting anxiously for news on the RunRev company's efforts to enhance LiveCode to allow projects to be exported to HTML5. This project would be a perfect candidate for this feature because I could then embed this project within a web page. Then, I would have legions of basketball fans flocking to my clickable bracket maker site. As I understand it, exporting to HTML5 will essentially convert LiveCode scripts to Javascript. The company began the effort to add this feature to LiveCode about eight months ago with a timeline to completion of one year. So, I keep my fingers crossed everyday that the company will send out an announcement that this feature is finally ready.

One Last Bit of Basketball Trivia While Pondering Who Might Win This Year's College Championship


Here's a final piece of basketball trivia. As I understand it, dribbling evolved from a loophole in the original rules of basketball. The game was invented in the late 1800s by James Naismith, a Massachusetts teacher who wanted a safe, indoor game. The idea was to have players continually pass the ball to teammates to move the ball down the court with the goal of getting the ball into a peach basket mounted up high at the end of the opposing team's side of the court. It was against the rules to run while holding the ball. At some point, someone figured out that if you bounce the ball you are not technically holding it, so this was a way for the player to move about without breaking the rules. Ah, American ingenuity.

So, who do I predict will win the tournament this year? Yes, it is possible for my school - The University of Georgia - to meet my brother's school - Butler University - in the NCAA Basketball Championship game. But, even with the little I know about college basketball, I know the odds of this happening are very, very, small. So, despite the fact that I show above Butler beating Kentucky in round 4 of the tournament (also known as the "Elite 8"), I'm predicting Kentucky will go all the way this. But, then again, stranger things have happened.

Oh, one more thing ... what exactly is a hoosier, anyway?


34 comments:

  1. Professor,

    Good to see another LiveCode fan out there. I use LC as a rapid prototype builder supporting apps for the Oceanographer of the Navy. You can see a little of my work at: https://www.youtube.com/watch?v=RzeM2mZIqP8 you tube link. Spread the word...keep up the good work. Greg

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. hello, today as always your post is lovely that I liked it and I am waiting for your new works in future, good luck to all of you.
    digital marketing services in delhi

    ReplyDelete
  4. In the last few months we've seen a lot of Health Care Reform rules and regulations being introduced by the Health and Human Services Department. Every time that happens, the media gets hold of it and all kinds of articles are written in the Wall Street Journal, the New York Times, and the TV network news programs talk about it. All the analysts start talking about the pros and cons, and what it means to businesses and individuals. Health is God

    ReplyDelete
  5. I think this is a real great article post.Really looking forward to read more. Visit at
    Crazy Video Hub

    ReplyDelete
  6. Nutra Trials defines personal characteristics of different health products including skincare, weight loss, muscle and male enhancement. The study presented here is briefly described for reader convenience and to deliver them assurance with health standards. The best possible answers are given here regarding the selection of an ideal supplement or cream or serum that possibly remains to be safe for health and do not cause any side effects.

    ReplyDelete
  7. Nice.... article to go through,I would appreciate the writer's and I hope you continue this job well
    NutraT line

    ReplyDelete
  8. This is a great post ! it was very informative. I look forward in reading more of your work. Also, I made sure to bookmark your website so I can come back later. I enjoyed every moment of reading it..
    kim kardashian sex tape
    porn sex video hd
    mia khalifa sex video
    sunny leone sexy movie

    ReplyDelete
  9. Hello, I am thomus jons thank you for this informative post. That is a great job. Wish you more success.Thank you so much and for you all the best. Takes Down
    123movies

    ReplyDelete
  10. Times For Health is Online Health & Wellness Program! I came on the your post and i got so information here. Thanks for the valuable post. https://www.timesforhealth.com/

    ReplyDelete
  11. Healrun is a health news blog we provide the latest news about health, Drugs and latest Diseases and conditions. We update our users with health tips and health products reviews. If you want to know any information about health or health product (Side Effects & Benefits) Feel Free To ask HealRun Support Team.

    ReplyDelete
  12. Supplements For Fitness diet pill is a completely natural product and is considered safe, it would be good to consult your doctor before starting the program with its use.It is important that when you decide to use Hoodia, you must

    ReplyDelete
  13. Pilpedia is supplying 100 percent original and accurate information at each moment of time around our site and merchandise, and the intent is to improve the usage of good and pure health supplement. For More Info please visit Pilpedia online store.

    ReplyDelete
  14. We are here to give you a complete review on the Parallel Profit project by Steve Clayton and Aidan Booth. If you are someone from the field you would already be familiar with these two names, for those of who are new. Parallel Profits Review

    ReplyDelete
  15. Best softwares for Internet Marketers and legitimate make money online opportunities cxyrc

    ReplyDelete
  16. Revuesdefaits defines personal characteristics of various health merchandise together with skincare, weight loss, muscle and male enhancement. The study presented here is briefly described for reader convenience and to deliver them assurance with health standards. The best potential answers are given here concerning the selection of a perfect supplement or cream or serum that presumably remains to be safe for health and do not cause any facet effects.

    http://revuesdefaits.fr/revolyn-ultra/

    http://revuesdefaits.fr/keto-fit-premium/

    ReplyDelete
  17. Buyers Reviews defines personal characteristics of different health products including skincare,weightloss,muscle and male enhancement.Buyers Reviews is supplying 100% original and accurate information at each moment of time around our site and merchandise, and the intent is to improve the usage of good and pure health supplement.

    ReplyDelete
  18. The Probiotic supplement helps to balance good bacteria and in this regard, Zenith Labs Probiotic t-50 review is creating buzz. How far is the supplement reliable and worth considering, you will come to know about it here.

    ReplyDelete
  19. Hi to all, the contents existing at this site are actually remarkable for people experience, well, keep up the good work fellows.
    https://www.drozus.com

    ReplyDelete
  20. Thanks for sharing your info. I truly appreciate your efforts and I will be waiting for your further write ups thank you once again.
    https://www.drozus.com

    ReplyDelete
  21. This is a very great article.Simply wow!!! You folks has a great and information.good work,Thanks a lot for this awesome post.
    Keto BodyTone

    ReplyDelete
  22. Hello to every one, the contents present at this web page are in fact amazing for people knowledge, well, keep up the good work fellows.
    https://www.drozus.com

    ReplyDelete
  23. This is great, unique and very informative post; I like it. thanks
    https://care2fit.com/lipo-cla-avis/

    ReplyDelete
  24. This is great, unique and very informative post; I like it. thanks
    https://care2fit.com/lipo-cla-avis/

    ReplyDelete
  25. Hello to every one, the contents present at this web page are in fact amazing for people knowledge, well, keep up the good work fellows.
    https://www.drozus.com

    ReplyDelete
  26. Weight loss is a general issue that almost anyone wants to solve. However, even with all the products that can assist people to lose weight, a lot of them are still

    not able to do it.For men who want to lose weight successfully.

    https://www.supplementsmegamart.com/keto-ultra-diet/
    https://ketoultradietsharktank.quora.com/Keto-Ultra-Diet-Alert-Read-Shark-Tank-Reviews-Ingredients-Or-Scam
    https://www.instagram.com/p/Bt0Oz3WAMtC/
    https://www.pinterest.com/pin/855754366674247147
    https://medium.com/@supplementsmegamart/keto-ultra-diet-are-these-pills-your-slim-down-solution-review-ee442211f3e7
    https://www.reddit.com/user/supplementsmegamart/comments/aq5xbz/keto_ultra_diet_bottle_reviews_does_it_really/

    ReplyDelete
  27. Thanks for share this valuable post TimesForEducation. We Regularly Update Education's News From All Over The Worlds. Our Mission Not Only Provide Education's News But Also People Get Become Educated. Visit also this website: https://timesforeducation.com/

    ReplyDelete
  28. This is often a small amount of good useful content in the matter of delving into this. Double X Male Enhancement Male Enhancement may be a dangerous strategy to find even additional types of Male Enhancement. You do have the time for a Male Enhancement that exterminates a scenery for a Male Enhancement. Like I perpetually say, "The final straw breaks the camel's back." There are a slew of game plans in that you can use Male Enhancement.

    https://www.healthygnc.com/double-x-male-enhancement/

    https://www.healthygnc.com/

    ReplyDelete
  29. Quite often, a lot of overweight people who decide to embark on a Trim Pill Keto weight loss program or diet spend a lot on smaller size dresses to serve as a source of motivation at the beginning only to end up feeling guilty, angry and frustrated once they fail to achieve this goal a month later.

    Visit Us: https://www.supplementsmegamart.com/trim-pill-keto/
    https://bit.ly/34BoxS7
    https://buytrimpillketo.yolasite.com/
    http://buytrimpillketo.bravesites.com/
    http://buytrim-pill-keto.jigsy.com/
    http://buytrimpillketo.mystrikingly.com/
    https://works.bepress.com/leesa-roy/
    https://yarabook.com/read-blog/25706
    https://trimpillketo-20.webself.net/
    https://leesaroy.tumblr.com/post/189426076592/trim-pill-keto-advanced-diet-formula-bhb

    ReplyDelete
  30. I am truly pleased to glance at this web site posts which includes tons of useful information, thanks for providing these information.
    Home Improvement Write for us

    ReplyDelete
  31. It was very useful for me. Keep sharing such ideas in the future as well. This was actually what I was looking for, and I am glad to came here! Thanks for sharing such a information with us.
    Health + write for us

    ReplyDelete
  32. Hello Friends My Name is Elijah Pellinger I am From United States I would like to Introduce You about My Website Many weight lose Products Are Available on our Website.Those Products are Beneficial for your Health You can Live your Lifestyle Healthier.You can Loose Your weight easily with these products

    https://fitness-trends.life/

    ReplyDelete
  33. Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this.
    Home Decor "Write for us"

    ReplyDelete