Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Oct 18, 2017 6:03 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: NilObjectException with XP but not Win7
PostPosted: Sat Jun 01, 2013 10:31 am 
Offline

Joined: Fri Jun 02, 2006 1:43 pm
Posts: 209
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 line
if not f1.Exists Then
This 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
 Profile  
Reply with quote  
 Post subject: Re: NilObjectException with XP but not Win7
PostPosted: Sat Jun 01, 2013 11:12 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
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
 Profile  
Reply with quote  
 Post subject: Re: NilObjectException with XP but not Win7
PostPosted: Sat Jun 01, 2013 12:18 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
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
 Profile  
Reply with quote  
 Post subject: Re: NilObjectException with XP but not Win7
PostPosted: Sat Jun 01, 2013 12:28 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
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 line
if not f1.Exists Then
This 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
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group