79 lines
2.4 KiB
HTML
79 lines
2.4 KiB
HTML
<html>
|
|
<head>
|
|
<title>Blitz3D Docs</title>
|
|
<link rel=stylesheet href=../css/commands.css type=text/css>
|
|
</head>
|
|
<body>
|
|
<h1>WriteLine$ (filehandle/stream, string$)</h1>
|
|
<h1>Parameters</h1>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
filehandle/stream = a valid variable set with the OpenFile, WriteFile command, or OpenTCPStream (v1.52+). The value returned is a text string.
|
|
<br />
|
|
string$ = valid string value.
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h1>Description</h1>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
Once you've opened a disk file (or stream) for writing, use this command to right a whole line of text to the file. Each line of text is automatically terminated with an "end-of-line" mark, consisting of a Carriage Return character followed by a LineFeed character. (i.e. 0Dh, 0Ah ) This function can be used to make plain text files.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
Streams can only be used in Blitz Basic v1.52 or greater.
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h1><a href=../2d_examples/WriteLine.bb>Example</a></h1>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
; Reading and writing a file using ReadLine$ and WriteLine functions
|
|
<br />
|
|
|
|
<br />
|
|
; Initialise some variables for the example
|
|
<br />
|
|
String1$ = "Line 1 is short"
|
|
<br />
|
|
String2$ = "Line 2 is a longer line but they can be much longer"
|
|
<br />
|
|
String3$ = "Line 3 is made up "
|
|
<br />
|
|
String4$ = "of two parts joined together."
|
|
<br />
|
|
|
|
<br />
|
|
; Open a file to write to
|
|
<br />
|
|
fileout = WriteFile("mydata.txt")
|
|
<br />
|
|
|
|
<br />
|
|
; Write the information to the file
|
|
<br />
|
|
WriteLine( fileout, String1 )
|
|
<br />
|
|
WriteLine( fileout, String2 )
|
|
<br />
|
|
WriteLine( fileout, String3 + String4)
|
|
<br />
|
|
WriteLine( fileout, "Just to show you don't have to use variables" )
|
|
<br />
|
|
|
|
<br />
|
|
; Close the file
|
|
<br />
|
|
CloseFile( fileout )
|
|
<br />
|
|
|
|
<br />
|
|
; Open the file to Read
|
|
<br />
|
|
filein = ReadFile("mydata.txt")
|
|
<br />
|
|
|
|
<br />
|
|
Read1$ = ReadLine( filein )
|
|
<br />
|
|
Read2$ = ReadLine$( filein )
|
|
<br />
|
|
Read3$ = ReadLine$( filein )
|
|
<br />
|
|
Read4$ = ReadLine$( filein )
|
|
<br />
|
|
|
|
<br />
|
|
; Close the file once reading is finished
|
|
<br />
|
|
CloseFile( filein )
|
|
<br />
|
|
|
|
<br />
|
|
Print "Lines of text read from file - mydata.txt "
|
|
<br />
|
|
Print
|
|
<br />
|
|
Print Read1
|
|
<br />
|
|
Print Read2
|
|
<br />
|
|
Print Read3
|
|
<br />
|
|
Print Read4
|
|
<br />
|
|
|
|
<br />
|
|
WaitKey()
|
|
<br />
|
|
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<a target=_top href=../index.htm>Index</a><br>
|
|
<br>
|
|
Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=WriteLine&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
|
|
</html>
|