Problem with variable between Screens

Hi all,

I'm trying to make a game with two screens. In screen1 there's a button that leads to screen joc_pala, when the game takes place. When the game is over, it stores the time (temps) and returns to screen1, where it checks that time against the best time (rècord) and updates it if it is the case.
My problem is that I think it should work, but the label etiqueta_rècord always shows the last time, instead of the record. Hoping someone can help...



Make a small sample app to study the possible error.

borrar_record.aia (3.8 KB)

darrer_temps > record, The record is established when temps is greater.

1 Like

Thank you, Antonio!

I tried the sample app and worked perfectly. Then I compared with my blocks, and could find no difference. But finally, after too much time for what it was, I found my mistake! As you can see in the previous image, the tag is written "rècord" in one place and "record" in the other.

I'm sorry to waste your time with such silly mistake. Thanks again!

I avoid such errors in my code by creating constant global variables holding my reserved tag values, and referencing the global variables when I need a reserved tag. That concentrates the spelling of the tag into just one place, the global init block.

init global RECORD_tag 'record'

TinyDB get tag(global RECORD_tag)
TinyDB Save tag(global RECORD_tag) value(...)

1 Like