Dim dlg as New SaveAsDialog
Dim f as FolderItem
dlg.InitialDirectory=SpecialFolder.Documents
dlg.promptText="Prompt Text"
dlg.SuggestedFileName="Suggested Filename"
dlg.Title="Title Property"
dlg.Filter=FileTypes1.Text //defined as a file type in FileTypes1 file type set
f=dlg.ShowModal()
If f <> Nil then
//file saved
Else
//user canceled
End if
This line is returning an error.
dlg.Filter=FileTypes1.Text //defined as a file type in FileTypes1 file type set
Assuming you DO have a FileTypes1, it doesn’t have a file type called text
Go to that line, delete .text
then press . and see what file types appear.
If text is not among them, you can add the text type to your FileTypes1 file set, using the second icon from the left on the filetypes editor screen.
That gives you a list of common file types.
Choose text from the drop down list
Whenever you open a text file on one OS that was created on a different OS, you have to deal with line endings. If you’re opening the file with a Xojo app, use ReplaceLineEndings to resolve the line ending differences. Otherwise, use an app like Notepad++ that will “fix” the line endings for you.
Xojo does not automatically create pdf files. You must use some specific platform-dependent mechanism, such as Mac’s ability to save a report as pdf, or a pdf printer driver on Windows. There are also a few frameworks you can use such as DynaPDF from Monkeybread Softare or the QuickPDF library fromDebenu.
How are you creating the rtf file? Are you writing out a TextArea’s RTFData? Based on your comment about pdf, I suspect you may be confused about what the filetype does. It simply marks the file as a particular kind of file (which isn’t necessary on Windows, as it’s based solely on the extension anyway). It is up to you to ensure that the contents of the file are formatted correctly.
Yes, Tim, you are right I was/am using a wrong way to format the data correctly.
Probably, I will stick with creating a text (.TXT) for right now and will open it on a PC with the right click and selecting WordPad. I need this to work on both PC and Mac.
Probably, it will take a while for me to find a way how to get content of several TextArea fields and write it into an RTF file.
I was using the following code
Dim t As TextOutputStream
Dim d as Date
Dim dlg as New SaveAsDialog
Dim f as FolderItem
dlg.InitialDirectory=SpecialFolder.Documents
dlg.promptText="Prompt Text"
dlg.SuggestedFileName="UNTITLED FILE"
dlg.Title="Title Property"
dlg.Filter=FileTypes1.Text//defined as a file type in FileTypes1 file type set
f=dlg.ShowModal()
If f <> Nil then
//file saved
Else
//user canceled
End if
if f <> nil then // f different from nil
t = f.CreateTextFile // create file in selected location
t.WriteLine ("PROJECT REPORT")
t.WriteLine
t.WriteLine
t.WriteLine
t.WriteLine"PARAMETER 1"
t.WriteLine
t.WriteLine (TextArea1.Text) // write date from TextArea to file
t.WriteLine
t.WriteLine
t.WriteLine"PARAMETER 2"
t.WriteLine
t.WriteLine (TextArea2.text)
t.WriteLine
t.WriteLine
t.WriteLine"PARAMETER 3"
t.WriteLine
t.WriteLine (TextArea3.text)
t.WriteLine
t.WriteLine
t.WriteLine"PARAMETER 4"
t.WriteLine
t.WriteLine (TextArea4.text)
t.WriteLine
t.WriteLine
t.WriteLine"PARAMETER 5"
t.WriteLine
t.WriteLine (TextArea5.text)
t.WriteLine
t.WriteLine
t.WriteLine"PARAMETER 6"
t.WriteLine
t.WriteLine (TextArea6.text)
t.WriteLine
t.WriteLine
t.Close // close file
else
// user cancelled
end if
I will have to figure out how to do the same to write into RTF file. Like you said, I was under the impression that I only need to set the FileTypes to the appropriate extension.