avoid losing data

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
greggarcia
Posts: 33
Joined: Mon Apr 27, 2009 3:32 pm
Contact:

avoid losing data

Post by greggarcia » Thu May 20, 2010 12:53 am

Hello, i have a code like this in one card:
on Temporizador
add 1 to tsec3
if tsec3 < 60 then
if tsec3 <= 9 then
put "0" & tsec3 into field "3sec"
else
put ":" && tsec3 into field "3sec"
end if
else
if tsec3 =60 then
put "00" into field "3sec"
end if
put "0" into tsec3
add 1 to tmin3
if tmin3 <=9 then
put "0" & tmin3 into field "3min"
else
put tmin3 into field "3min"
end if
end if
if gparat3 is 0 then
send "Timer1" to me in 1 second
end if
end Temporizador

if i moved to another card i got an error message and the timer stop to counting, do you know how to avoid it? well a solution was putting a the same field name in the othe card (but a thinks is not the way to do it)


thanks so much
Greg

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: avoid losing data

Post by Mark » Thu May 20, 2010 9:34 am

Hi Greg,

As far as I can see, it is impossible to go to another card while your script runs (because it is a blocking script). From this, I conclude that you run the script while it shouldn't or the script contains an incorrect reference to objects. There are two solutions.

First of all, you can replace

Code: Select all

field "3sec"
with a complete reference to that field. I don't know what this reference looks like exactly, but it should be something like

Code: Select all

field "3sec" of cd "Correct Card" of stack "Your Stack"
Another solution is to prevent the script from running if the short name of the card is incorrect:

Code: Select all

on Temporizador
  if the short name of this cd is "Correct Card" then
    -- remainder of your script here
  end if
end Temporizador
Best regards,

Mark

P.S. Please, make sure to post any error messages next time.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Re: avoid losing data

Post by Regulae » Thu May 20, 2010 6:20 pm

Hi Greg,

Here’s a quick stack which might be in the right direction for you.

Regards,

Michael
Attachments
TimerTest.zip
(2.59 KiB) Downloaded 279 times

greggarcia
Posts: 33
Joined: Mon Apr 27, 2009 3:32 pm
Contact:

Re: avoid losing data

Post by greggarcia » Mon May 24, 2010 11:44 pm

Mark I appreciate your kind answer, thanks so much, now is working property and i can understand how runrev is working little by little... best regards... Greg

Post Reply