<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - LINE INPUT
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="like+en">Previous</a>&nbsp;
<a href="link+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
LINE INPUT
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><b>LINE INPUT</b> [ <b>#</b> <u>hStream</u> <b>,</b> ] <u>sVariable</u></pre><p>

Reads an entire line of text from the text <a href="../def/stream+en">stream</a> <u>Stream</u> into a <a href="../comp/gb/string+en">String</a> <u>sVariable</u>.
<p>
If the <a href="../def/stream+en">stream</a> <u>hStream</u> is not specified, then the standard input is used.
<p>
The entire line is read, except the end-of-line delimiter.
<p>
The end-of-line delimiter can be defined with the
<a href="../comp/gb/stream+en">Stream</a>.<a href="../comp/gb/stream/endofline+en">EndOfLine</a> property.
It is <a href="../comp/gb/gb+en">gb</a>.<a href="../comp/gb/gb/unix+en">Unix</a> by default,
which selects a single <tt><a href="chr+en">Chr$</a>(10)</tt> character.
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
Use only the correct end-of-line delimiter.
</td></tr></table></div>
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
Do not use this instruction to read from binary files, because you will lose the linefeed characters. Use <a href="read+en">READ</a> instead.
</td></tr></table></div>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">DIM hFile AS Stream
DIM sOneLine AS String

' Print a file to standard output
hFile = OPEN &quot;/etc/hosts&quot; FOR INPUT

WHILE NOT Eof(hFile)
  LINE INPUT #hFile, sOneLine
  PRINT sOneLine
WEND

CLOSE #hFile</pre>
<p>

<hr><b>See also</b><br>
<a href="../cat/stream+en">Stream &amp; Input/Output functions</a>&nbsp; Stream.<a href="../comp/gb/stream/endofline+en">EndOfLine</a>&nbsp;

</div>
</body>
</html>

