Delete Preferences file

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Delete Preferences file

Post by keram » Sun Feb 08, 2015 12:47 pm

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Delete Preferences file

Post by keram » Sun Feb 08, 2015 1:28 pm

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?
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Delete Preferences file

Post by Klaus » Sun Feb 08, 2015 1:36 pm

A simpler way for what?

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Delete Preferences file

Post by keram » Sun Feb 08, 2015 5:02 pm

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.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Delete Preferences file

Post by Klaus » Sun Feb 08, 2015 5:13 pm

keram wrote:For doing the same thing,
Problem is, I have still no idea what "doing the same thing" means"? :D

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Delete Preferences file

Post by keram » Sun Feb 08, 2015 5:19 pm

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.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Delete Preferences file

Post by jacque » Sun Feb 08, 2015 5:30 pm

Code: Select all

if there is no stack gPrefsFile then pass closeStack
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Delete Preferences file

Post by keram » Sun Feb 08, 2015 5:38 pm

Thanks Jaqueline,
That's what I was looking for.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Delete Preferences file

Post by Klaus » Sun Feb 08, 2015 6:23 pm

AHA! :D


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

Post Reply