New topic: NilObjectException with XP but not Win7
<http://forums.realsoftware.com/viewtopic.php?t=48035> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message dgdavidge Post subject: NilObjectException with XP but not Win7Posted: Sat Jun 01, 2013 10:31 am Joined: Fri Jun 02, 2006 1:43 pm Posts: 208 Location: Santa Ynez, CA Sub Open() dim rs As RecordSet, f As FolderItem rs = app.MainDB.SQLSelect("SELECT * FROM Setups WHERE Name = 'pdfFolder'") if rs <> nil and rs.RecordCount > 0 Then PDFPath = rs.Field("Value").StringValue f = GetFolderItem(PDFPath) if not f.Exists Then dim f1 As FolderItem = f.Parent if not f1.Exists Then dim f2 As FolderItem = f1.Parent if not f2.Exists Then f2.CreateAsFolder f1.CreateAsFolder Else f.CreateAsFolder end if end if end if End Sub This routine works fine in Win7 but throws an nil object error at the lineif not f1.Exists ThenThis was with 2012R2.1. I rebuilt it with 2011R4.3 and the same thing still happens. The code was originally developed several years ago an an XP machine. The updated program has some features that I'm afraid won't work if I have to go back several years to fix this. The recordset returns a valid path that exists on the computer. I'm looking for suggestions for a work around. Top kermit Post subject: Re: NilObjectException with XP but not Win7Posted: Sat Jun 01, 2013 11:12 am Joined: Mon May 30, 2011 12:56 am Posts: 701 Not sure what you were hoping for but look at what the code is doing: if not f.Exists Then dim f1 As FolderItem = f.Parent So you already know f does not exist, but then you set a variable to its parent anyway? What is the parent of a non existent item? Top timhare Post subject: Re: NilObjectException with XP but not Win7Posted: Sat Jun 01, 2013 12:18 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 12385 Location: Portland, OR USA Quote:The recordset returns a valid path that exists on the computer. The nilobjectexception would indicate otherwise. Double check your path. There is something wrong with it. Top npalardy Post subject: Re: NilObjectException with XP but not Win7Posted: Sat Jun 01, 2013 12:28 pm Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7855 Location: Canada, Alberta, Near Red Deer dgdavidge wrote:Sub Open() dim rs As RecordSet, f As FolderItem rs = app.MainDB.SQLSelect("SELECT * FROM Setups WHERE Name = 'pdfFolder'") if rs <> nil and rs.RecordCount > 0 Then PDFPath = rs.Field("Value").StringValue f = GetFolderItem(PDFPath) if not f.Exists Then dim f1 As FolderItem = f.Parent if not f1.Exists Then dim f2 As FolderItem = f1.Parent if not f2.Exists Then f2.CreateAsFolder f1.CreateAsFolder Else f.CreateAsFolder end if end if end if End Sub This routine works fine in Win7 but throws an nil object error at the lineif not f1.Exists ThenThis was with 2012R2.1. I rebuilt it with 2011R4.3 and the same thing still happens. The code was originally developed several years ago an an XP machine. The updated program has some features that I'm afraid won't work if I have to go back several years to fix this. The recordset returns a valid path that exists on the computer. I'm looking for suggestions for a work around. f = GetFolderItem(PDFPath) I'd double check this line It probably just needs to be updated to f = GetFolderItem(PDFPath,Folderitem.PathTypeAbsolute) _________________ Norman Palardy (Real Software) Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 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]
