On Jul 30, 2006, at 7:06 PM, Lennox Jacob wrote:

Hi Russ & Briman,
I have this:

Dim f As folderitem
Dim TOS As TextOutputStream

f = DesktopFolder.Child("myExpFile")
If f exists then
If f <> Nil then
TOS = f.CreateTextFile
TOS.WriteLine FirstName.Text
TOS.WriteLine LastName.Text
TOS.WriteLine Age.Text
TOS.WriteLine Address.Text
TOS.Close
end if
else
'do nothing
end if

but this does not create any file.

Because you are testing for existence(f.Exists) before the file has been created. The f.CreateTextFile creates the file. Until that line is executed the file doesn't exist. So in the code above, the existence test fails and nothing is done. The code should look more like this:

  Dim f As folderitem
  Dim TOS As TextOutputStream

  f = DesktopFolder.Child("myExpFile")
  If f <> Nil then
    TOS = f.CreateTextFile
    If TOS <> nil then
      TOS.WriteLine  FirstName.Text
      TOS.WriteLine LastName.Text
      TOS.WriteLine Age.Text
      TOS.WriteLine Address.Text
      TOS = nil
    End
  else
    'do nothing
  end if

Best,

Jack

_______________________________________________
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