Empty Field on Stack closure

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
redfield
Posts: 95
Joined: Thu Apr 04, 2019 1:41 pm

Empty Field on Stack closure

Post by redfield » Sun May 05, 2019 10:04 am

Hi guys,
I was looking for a way to put an initial value into a Field on startup of the Stack. So what I did on Card 1 is this:

Code: Select all

on openCard
   set the text of fld f1 to 10
end openCard
And this seems to work fine. But I also want to empty another Field on the Card, when closing the Stack. So I tried this:

Code: Select all

on closeCard
   set the text of fld f2 to empty
end closeCard
This doesn't work though, the Field remains filled. I'm stuck again :? .

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Empty Field on Stack closure

Post by Klaus » Sun May 05, 2019 10:19 am

Hi redfield,

if you do not SAVE the stack after emptying the field, it will open again in the state of the last SAVE.
Same with standalones, which cannot save themselves at all.

So just empty the field "on preopencard" or even "on preopenstack" and noone will be able to tell the difference! :D


Best

Klaus

redfield
Posts: 95
Joined: Thu Apr 04, 2019 1:41 pm

Re: Empty Field on Stack closure

Post by redfield » Sun May 05, 2019 8:15 pm

Thanks Klaus, but seems I didn't get it yet.

I have now:

Code: Select all

on preOpenCard
   set the text of fld f1 to 10
   set the text of fld f2 to empty
end preOpenCard
When I open the stack and change f1 let's say to 20 and fill f2 with "xyz", then save, close and reopen, f1 shows value 10 (which is what I want) but f2 is not empty, it shows "xyz".

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Empty Field on Stack closure

Post by Klaus » Sun May 05, 2019 8:57 pm

Does this also happen if you quit LC after saving and then start LC and open that stack again?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Empty Field on Stack closure

Post by dunbarx » Sun May 05, 2019 9:16 pm

Are you sure you have no other handlers in play? It sure seems that what you have should work just fine. I will be shocked if this is a real anomaly. The handler is just too simple and direct.

Craig

redfield
Posts: 95
Joined: Thu Apr 04, 2019 1:41 pm

Re: Empty Field on Stack closure

Post by redfield » Sun May 05, 2019 9:19 pm

Your answers indicate that this should not be :D . So I double double checked everything and discovered having a typo in the name of the second Field. It's working fine now, thanks and sorry for the fuss!

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Empty Field on Stack closure

Post by Klaus » Sun May 05, 2019 9:48 pm

Okie Dokie! :D

But do yourself a favour and get used to put QUOTES around all strings like object names etc.:

Code: Select all

...
set the text of fld "f2" to empty
...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Empty Field on Stack closure

Post by dunbarx » Mon May 06, 2019 12:34 am

discovered having a typo in the name of the second Field.
LC did not throw an error when you tried to modify a non-existent field? There is still something odd here, even if not related to the original issue.

Craig

redfield
Posts: 95
Joined: Thu Apr 04, 2019 1:41 pm

Re: Empty Field on Stack closure

Post by redfield » Mon May 06, 2019 8:16 am

I was not precise, it was not a "typo", it was the name of a different field that I accidentally used (copy&paste). All is well with LC.

Post Reply