Hi Brian,

I can think of a couple of possibilities. If the 'read' code is in the open event of your window and is being executed before the 'save' code has ever been executed, you may be trying to open and read and close a file that doesn't exist. Adding one more simple check should help.

Remember that just because you get a non-Nil FolderItem that can represent a file, that does not ensure that such a file actually exists! So, before you try to open and read from the file, check that it exists.

 dim file as folderitem
 dim t as textinputstream
 file = preferencesfolder.child("SpiderWeb 2006 Preferences")

 if file<> nil  and file.Exists then // add check for file's existence
   t=file.OpenAsTextFile
   homepage.text= t.readline
   welcome.text = t.readline
   t.close
 end if

The save code should wok fine - but the following 2 lines serve no purpose and can be removed

   Dim fileStream As TextOutputStream
   //file= GetSaveFolderItem("application/text","My Info")

Hope that gets you going,
Ken

Brian Heibert wrote:

So what do I do about this?

ok so here is my code that writes a preference file it is in the Save button in my preferences window:

  dim file as folderitem
  dim t as textoutputstream
  file = PreferencesFolder.child("SpiderWeb 2006 Preferences")
  if file<> nil then
    Dim fileStream As TextOutputStream
    //file= GetSaveFolderItem("application/text","My Info")
    t=file.CreateTextFile

    t.WriteLine homepage.text
    t.WriteLine welcome.text
    t.Close
  end if

Here is the open code to open the preferences file that is in my main window
  dim file as folderitem
  dim t as textinputstream
  file = preferencesfolder.child("SpiderWeb 2006 Preferences")
  if file<> nil then
  t=file.OpenAsTextFile
  'preferences.homepage.text= t.readline
  'preferences.welcome.text = t.readline
  t.close
  end if

which I get a nilobjectexception on t.Close


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to