A question about openCard
Richard Gaskin
ambassador at fourthworld.com
Mon Jun 3 13:19:01 EDT 2019
Simon Knight wrote:
> "Is there some simple way that an openCard handler can branch based on
> what card it is coming from?"
>
> My solution would be to give each card a customprop named say
> “uCalledBy". Then when the app changes cards I set this prop e.g.
>
> Set the uCalledBy of Card 42 to “HitchHikers”
> Go to Card 42
>
> Then in Card 42 ’s opencard or anywhere else
>
> If the uCalledBy of me is “HitchHikers” then
> answer “Where is your towel?”
> end if
Custom properties are an excellent option when both of these
requirements are met:
1. The data is most meaningfully expressed when bound to a specific
object.
2. The data benefits from persistence.
In the scenario at hand, #1 is well met, but #2 may be problematic.
For example, if you happen to save the stack while working on it (who
doesn't?) then you'll have property values in place that may not be
relevant to the next runtime session.
This would require that you add a handler to clear those properties on
startup, or some other useful entry point for execution, in addition to
adding the code above.
When you find yourself writing handlers to clean up after other handlers
you've written, it may be time to reconsider the original premise.
FWIW Jacque's solution seems the most with-the-grain one yet, using the
function designed for this purpose:
> Look at the recentCards. Line 2 is the card you came from.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list