While block error

Every time I use the while block, both the emulator and the application get blocked.
Even when I use simple programming.error

In your while loop you don't reduce global contar, so it will run forever.

if you want decrease a variable whenever you hit a button you can do something like the following (without a while):

Probably is not what you need, but at least it works.