Difference between revisions of "TextOutputStream.WriteLine"

From Xojo Documentation

(Example)
(Example)
Line 15: Line 15:
 
   
 
   
 
<rbcode>
 
<rbcode>
Var f As FolderItem = FolderItem.ShowSaveFileDialog(FileTypes1.Text, "MyInfo.txt")
+
Var file As FolderItem = FolderItem.ShowSaveFileDialog(FileTypes1.Text, "MyInfo.txt")
If f <> Nil Then
+
If file <> Nil Then
   Var fileStream As TextOutputStream
+
   Var output As TextOutputStream
   fileStream = TextOutputStream.Create(f)
+
   output = TextOutputStream.Create(file)
   fileStream.WriteLine(NameField.Value)
+
   output.WriteLine(NameField.Value)
   fileStream.WriteLine(AddressField.Value)
+
   output.WriteLine(AddressField.Value)
   fileStream.WriteLine(PhoneField.Value)
+
   output.WriteLine(PhoneField.Value)
   fileStream.Close
+
   output.Close
 
End If
 
End If
 
</rbcode>
 
</rbcode>

Revision as of 15:56, 3 September 2019

Method

TextOutputStream.WriteLine(Text as String)

Supported for all project types and targets.

Writes the text passed to the TextOutputStream and appends the Delimiter to the end of the line.

Example

This example displays the Save As dialog box. A text file is then created and the text properties of three TextFields are written to the new file. Finally the file is closed.

Var file As FolderItem = FolderItem.ShowSaveFileDialog(FileTypes1.Text, "MyInfo.txt")
If file <> Nil Then
Var output As TextOutputStream
output = TextOutputStream.Create(file)
output.WriteLine(NameField.Value)
output.WriteLine(AddressField.Value)
output.WriteLine(PhoneField.Value)
output.Close
End If