Close Stack Cleanup
curry at pair.com
Thu Feb 4 21:33:17 EST 2021
> I agree with others that this isn't a Good Idea,
> and a cleaning routine in preOpenStack would do the trick nicely.
Amen, Brother Mark! Good Idea to avoid Bad Habits.
(Agreed, except a small but crucial difference in details....)
As Tore said:
> execute the necessary routines as part of a preOpenStack handler
Again, with a small but important difference:
The preOpenStack handler is NOT ideal for this type of cleanup.
"Literally, to "clear the fields" of a stack."
(And now we also know, a "complex" stack.)
That is NOT something best done in preOpenStack.
A complex stack usually has multiple cards.
The user is going from one card to the other - perhaps more than once.
You need this type of cleanup triggered by preOpenCard!
Whereas preOpenStack and startup are better for general init.
Keep it modular; preOpenCard and Clear Form can call the same code.
(You both already probably know that and do it.
Just making an explicit point for other readers who are learning.
People always tell me things they read here! They take it to heart.)
If you clean up fields in preOpenCard, you're ready for the end user.
But your saved stack may be very BLOATED at times!
Large amount data in a field, image, etc.
(And yes, in these days of interim-capacity SSDs, disk space matters.
Your stack will also be saved in a more cluttered state.)
To solve that easily, as I've said: use saveStackRequest!
That way your stack is SAVED clean and non-bloated.
You can freely test larger data samples.
Stacks are small for sharing within your dev team.
Your users will NEVER see your test data entries.
(Even if a preOpenX handler fails due to runtime bug,
which I've seen happen fairly often in stacks people make!
Potential embarrassments automatically averted.)
It's also perfect for simpler stacks with one card.
> Back to the drawing board.
Not if you take the advice of myself and others!
Proven solutions, well-tested over time, reliable, that work TODAY.
(But I do like the IDE bug report; the IDE tramples some messages.)
Good topic! People will learn from it. Thanks for starting it.
Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
More information about the use-livecode