Page 1 of 3

Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 1:10 pm
by cbarbal
Hi all,

I would like that when leaving the stack the data of all the cards will be erased. I've done a test with the following script, but it does not work for me.

Code: Select all

on closeStack
   closeConection
   go invisible card "Finques"
   send "clearAllFinques" to cd "Finques"
   close this stack
end closeStack
Any suggestions

Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 1:57 pm
by Klaus
Hi Carles

try this:

Code: Select all

on closeStack
   closeConection
   lock screen
   go card "Finques"

   ## If this is in the card script then no need to SEND it, since we ARE now on that card:
   clearAllFinques
   PASS closestack
end closeStack
If the fields have been filled AND the stack has been saved in the meantime, this will of course not work, resp. will LOOK as if this has not been working! 8)


Best

Klaus

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 2:13 pm
by Klaus
If that does not work, please try with "closestackrequest":

Code: Select all

on closeStackRequest
   closeConection
   
   ## INVISIBLE is a STACK property, so a card can not be invisible itself.
   ## With a "lock screen" the user will also not notice this
   lock screen
   go card "Finques"
   clearAllFinques
   PASS closeStackRequest
end closeStackRequest

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 3:00 pm
by cbarbal
Hi Klaus,

The two answers take me to the card "Finques" and the error comes out that does not find the handler "clearAllFinques"

Code: Select all

on clearAllFinques
   clearDatagridFinques
   clearDatagridPisos
   clearDatagridTotals
   clearRecordFinques
   clearGroupTotals
end clearAllFinques
I give you another option :D

Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 3:05 pm
by Klaus
Very strange!? OK, then try with:
...
send "clear..." to cd "Finques"
...
Does not make sense, but if that works... :D

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 3:30 pm
by cbarbal
Hi Klaus,

After forcing the exit of the application, now it leaves me all the empty cards without doing anything. If in the data grid is checked persistent data. Should not there be data?

With a Mac Plus and Hypercard, these things did not happen

Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 3:37 pm
by Klaus
Hm, did you SAVE the stack at some point?
And you are talking about "application", so this is a standalone?
If yes, where are the stacks that are NOT part of the standalone located?

All stacks of a standalone will of course always reflect the status they have been saved with.
Know what I mean?

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 3:39 pm
by cbarbal
Hi Klaus,

I just rebooted the Mac and I have all the data on all the cards again. I leave the computer and I dedicate myself to something else ...

Regards,

Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 4:21 pm
by cbarbal
Hi Klaus,

In principle this works, at the moment with a button...

Code: Select all

on mouseUp
   go card "Finques"
   send script "clearAllFinques" of card "Finques"
   go card "Pisos"
   send script "clearAllPisos" of card "Pisos"
end mouseUp
Is there any logical explanation?

Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 4:30 pm
by Klaus
Sorry, no idea. :(

But please leave out -> script, just send the name of the handler(s) and TO the target:

Code: Select all

...
## send script "clearAllFinques" of card "Finques"
send "clearAllFinques" TO card "Finques"
...

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 5:56 pm
by cbarbal
Klaus,

I have gone for a walk. I do not understand anything with the button works, but when I put the script inside a handler. A GREAT ...

Code: Select all

on clearAllCards
   lock screen
   go card "Finques"
   send script "clearAllFinques" of card "Finques"
   go card "Pisos"
   send script "clearAllPisos" of card "Pisos"
   go card "Menu"
   unlock screen
end clearAllCards

on closeStack
   clearAllCards
   closeConection
   close this stack
end closeStack
The result:
LiveCode001.jpg
Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 6:02 pm
by Klaus
Please read my last post, you are using a very wrong syntax, although you had it right in your first posting!?

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 7:02 pm
by cbarbal
Klaus,

What exactly do you mean by telling me
you are using a very wrong syntax
If you mean my English, I completely agree, but if it's the LiveCode syntax, I'll attach two images so you can see where I got it from.
LiveCode002.jpg
LiveCode002.jpg (19.8 KiB) Viewed 8335 times
LiveCode003.jpg
Carles

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 7:09 pm
by Klaus
Of course I do not mean your english! :shock:

I mean this, which is wrong syntax:
send script "clearAllPisos" of card "Pisos"
So no wonder this throws an error!

In your first posting you had it correct:
send "clearAllPisos" to card "Pisos"
Which I was telling you in my last posting.

And this is from the dictionary entry about "visible", no idea why LC gives this "go invisible card..." example for GO!?
...
You can set the invisible property of a card, but doing so has no effect. Cards cannot be made invisible.
...

Re: Clear the data of a card when leaving the stack

Posted: Fri Nov 23, 2018 7:39 pm
by cbarbal
Regarding send script "clearAllPisos" of card "Pisos" in the second image you see: "send script message to object"

For me is not wrong syntax, send script message ("clearAllPisos") to object (of card "Pisos")

Spanish:
Que conste que no quiero discutir con una persona que sabe muchísimo más que yo de LiveCode y encima me está ayudando. Por lo que le doy las gracias y a todos los que me han ayudado en este foro.

Al no funcionar el "send" he buscado una alternativa que ha sido "send script". Si lo que me ofrece LiveCode no es correcto, apaga y vámonos

English:
For the record, I do not want to argue with someone who knows a lot more about LiveCode than me and who is helping me. For what I thank you and all those who have helped me in this forum.

When the "send" did not work I searched for an alternative that was "send script". If what LiveCode offers is not right, turn it off and let's go

Carles