Page 1 of 1

Delete Preferences file

Posted: Sun Feb 08, 2015 12:47 pm
by keram
Hi,

I'm sure that this is very simple but I cannot figure how to do it:

On closing the stack I'm saving all the preferences in a file like this (in the stack script):

Code: Select all

on closeStack
   set the cCurrentView of stack gPrefsFile to gCurrentView
......
......
   save stack gPrefsFile
   close stack gPrefsFile
end closeStack
and in the button for deleting the Preferences stack is:

Code: Select all

on mouseUp
   answer question "Are you sure you want to reset all your Preferences ?" with OK and Cancel
   if it is Cancel then exit to top
   else  delete file gPrefsFile
   answer "All your Preferences have been reset. Please restart the app."


## what to put here to bypass the closeStack command in the stack script?

   end mouseUp
When the Preferences file gets deleted and the stack is about to close I'm getting of course an error because the Preferences file is not there anymore: execution error at line 493 (Chunk: can't find stack), char 25

How to get it working properly?

keram

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 1:28 pm
by keram
OK, I figured it out.

In the reset button I have now:

Code: Select all

on mouseUp
   answer question "Are you sure you want to reset selection of all your Favorites?" with OK and Cancel
   put it into gDel
   if it is Cancel then exit to top
   else  delete file gPrefsFile
   answer "All your Favorites have been reset. Please restart the app."
end mouseUp
and in the closeStack:

Code: Select all

on closeStack
   if gDel = "OK"  then pass closeStack
   else
      set the cCurrentView of stack gPrefsFile to gCurrentView
....
....
      save stack gPrefsFile
      close stack gPrefsFile
   end if
end closeStack
But there must be some simpler way as well. Any suggestions?

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 1:36 pm
by Klaus
A simpler way for what?

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 5:02 pm
by keram
For doing the same thing, just 1 line in the button script maybe?
I was trying something like this:

Code: Select all

on mouseUp
   answer question "Are you sure you want to reset selection of all your Favorites?" with OK and Cancel
   if it is Cancel then exit to top
   else
      delete file gPrefsFile
      send "pass  closeStack" to this stack in 0 sec
      answer "All your Favorites have been reset. Please restart the app."
end mouseUp
but it does not work.

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 5:13 pm
by Klaus
keram wrote:For doing the same thing,
Problem is, I have still no idea what "doing the same thing" means"? :D

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 5:19 pm
by keram
Sorry, I was not clear.
With doing the same thing, I meant deleting the Prefs file without creating an error. I thought that some short line in the button script without the need of creating another global would work.

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 5:30 pm
by jacque

Code: Select all

if there is no stack gPrefsFile then pass closeStack

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 5:38 pm
by keram
Thanks Jaqueline,
That's what I was looking for.

Re: Delete Preferences file

Posted: Sun Feb 08, 2015 6:23 pm
by Klaus
AHA! :D


Your message contains 7 characters. The minimum number of characters you need to enter is 10.