New topic: Problem with file backup
<http://forums.realsoftware.com/viewtopic.php?t=39296> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message S.Rampling Post subject: Problem with file backupPosted: Thu Jun 02, 2011 11:15 pm Joined: Sat Jan 08, 2011 4:47 pm Posts: 308 Location: Sydney, Australia Hi, in the following code I am getting an error if a user elects to cancel.Code: dim result as integer result = msgbox ("Are you sure you want to Backup the Database ?",36) if result=6 then dim source as FolderItem = SpecialFolder.ApplicationData.Child("TKC").Child("Karts").Child("karter.rsd") dim destination as FolderItem = GetSaveFolderItem("", "karter.rsd") if source.exists = false then MsgBox "No Backup to Restore" return else source.CopyFileTo destination *************Error here ************* If they Cancel the operation. MsgBox "Your Database has been Backed Up" end end if not sure if I have the code correct, can someone point me in the right direction. Thanks Shane. _________________ Thanks to any and all who can help with my limited knowledge of Real Studio. 54YO Kart Racer from Sydney Australia Real Studio 2010r5.1 Win 7 Top timhare Post subject: Re: Problem with file backupPosted: Fri Jun 03, 2011 1:02 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 9869 Location: Portland, OR USA If the user cancels, destination will be nil. You can test for nil after the call to GetSaveFolderItem. Code:dim destination as FolderItem = GetSaveFolderItem("", "karter.rsd") if destination = nil then return if source.exists = false then ... Top mauitom Post subject: Re: Problem with file backupPosted: Fri Jun 03, 2011 1:06 am Joined: Thu Feb 16, 2006 10:04 pm Posts: 88 If you cancel during the GetSaveFolderItem operation, 'destination' will be nil. You're not checking for nil in both 'source' and 'destination' calls, which is a no-no. _________________ Thomas C. REAL.basic Blog http://bigdaddysurf.com/blog/ Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
