You might want to add a handler for NilObjectExceptions, because this
code will eventually toss one :)
GetFolderItem can return nil for reasons beyond your control; the
same is true for all FolderItem methods that open files for reading
or writing.
Charles Yeomans
On Jul 30, 2006, at 11:03 PM, Kevin Mahler wrote:
I use the following in most my projects:
----------------------------------------------------------------------
-----------
Method Name: AppendFile
Parameters: FilePath As String,Data As String,Header As String
Return Type: N/A
Dim TD,cr As String
Dim file As FolderItem
Dim fileStream As TextOutputStream
cr = chr(13)
file=GetFolderItem(filePath)
if file.exists then
TD = Data
else
if Header <> "" then
TD = Header + cr + Data
else
TD = Data
end if
end if
fileStream=file.AppendToTextFile
file.MacCreator = "XCEL"
file.MacType = "TEXT"
fileStream.WriteLine TD
fileStream.Close
----------------------------------------------------------------------
-------------
Method Name: SaveFile
Parameters: FilePath As String,Data As String
Return Type: N/A
Dim file As FolderItem
Dim fileStream As TextOutputStream
if (len(filePath) > 2) then 'Sometimes the path may seem empty
but a tab or carriage return or some other invisible character gets in
file=GetFolderItem(filePath) 'used to get the file Info
file.MacCreator = "XCEL"
file.MacType = "TEXT"
fileStream=file.CreateTextFile
fileStream.Write Data
fileStream.Close
else
file=GetSaveFolderItem("","Save file as...") 'if a file path is
empty bring up dialog
If file<>Nil then
file.MacCreator = "XCEL"
file.MacType = "TEXT"
fileStream=file.CreateTextFile
fileStream.Write Data
fileStream.Close
end if
end if
----------------------------------------------------------------------
-------------
I like to open my files in Excel but you can comment out the
MacCreator and MacType to create a vanilla text file.
hope it helps any,
Kevin
----------------------------------------------------------------------
-------------
On Jul 30, 2006, at 5:42 PM, Lennox Jacob wrote:
Hello,
I have a Pushbutton named Export, which,when clicked, I would like
it to export data (EF1.text, EF2.text, EF3.text, EF4.text) from
some chosen editfields (EF1, EF2, EF3, EF4) to a new text file on
the desktop.
Not Save or SaveAs like when the whole document is saved.
How is that done?
Thanks.
Lennox.
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.
Great rates starting at 1ยข/min.
_______________________________________________
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>
_______________________________________________
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>
_______________________________________________
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>