Pasing/Saving/Restoring a Card's Contents

Jan Schenkel janschenkel at yahoo.com
Fri Apr 9 13:51:46 EDT 2004


--- David Burgun <dburgun at dsl.pipex.com> wrote:
> Hi,
> 
> I am trying to work out the best way to handle
> saving a card' 
> contents. If I have a stack that is run from another
> stack in order 
> to obtain some values from the User, what is the
> best way to:
> 
> 1.  Save the State of the Card (all it's controls).
> 2.  Obtain the Values of the Controls from the
> Calling Script.
> 3.  Restore the Old Contents if the user presses
> Cancel.
> 
> I would like to be able to return the Button that
> dismissed the Stack 
> (usually OK or Cancel in this case).
> 
> In one Stack I have, I set the Script on the OK
> button to:
> 
> on mouseUp
> save this stack
> close this stack
> end mouseUp
> 
> and on the Cancel Button:
> 
> on mouseUp
> close this stack
> end mouseUp
> 
> But this seems to Save the State of the Stack/Card
> anyway, regardless 
> of whether a "save this stack" command is issued or
> not.
> 
> I had thougt of adding a Script on the preOpenCard
> handler that saves 
> the current Card to a Temp Stack and restores that
> card if the Cancel 
> Button is pressed.
> 
> Also I am not sure of the best way to access the
> values, in the case 
> a text field called "PageSize" and if the OK button
> is pressed then I 
> want to take some action, if cancel then I don't
> want to do anything.
> 
> I can't seem to find any Sample Stacks that do this.
> Any pointers 
> would be a great help.
> 
> Thanks
> Dave
> 

Hi Dave,

Have a look at the 'revert' command, as well as the
'destroyStack' property.
If neither of these can do what you want, your best
bet is to make an 'openField' handler that saves the
original data of a field in a custom property, that
way when you press cancel you can easily revert the
data in the stack in a repeat loop.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/


More information about the use-livecode mailing list