O'Reilly logo

LiveCode Mobile Development HOTSHOT by Edward D Lavieri Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding scoring

For our project's final task, we will add scoring to our mobile application. This will require us to edit all six cards.

Engage Thrusters

  1. We want to ensure that the scoring is set to zero each time the application is run. So, we'll add the following code at the stack level:
    on openStack
       global theScore, totalQuestions, totalCorrect
       
       put 0 into theScore
       put 0 into totalQuestions
       put 0 into totalCorrect
    end openStack
  2. Each time the user is taken back to the Main card, we want to recalculate the score. Here is the code to accomplish that. Put this code at the card level on the Main card:
    on openCard global theScore, totalQuestions, totalCorrect put totalCorrect / totalQuestions into theScore put theScore * 100 into theScore put format("%2d", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required