Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/doc/ref/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 75 kB image not shown  

Quelle  chap10.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/GAP/doc/ref/chap10.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ref) - Chapter 10: Streams</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap10"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href=

<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap9.html">[Previous Chapter]</a>    <a href="chap11.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a hrefcode="func>Ring/>,for  collection  ahref=chap56_mj.tmlX820B172A860A5B1A>56.-<a><br /
<p><a id="X839725177BF8B5B4" name="X839725177BF8B5B4"></a></p>
<div class="ChapSects"><a href="chap10.html#X839725177BF8B5B4">10 <span class="Heading">Streams</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X7F89070B7CF52DE0">10.1 <span class="Heading">Categories for Streams and the StreamsFamily</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7E974B96785E91A8">10.1-1 IsStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7FE4096F8497B7F2">10.1-2 IsClosedStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7FB4391283847C3A">10.1-3 IsInputStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7C8956BB7FE2A89C">10.1-4 IsInputTextStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7DCD6ADC86CF2472">10.1-5 IsInputTextNone</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7D357CA07E7B1E78">10.1-6 IsOutputStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X8248B8A4844CB8AB">10.1-7 IsOutputTextStream< classfunc</code.#7E7B1B727EA434CF.-<a  br/
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7C89CDD47E33E741">10.1-8 IsOutputTextNone</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7F0F9DD47DE16DAB">10.1-9 StreamsFamily</a></span>
</></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X8461F4DF7FC20C4B">10.2 <span class="Heading">Operations applicable to All Streams</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X786E5520803FDE00">10.2-1 CloseStream class=func>RingHomomorphismByImagescode  a.html">5682/><br />
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7F0459287E717456">10.2-2 FileDescriptorOfStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X87BC257A78F96828">10.2-3 UNIXSelect</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X7D1D33A587BFD93D">10.3 <span class="Heading">Operations for Input Streams</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7A5DC83D7E295568">10.3-1 Read</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7D62F2877F0E45A7">10.3-2 ReadAsFunction</a></span>
<span=""><br >span ="nocss"&; /pan>< ="chap10.tml#X79E1E6A57AE58BB8>. <a<span
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7D2CA44C7D110C4F">10.3-4 ReadLine</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X85C603D7867430D0">10.3-5 ReadAll</a></span>
<span class="ContSS"><br /><span class="nocss">  class"unc"RingWithOne/code> fora collection  <href.#X80942A318417366E"5632<a  br >
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7B646FA3860521D1">10.3-7 PositionStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7A777E1186EB330B">10.3-8 RewindStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7A60AD8C7E0D0507">10.3-9 SeekPositionStream</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X7F454EB286947C85">10.4 <span class="Heading">Operations for Output Streams</span></a>
</span>
<div class="ContSSBlock">
<span="ContSS"<r />span"" <spanhref.htmlX7D37C7A07E9C319C"10.-1WriteByte<a>span
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X79FA85498596CC99">10.4-2 WriteLine</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X78C113917936058D">10.4-3 WriteAll</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7F4E090C86AACCF7">10.4-4 <span class="Heading">PrintTo and AppendTo (for streams)</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7BF4E44C7D51E085">10.4-5 LogTo</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10&bsp;   for a   <a href=".htmlX78199B6B84A017B9"29.-/> <r /
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X834A6DD17B0E2062">10.4-7 OutputLogTo</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X8663FCD57E8BC390">10.4-8 SetPrintFormattingStatus</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X80B5F2E4856D8980">10.5 <span class="Heading">File Streams</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X8343D04981128784">10.5-1 InputTextFile</a></span>
<span="ContSS"><br >span="nocss"> </><a href=chap10"10-2 OutputTextFile</>/span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X808348977A05477A">10.6 <span class="Heading">User Streams</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X83531E4C7C53544F; nbsp&bsp;of an integer modulo another  <a ="chap15_mj#X83E3ED577B7A04ED1543/>< /
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X83E5FC9487766297">10.6-2 OutputTextUser</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7DAF5B7085F4F893">10.6-3 InputFromUser</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X8028E1D87CE2F059">10.7 <span class="Heading">String Streams</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7ABABCDF7ED81F7F">10.7-1 InputTextString</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7FEDA5167979B74D">10.7-2 OutputTextString</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10code class="funccode<ahref.#X83D9B5C87EEA2A772-/a> < java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X82822D3D8339F635">10.8-1 IsInputOutputStream</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X820799A3824684AC">10.8-2 InputOutputLocalProcess</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7CDF48447E823977">10.8-3 ReadAllLine</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a of  < ="chap18_mjhtmlX8631458886314588">18.-/><br /
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7C732324806716C6">10.9-1 InputTextNone</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X7CC5C1FC81715E38">10.9-2 OutputTextNone</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X7CB5832F8721ADF3">10.10 <span class="Heading">Handling of Streams in the Background</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X81FB42517E3EA96D">10.10-1 InstallCharReadHookFunc</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X8492474C7A0B10AD">10.10-2 UnInstallCharReadHookFunc</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X848DD7DC79363341">10.11 <span class="Heading">Comma separated files</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X86FDC1EF82CAD2DA">10.11-1 ReadCSV</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X8779DAC585E05A47">10.11-2 PrintCSV</a></span>
</div>codeclass=func</>  a href=chap15_mj.html">15.-<a  br /
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap10.html#X87396F857ADA3F97">10.12 <span class="Heading">Opening files in the Operating System</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap10.html#X86B98E287AD42BE8">10.12-1 OpenExternal</a></span>
</div></div>
</div>

<h3>10 <span class="Heading">Streams</span></h3>

<p><em>Streams</em> provide flexible access to <strong class="pkg">GAP</strong>'s input and output processing. An <em>input stream</em> takes characters from some source and delivers them to <strong class="pkg">GAP</strong> which <em>reads</em> them from the stream. When an input stream has delivered all characters it is at <code class="code">end-of-stream</code>. An <em>output stream</em> receives characters from <strong class="pkg">GAP</strong> which <em>writes</em> them to the stream, and delivers them to some destination.</p>

<p>A major use of streams is to provide efficient and flexible access to files. Files can be read and written using <code class="func">Read</code> (<a href="chap9.html#X8373AC6B7D5F9167"><span class="RefLink">9.8-1</span></a>) and <code class="func">AppendTo class"RoundCyc</code>href=".html">1819/  br /

<p>Any stream is either a <em>text stream</em>, which translates the <code class="code">end-of-line</code> character (<code class="code">\n</code>) torow spaces  < href"chap61_mj.html#X7D937EBC7DE2819B">.<a  br>

<p>Whereas it is cheap to append to a stream, streams do consume system resources, and only a limited number can be open at any time, therefore it is necessary to close a stream as soon as possible using <code class="func">CloseStream</code>< class=func</code> ahref=chap51_mjhtml">51.-<a  br/>

<p><a id="X7F89070B7CF52DE0" name="X7F89070B7CF52DE0"></a></p>

<h4>10.1 <span class="Heading">Categories for Streams and the StreamsFamily</span></h4>

<p><a id="X7E974B96785E91A8" name="X7E974B96785E91A8"></a></p>

<h5>10.1-1 IsStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsStream</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>Streams are <strong class="pkg">GAP</strong> objects and all open streams, inputoutput, text and binary, lie in this category.</p>

<p><a idcode="func"RREF  < href.htmlX7BA26C3387AB434E>24.-/> < >

<h5>10.1-2 IsClosedStream</h5>

<ivclass="unc"<able class"func" width100%<>tdtdleft"<odeclass"">#227;IsClosedStream/code(<var class=Arg">bj<var><td="tdright"(nbspnbsp>/r>table
<p>When a stream is closed, its type changes to lie in <code class="func">IsClosedStream</code>. This category is used to install methods that trap accesses to closed streams.</p>

<p><a id="X7FB4391283847C3A" name="X7FB4391283847C3A"></a></p>

<h5>10.1-3 IsInputStream</h5>

class"unc"table="unc"width"100">tr>td="tdleft">< class"#8227 IsInputStream</code>(<=/var>)<td<d ="tdright&; >/tr<div
<p>All input streams lie in this category, and support input operations such as <code class="func">ReadByte</code> (<a href="chap10.html#X79E1E6A57AE58BB8"><span class="RefLink">10.3-3</span></a>) (see <a href="chap10.html#X7D1D33A587BFD93D"><span class="RefLink">10.3</span></a>)</p>

<p><a id="X7C8956BB7FE2A89C" name="X7C8956BB7FE2A89C"></a></p>

<h5>10.1-4 IsInputTextStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsInputTextStream</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>All <em>text</eminput streams lie in this category. They translate new-line characters read.</p>

<p><a id="X7DCD6ADC86CF2472" name="X7DCD6ADC86CF2472"></a></p>

<h5>10.1-5 IsInputTextNone</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsInputTextNone</code>( <var class="Arg">obj</var> )</tdcode ="func"SameBlock<code> ahrefchap71_mj">.-<a   /
<p>It is convenient to use a category to distinguish dummy streams (see <a href="chap10.html#X8724699C7D67BA47"><span class="RefLink">10.9</span></a>) from others  <ahref.

<p><a id="X7D357CA07E7B1E78" name="X7D357CA07E7B1E78"></a></p>

<h5>10.1-6 IsOutputStream</h5>

<div class="func"><table classcode="">SaveCommandLineHistory/code> < href=chap6_mj.>.-<><br>
<p>All output streams lie in this category and support basic operations such as <code class="func">WriteByte</code> (<a href="chap10.html#X7D37C7A07E9C319C"><span class="RefLink">10.4-1</span></a>) (see Section <a href="chap10.html#X7F454EB286947C85"><span class="RefLink">10.4</span></a>).</p>

<p><a id="X8248B8A4844CB8AB" name="X8248B8A4844CB8AB"></a></p>

<h5>10.1-7 IsOutputTextStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsOutputTextStream</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category code="func>aveWorkspace/  ahrefchap3_mj.html#">33-<a  brjava.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
<p>All <em>text</emoutput streams lie in this category and translate new-line characters on output.</p>

<p><a id="X7C89CDD47E33E741" name="X7C89CDD47E33E741"></a></p>

<h5>10.1-8 IsOutputTextNone</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class;nbsp;; &nbsp;two objectsa ="chap26_mjhtmlX85A815CA790094CC">682/>< /
<p>It is convenient to use a category to distinguish dummy streams (see <a href="chap10.html#X8724699C7D67BA47"><span class="RefLink">10.9</span></a>) from others. Other distinctions are usually made using representations</p>

<p><a id="X7F0F9DD47DE16DAB" name="X7F0F9DD47DE16DAB"></a></p>

<h5>10.1-9 StreamsFamily</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; StreamsFamily</code></td><td class="tdright">( family )</Schreier-ims, random  < hrefhtml>43./>< />
<p>All streams lie in the <code class="func">StreamsFamily</code>.</p>

<p><a id="X8461F4DF7FC20C4B" name="X8461F4DF7FC20C4B"></a></p>

<h4>10.2 <span class multiplierahref.#X792BC39D7CEB1D27.-<a> br>

<p><a id="X786E5520803FDE00" name="X786E5520803FDE00"></a></p>

<h5>10.2-1 CloseStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; CloseStream</code>( <var class="Arg">stream</varcodeclassSchurCover</ode> <href.tml"39242/><br/
<p>In order to preserve system resources and to flush output streams every stream should be closed as soon as it is no longer used using <code class="func"><ode=func</code>  ahrefhtml">39.4-<a><br /

<p>It is an error to try to read characters from or write characters to a closed stream. Closing a stream tells the <strong class="pkg">GAP</strong> kernel and/or the operating system kernel that the file is no longer needed. This may be necessary because the <strong class="pkg">GAP</strong> scope  <hrefhtml">.8/>< /

<p><a id="X7F0459287E717456" name="X7F0459287E717456"></a></p>

<h5>10.2-2 FileDescriptorOfStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class></code>< href".html#X8151581186F75BA3">.-<a   /
<p>returns the UNIX file descriptor of the underlying file. This is mainly useful for the <code class="func">UNIXSelect</code> (<a href="chap10.html#X87BC257A78F96828"><span class="RefLink">10.2-3</span></a>) function call. This is as of now only available on UNIX-like operating systems and only for streams to local processes and local files.</p>

<p><a id="X87BC257A78F96828" name="X87BC257A78F96828"></a></p>

<h5>10.2-3 UNIXSelect</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; UNIXSelect</code>( <var class="Arg">inlist</var>, <var class="Arg">outlist</var>, <var class="Arg">exclist</var>, <var class="Arg">timeoutsec</var>, <var class="Arg">timeoutusec</var> )</td><td class="tdright">( function )</td></tr><< class>ecHMSM/>< href".html#D77C81100B">.<a  br>
<p>makes the UNIX C-library function <code class="code">select</code> accessible from <strong class="pkg">GAP</strong> for streams. The functionality is as described in the man page (see UNIX file descriptors (integers) for streams. They can be obtained via <code class="func">FileDescriptorOfStream</code> (<a href="chap10.html#X7F0459287E717456"><span class="RefLink">10.2-2</span></a>) for streams to local processes and to local files. The argument <var class="Arg">timeoutsec</var> is a timeout in seconds as in the <code class="code">struct timeval</code> on the

<p>The return value is the number of streams that are ready, this may be 0 if a timeout was specified. All file descriptors in the three lists that are not yet ready are replaced by <code class="keyw">fail</code> in this function. So the lists are changed!</p>

<p>This function is only available if your operating system has <code class="code">select</code>, which is detected during compilation of <strong class="pkg">GAP</strong>.</p>

<p><a id="X7D1D33A587BFD93D" name="X7D1D33A587BFD93D"></a></p>

<h4>10.3 <span class="Heading">Operations for Input Streams</span></h4>

<p>Two operations</code for  automorphismsagroup href.htmlX7D905A5778D7ACDE>.2-<a> < >

<p>Three further operations: <code class="func">ReadByte</code> (<a href="chap10.html#X79E1E6A57AE58BB8"><span class="RefLink">10.3-3</span></a>), <code class="func">ReadLine</&bsp;nbspnbsp;for group, and  <a="chap49_mj.htmlX7D905A5778D7ACDE">49.-<a  br>

<p>Additional operations for input streams support detection of end of stream, and (for those streams for which it is appropriate) random access to the dataclass=func"SemiEchelonBasis<><ahref".html">19-<a> br /

<p><a id="X7A5DC83D7E295568" name="X7A5DC83D7E295568"></a></p>

<h5>10.3-1 Read</h5>

<code class=func>SemiEchelonBasisNC>< href.html">619-/>   /
<p>reads the input-text-stream as input until <code class="code">end-of-stream</code> occurs. See <a href="chap9.html#X81A0A4FF842B039B"><span class="RefLink">9.8</span></a> for details.</p>

<p><a id="X7D62F2877F0E45A7" name="X7D62F2877F0E45A7"></a></p>

<h5>10.3-2 ReadAsFunction class"SemiEchelonMat/><ahref"hap24_mjhtml".-<a> <r/

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ReadAsFunction</code>( <var class="Arg">input-text-stream</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>reads the input-text-stream as function and returns this function. See <a href="chap9.html#X81A0A4FF842B039B"><span class="RefLink">9.8</span></a> for details.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"># a function with local `a' does not change the global one</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">a := 1;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">i := InputTextString( "local a; a := 10; return a*10;" );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadAsFunction(i)();</span>
100
<span class="GAPprompt">gap>class"SemiEchelonMatsDestructive</>  ahref"hap24_mjX808F493B839BC7A6.-<a><br >
1
<span class="GAPprompt">gap></span> <span class="GAPinput"># reading it via `Read' does</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">i := InputTextString( "a := 10;" );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Read(i);</span>
span="GAPprompt>ap&t;/pan>< class=GAPinput"a;span
10
</pre></div>

<p><a id="X79E1E6A57AE58BB8" name="X79E1E6A57AE58BB8"></a></p>

<h5>10.3-3 ReadByte</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ReadByte</codesemigroup  <hrefhtml"511-<a> < >
<p><code class="func">ReadByte</code> returns one character (returned as integer) from the input stream <var class="Arg">input-stream</var>. <code class="func">ReadByte</code> returns <code class="keyw">fail</code> if there is no character available, in particular if it iscode ="func>emigroup/ode,for    ahrefchap51_mjhtml#X7F55D28F819B2817511-<a  br /java.lang.StringIndexOutOfBoundsException: Index 110 out of bounds for length 110

<p>If <var class="Arg">input-stream</var> is the input stream of a input/output process, <code class="func">ReadByte</code> may also return <code class="keyw">fail</code> if no byte is currently available.</p>

<p><code class="func">ReadByte</code> is onTable>< href=chap51_mj.htmlX7E67E13F7A01F8D3>51111<a  br/

<p><code class="func">ReadByte</code> will wait (block) until a byte is available. For instance if the stream is a connection to another process, it will wait for the process to output a byte.</p>

<p><a id ="func>SemigroupIdealByGenerators</code>  <a href="chap51_mj.html#X7D5CEE4D7D4318ED">51.5-1</a>  <br />

<h5>10.3-4 ReadLine</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ReadLine</code>( <var class="Arg">input-stream</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">ReadLine</code> returns one line (returned as string <em>with</em> the newline) from the input stream <var class="Arg">input-stream</var>. <code class="func">ReadLine</code> reads in the input until a newline 

<p>If <var class="Arg">input-stream</var> is the input stream of a input/output process, <code class="func">ReadLine</code> may also return <code class="keyw">fail</code> or return an incomplete line if the other process has not yet written any more. It will always wait (block) for at least one byte to be available, but will then return as much input as is available, up to a limit of one line.</p>

<p>A default method is supplied for <code class="func">ReadLine</code> which simply calls <code class="func">ReadByte</code> (<a href="chap10.html#X79E1E6A57AE58BB8"><span class="RefLink">10.3-3</span></a>) repeatedly. This is only safe for streams that cannot block. The kernel uses calls to <code class="func">ReadLine</code> to supply input to the parser when reading from a stream.</p>

<p><a id="X85C603D7867430D0" name="X85C603D7867430D0"></a></p>

<h5>10.3-5 ReadAll</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ReadAll</code>( <var class="Arg">input-stream</var>[, <var class="Arg">limit</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">ReadAll;    <a ="chap16_mj.tml#X7830A03181D67192>632/>< >

<p>With a second argument, at most <var class="Arg">limit</var> bytes will be returned. Depending on the stream a bounded number of additional bytes may have been read into an internal buffer.</p>

<p>A default method is supplied for <code class="func">ReadAll</code> which simply calls <code class="func">ReadLine</code> (<a href="chap10.html#X7D2CA44C7D110C4F"><span class="RefLink">10.3-4</span></a>) repeatedly. Thisclass>et<code<hrefhtml">.7/> <r/


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">i := InputTextString difference,of   <ahref.#825AC0F07E010B07.4/> < />
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadByte(i);</span>
49
<span class="GAPprompt">gap></span> <span class="GAPinput">CHAR_INT(last);</span>
'1'
<span class=GAPprompt"gap&t;/pan>spanclass=GAPinput"ReadLine<span
"Hallo\n"
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadLine(i);</span>
"You\n"
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadLine(i);</span>
"1"
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadLine(<"">SetAllBlist><a href="hap22_mj.tml#7E9F6C197A79098F"224-/>< />
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadAll(i);</span>
""
<span class="GAPprompt">gap></span> <span class="GAPinput">RewindStream(i);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadAll(i);</span>
"1Hallo\nYou\n1"
</pre></div>

<p><a id="X81D4FB097F631A79" name="X81D4FB097F631A79"></a></p>

<h5>10.3-6 IsEndOfStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsEndOfStream</code>( <var class="Arg">input-stream</var> )</td><td class="tdright">( operation )</td></tr><< class=func"SetCommutator/> ahref=chap46_mj.tml#7B25997C7DF92B6D"46.-/>  < /
<p><code class="func">IsEndOfStream</code> returns <code class="keyw">true</code> if the input stream is at <em>end-of-stream</em>, and <code class="keyw">false</code> otherwise. Note that <code class="func">IsEndOfStream</code> might return <code class="keyw">false</code> even if the next <code class="func">ReadByte</code> (<a href="chap10.html#X79E1E6A57AE58BB8"><span class="RefLink">10.3-3</span></a>) failscode="">SetCrystGroupDefaultActiona=".html#X792D237385977BE6">7-  br>

<p><a id="X7B646FA3860521D1" name="X7B646FA3860521D1"></a></p>

<h5>10.3-7 PositionStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PositionStream</code>( <var class=func"SetDefaultInfoOutput<> ahref=chap7_mj.tml#800234B5815CAC97">.4-<a><br /
<p>Some input streams, such as string streams and file streams attached to disk files, support a form of random access by way of the operations <code class= class></code  a ="chap86_mjhtml#X7B9748ED7BAAA379">8621/  br

<p>If this is not possible, for example for an input stream attached to standard input (normally the keyboard), then <code class="keyw">fail</code> is returned</p>

<p><a id="X7A777E1186EB330B" name="X7A777E1186EB330B"></a></p>

<h5>10.3-8 RewindStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; RewindStream</code>( <var class="Arg">input-stream</var> )</td><td class="tdright">( operation )</td></tr></table><< class></codeahref".#X7C92D53E7920CE02".3/  br
<ode class=func">etFloats<code> ahref=chap19_mj.tml#7A962B0983FA66E8"19.-/a> < />

<p>A default method implements RewindStream using <code class="func">SeekPositionStream</code> (<a href="chap10.html#X7A60AD8C7E0D0507"><span class="RefLink">10.3-9</span></a>).</p>

<p><a id="X7A60AD8C7E0D0507" name="X7A60AD8C7E0D0507"></a></p>

<h5>10.3-9 SeekPositionStream</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; SeekPositionStream</code>( <var class="Arg">input-stream</var>, <var class="Arg">pos</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">SeekPositionStream</code> attempts to rewind or wind forward an input stream to the specified position. This is not possible for all streams. It returns <code class="keyw">true</code> if the seek is successful and <code class="keyw">fail</code> otherwise.</p>

<p><a id="X7F454EB286947C85" name="X7F454EB286947C85"></a></p>

<h4>10.4 <span class="Heading">Operations for Output Streams</span></h4>

<>< id"X7D37C7A07E9C319C" ="X7D37C7A07E9C319C"/a><p>

<h5>10.4-1 WriteByte</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; WriteByte</code>( <var class="Arg">output-stream</var>, <var class="Arg">byte</var> )</td><td class="tdright">( operation )</td></tr></table></div ="">SetInfoLevel>ahrefchap7_mjX7A43B9E68765EE9E4<a  brjava.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
<p>writes the next character (given as <em>integer</em>) to the output stream <var class="Arg">output-stream</var>. The function returns <code class="keyw">true</code> if the write succeeds and <code class="keyw">fail</code> otherwise.</p>

<p><code class="func">WriteByte</code> is the basic operation for output streams. If a <code class="func">WriteByte</code> method is installed for a user-defined type of stream, then all the other output stream operations will work (although possibly not at peak efficiency).</p>

<p><a id="X79FA85498596CC99" name="X79FA85498596CC99"></a></p>

<h5>10.4-2 WriteLine</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; WriteLine</code>( <var class="Arg">output-stream</var>, <var class="Arg">string</var> )</td><td class="tdright">( operation )codeclass=func>etPackagePath><a href.htmlX858E8985840BFA72>76.3/>< >
<p>appends <var class="Arg">string</var> to <var class="Arg">output-stream</var>. A final newline is written. The class"SetParentcode  <href"hap31_mjhtmlX7BC856CC7F116BB0>.-<a  <r /

<p>A default method is installed which implements <code class="func">WriteLine</code> by repeated calls to <code class="func">WriteByte</code> (<a href="chap10.html#X7D37C7A07E9C319C"><span class="RefLink">10.4-1</span></a>).</p>

<p><a id="X78C113917936058D" name="X78C113917936058D"></a></p>

<h5>10.4-3 WriteAll</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code classclass=func"SetPrintFormattingStatus<code  a href".html">.-<a> br /
<p>appends <var class="Arg">string</var> to <var class="Arg">output-stream</var>. No final newline is written. The function returns <code class="keyw">true</code> if the write succeeds and <code class="keyw">fail</code> otherwise. It will block as long as class=func</code>< ="chap7_mj.html#X7D8968FC7E24A4E5">7.11/>< /

<p>A default method is installed which implements <code class="func">WriteAll<ode="func">etReducedMultiplication</ode> < ="chap47_mjhtml#82CB9EC982CDAEAC">.-<>  < >

<p>When printing or appending to a stream (using <code class="func">PrintTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), or <code class="func">AppendTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="Sets  <a href="chap21_mj#X7B256AE5780F140A.a  < /


<div class="example"><pre>
<span="GAPprompt">gap&t<spanspan ="GAPinput" : "; a :=OutputTextString(str,rue);;</>
<span class="GAPprompt">gap></span> <span class="GAPinput">WriteByte(a,INT_CHAR('H'));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">WriteLine(a,"allo");</span>
true
<span""gapspanclass">WriteAlla,You\n")<span
true
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(a);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(str);</span>
Hallo
You
</pre></div>

<p><a id="X7F4E090C86AACCF7" name="X7F4E090C86AACCF7"></a></p>

<h5>10.4-4 <span class="Heading">PrintTo and AppendTo (for streams)</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; PrintTo</code>( <var class="Arg">output-stream</var>, <var class="Arg">arg1</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; AppendTo</code>( <var class="Arg">output-stream</var>, <var class="Arg">arg1</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>These functions work like <code class="func">Print</code> (<a href="chap6.html#X7AFA64D97A1F39A3"><span class="RefLink">6.3-4</span></a>), except that the output is appended to the output stream <var class="Arg">output-stream</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">str := "";; a := OutputTextString(str,true);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">AppendTo( a, (1,2,3), ":", Z(3) );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(a);</span>
<pan=GAPprompt><spanspan="GAPinput>(str \n );</>
(1,2,3):Z(3)
</pre></div>

<p><a id="X7BF4E44C7D51E085" name="X7BF4E44C7D51E085"></a></p>

<h5>10.4-5 LogTo</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; LogTo< class"ShallowCopy/>,for lists  < ="chap21_mj#ED7C0738495556F7<
<p>causes the subsequent interaction to be logged to the output stream <var class="Arg">stream</var>. It works in precisely the same way as it does for files (see <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.8-4</span></a>)).</p>

<p><a id="X7B843516796B2A18" name="X7B843516796B2A18"></a></p>

<h5>10.4-6 InputLogTo</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; InputLogTo</code>( <var class="Arg">stream</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>causes the subsequent input to be logged to the output stream <var class="Arg">stream</var>. It works just like it does for files (see <code class="func">InputLogTo</code> (<a href="chap9.html#X7CAB119378B075B7"><span class="RefLink">9.8-5</span></a>)).</p>

<>aid" =X834A6DD17B0E2062"></>/p>

<h5>10.4-7 OutputLogTo</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OutputLogTo</code>( <var class="Arg">stream</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>causes the subsequent output to be logged to the output<code class="">hortBanners<code  <a href="hap3_mjhtml#X870A11E7864F9CA7>3.2-/>br/java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99

<p><a id="X8663FCD57E8BC390" name="X8663FCD57E8BC390"></a></p>

<h5>10.4-8 SetPrintFormattingStatus</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; SetPrintFormattingStatus</code>( <var class="Arg">stream</var>, <var class="Arg">newstatus</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<iv ="func><table class=func"width%>tr classtdleft class=func8227 PrintFormattingStatus<code(var class"stream/var></>tdclass=tdright>&;operation&;<td>/>/able<div>
<p>When text is being sent to an output text stream via <code class="func">PrintTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), <code class="func">AppendTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), <code class="func">LogTo</code> (<a href="chap10.html#X7BF4E44C7D51E085"><span class="RefLink">10.4-5</span></a>), etc., it is by default formatted just as it would be were it being printed to the screen. Thus, it is broken into lines of reasonable length at (where possible) sensible places, lines code=func/codeahrefhtml>.-/>br>

<p><code class="func">SetPrintFormattingStatus</code> sets whether output sent to the output stream <var class="Arg">stream</var> via <code class="func">PrintTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), <code class="func">AppendTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), etc. will be formatted with line breaks and indentation. If the second argument <var class="Arg">newstatus ="func></code>  ahref="chap7_mjhtml">711/>< /

<p><code class="func">PrintFormattingStatus</code> returns <code class="keyw">true</code> if output sent to the output text stream <var class="Arg">stream</var> via <code class="func">PrintTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), <code class="func">AppendTo</code> (<a href="chap9.html#X86956C577FFEE1F9"><span class="RefLink">9.8-3</span></a>), etc. will be formatted with line breaks and indentation, and <code class="keyw">false</code> otherwise. For non-text streams, it returns <code class="keyw">false</code>. If as argument <var class="Arg">stream</var> the string <code class="code">"*stdout*"</code> is given, these functions refer to the formatting status of the standard output (so usually the user's<code class="func">ShowDetails</code  ahref"chap7_mj.htmlX7D25D904800D5CBA">713<a  <r /

<p>Similarly, the string <code class="code">"*errout*"</code> refers to the formatting status of the standard error output, which influences how error messages are printed.</p>

<p>These functions do not influence the behaviour of the low level functions <code class="func">WriteByte</code> (<a href="chap10.html#X7D37C7A07E9C319C"><span class="RefLink">10.4-1</span></a>), <code class="func">WriteLine</code> (<a href="chap10.html#X79FA85498596CC99"><span class="RefLink"><code class=func>ShowMethods</code>  <a hrefchap7_mj#X7F6996CA872478B87.4</><br/>


<div class="example"><pre>
<span class="GAPprompt">gapcode class="">ShowMultiplicationTable>a href".html#8142D994794B700A">5542/> < /
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintTo(str,Primes{[1..30]});</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">s;</span>
"[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,\
 \n  67717379838997101103107109113 ]"
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(s,"\n");</span>
23571113171923293137414347535961,
  67717379838997101103107109113 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">SetPrintFormattingStatus(str, false);</span>
< classGAPpromptgap&;/panspan ="GAPinput>(strPrimes1.30};/>
<span class="GAPprompt">gap></span> <span class="GAPinput">s;</span>
"[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,\
 \n  67717379838997101103107109113 ][ 2357\
1113171923293137414347535961677173, \
79838997101103107109113 ]"
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(s,"\n");</span>
23571113171923293137414347535961,
  67717379838997101103107109113 ][ 23571\
11317192329313741434753596167717379,\
 838997101103107109113 ]
</pre></div>

<p><a id="X80B5F2E4856D8980" name="X80B5F2E4856D8980"></a></p>

<h4>10.5 <span class="Heading">File Streams</span></h4>

<p>File streams are streams associated with files. An input file stream reads the characters it delivers from a file, an output file stream prints the characters it receives to a file. The following functions can be used to create such streams. They return <code class="keyw">fail</code> if an error occurred, in this case <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>

<p><a id="X8343D04981128784" name="X8343D04981128784"></a></p>

<h5>10.5-1 InputTextFile</h5>

< =func>table"width"100"<>td class=tdleft"><codeclass=func8227;InputTextFile<codevar="rg>filenamevar <td<td class="dright;operation;)</></div>
<p><code class="code">InputTextFile( <var class="Arg">filename</var> )</code> < class"func>ShrinkRowVector<code> < href="chap23_mjhtmlX78951C0E86D857B5> java.lang.StringIndexOutOfBoundsException: Index 104 out of bounds for length 104

<p><code class="code">InputTextFile</code> is designed for use with text files and automatically handles windows-style line endings. This means it should <em>not</em> be used for binary data. The <code class="func">IO_File</code> (<a href="../../pkg/io/doc/chap4.html#X7EC160D07E815DBB"><span class="RefLink">IO: IO_File mode</span></a>) function from the <strong class="pkg">IO</strong> package should be used to access binary data.</p>

<p>Note: At most 256 files may be open for reading or writing at the same time. Use <code class="func">CloseStream</code> (<a href="chap10.html#X786E5520803FDE00"><span class="RefLink">10.2-1</span></a>) to close the input stream once you have finished reading from it.</p>

<< ="X83F53291822B7126nameX83F53291822B7126>a></

<h5>10.5-2 OutputTextFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OutputTextFile</code>( <var class="Arg">filename</var>, <var class="Arg">append</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OutputGzipFile</code>( <var class="Arg">filename</var>, <var class="Arg">append</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="code">OutputTextFile( <var class="Arg">filename</var>, <var class="Arg">append</var> )</code> returns an output stream in the category <code class="code">IsOutputTextFile<code class"func"Sigmacode  ahrefchap15_mj.htmlX823707DF821E79A0"15.51/a><br />

<p>Note: At most 256 files may be open for reading or writing at the same time. Use <code class="func">CloseStream</code> (<a href="chap10.html#X786E5520803FDE00"><span class="RefLink">10.2-1</span></a>) to close the output stream once you have finished writing to it.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"># use a temporary directory</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">name := Filename( DirectoryTemporary(), "test" );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># create ansign an integer  ahref=chap14_mjhtml#X842614817FE48D62142-/>  br>
<span class="GAPprompt">gap></span> <span class="GAPinput">output := OutputTextFile( name, true );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">AppendTo( output"Hallo\n""You\n" );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(output);</span>
< classGAPprompt>>/> < classGAPinput#create an, print complete contentsof, and </span
<span class="GAPprompt">gap></span> <span class="GAPinput">input := InputTextFile(name);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print( ReadAll(input) );</span>
Hallo
You
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(input);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># append a single line</span>
<spanclassGAPprompt>gap></span><span class=GAPinput">output := OutputTextFile( name, true );;/>
<span class="GAPprompt">gap></span> <span class="GAPinput">AppendTo( output"AppendLine\n" );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># close output stream to flush the output</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(output);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># create an input, print complete contents of file, and close</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">input := InputTextFile(name);;</span>
);/>
Hallo
You
AppendLine
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(input);</span>
</pre></div>

<p><a id="X808348977A05477A" name="X808348977A05477A"></a></p>

<h4>10.6 <span class="Heading">User Streams</span></h4>

<p>The commands described in this section create streams which accept characters from, or deliver characters to, the user, via the keyboard or the <strong class="pkg">GAP</strong> session display.</p>

C7C53544Fjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

<h5>10.6-1 InputTextUser</h5>

<divcode=""SimpleGroup/>  ahref=chap39_mjhtml#X8492B05B822AC58C".-</a><br/>
<p>returns an input text stream which delivers characters typed by the user (or from the standard input device if it has been redirected). In normal circumstances, characters are delivered one by one as they are typed, without waiting until the end of a line. No prompts are printed.</p>

<p><a id="X83E5FC9487766297" name="X83E5FC9487766297"></a></p>

<h5>106-OutputTextUser/5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OutputTextUser</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<> an stream deliverscharacters to user'  ( the standard output device if   been redirected.Eachcharacter is delivered immediately  is written,without waiting for afull line of output.Text writtenin this way is <m>not</m written tothe sessionlog (see codeclass"func>LogTo</code (a href"chap9htmlX79813A6686894960">spanclass"efLink".-/>>).<p>

<p><a id="X7DAF5B7085F4F893" name="X7DAF5B7085F4F893"></a></p>

<h5>10.6-3 InputFromUser</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class<code class"func>SimpleSystem</ode  ahref"hap64_mj.htmlX7DBD179E7CCF669964.-1/>< >
<p>prints the <var class="Arg">arg</var> as a prompt, then waits until a text is typed by the user (or from the standard input device if it has been redirected). This text must be a <em>single</em> expression, followed by one <em>enter</em>. This is evaluated (see <code class="func">EvalString</code> (<a href="chap27.html#X7DE4CCD285440659"><span class="RefLink">27.9-5</span></a>)) and the result is returned.</p>

<p><a id="X8028E1D87CE2F059" name="X8028E1D87CE2F059"></a></p>

<h4>10.7 <span class="Heading">String Streams</span></h4>

ring are associated strings. An inputstring reads the characters it delivers froma string an string stream the characters it receives a string. The followingfunctions be to suchstreams<p>

<p><a id="X7ABABCDF7ED81F7F" name="X7ABABCDF7ED81F7F"></a></p>

<h5>10.7-1 InputTextString</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; InputTextString</code>( <var class="Arg">string</var> )</td><td class="tdright">( operation )</td><< class"unc"SimplifyPresentation ="chap48_mj.#X78C3D23387DAC35A>.62<a  
<p><code class="code">InputTextString( <var class="Arg">string</var> )</code> returns an input stream that delivers the characters from the string <var class="Arg">string</var>. The <var class="Arg">string</var> is not changed when reading characters from it andcode class=funcSimultaneousEigenvalues</><ahref=chap24_mj.tml#X847ADC6779E33A1C>414<a   /

<p><a id="X7FEDA5167979B74D" name="X7FEDA5167979B74D"></a></p>

<h5>10.7-2 OutputTextString</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OutputTextString</code>( <var class="Argcode class="funcSinCos< href.htmlX7935C65D7B0F47C7">1929/>  br/java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
<p>returns an output stream that puts all received characters into the list <var class="Arg">list</var>. If <var class="Arg">append</var> is <code class="keyw">false</code>, then the list is emptied first, otherwise received characters are added at the end of the list.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"># read input from a string</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">input := InputTextString( "Hallo\nYou\n" );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadLine(input);</span>
"Hallo\n"
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadLine(input);</span>
"You\n"
<span class="GAPprompt">gap></span> <span class="GAPinput"># print to a string</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">str := "";;</span>
<span class="GAPprompt">gap&t;</pan> <span classGAPinputoutOutputTextString(str,true );<span
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintTo( out, 1"\n", (1,2,3,4)(5,6), "\n" );</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(out);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print( str );</span>
1
(1,2,3,4)(5,6)
</pre></div>

<p><a id="X8563EF8387236417" name="X8563EF8387236417"></a></p>

<h4>10.8 <span class="Heading">Input-Output Streams</span></h4>

<p>Input-output streams capture bidirectional communications between <strong class="pkg">GAP</strong> and another process, either locally or (@as yet unimplemented@) remotely.</p>

<p>Such streams support the basic operations of both input and output streams. They should provide some buffering, allowing output data to be written to the stream, even when input data is waiting to be read, but the amount of this buffering is operating system dependent, and the user should take care not to get too far ahead in writing, or behind in reading, or deadlock may occur.</p>

<p>At present the only type of Input-Output streams that are implemented provide communication with a local child process, using a pseudo-tty.</p>

<p>Like other streams, write operations are blocking, read operations will block to get the first character, but not thereafter.</p>

<p>As far as possible, no translation is done on characters written to, or read from the stream, and no control characters have special effects, but the details of particular pseudo-tty implementations may effect this.</p>

<p><a id="X82822D3D8339F635" name="X82822D3D8339F635"></a></p>

<h5>10.8<code class="code"></code>,  groupswith  <ahref"chap45_mj.htmlX7A19DF1E7E841074">45.6</><br >

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsInputOutputStream</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p><code class="func">IsInputOutputStream</code> is the Category of Input-Output Streams; it returns <code class="keyw">true</code> if the <var class="Arg">obj</var> is an input-output stream and <code class="keyw">false</code> otherwise.</p>

<p><a id="X820799A3824684AC" name="X820799A3824684AC"></a></p>

<h5>10.8-2 InputOutputLocalProcess</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; InputOutputLocalProcess</code>( <var class="Arg">dir</var>, <var class="Arg">executable</var>, <var class="Arg">args</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>starts up a child process, whose executable file is <var class="Arg">executable</var>, with <q>command line</q> arguments <var class="Arg">args</var> in the directory <var class="Arg">dir</var>. (Suitable choices for <var class="Arg">dir</var> are <code class="code">DirectoryCurrent()</code> or <code class="code">DirectoryTemporary()</code> (see Section <a href=" =func<  href".".-/   java.lang.StringIndexOutOfBoundsException: Index 113 out of bounds for length 113

<p>When the stream is closed, the signal SIGTERM is delivered to the child process, which is expected to exit.</p>


< class">pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">d := DirectoryCurrent();</span>
dir("./")
<span class="GAPprompt">gap></span> <span class="GAPinput">f := PathSystemProgram("rev");</span>
"/usr/bin/rev"
<span class="GAPprompt">gap></span> <span class="GAPinput">s := InputOutputLocalProcess(d,f,[]);</span>
&; inputoutput stream rev >
<span class="GAPprompt">gap></span> <span class="GAPinput">WriteLine(s,"The cat sat on the mat");</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(ReadLine(s));</span>
tam eht no tas tac ehT
<span class="GAPprompt">gap></span> <span class="GAPinput">x := ListWithIdenticalEntries(10000,'x');;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ConvertToStringRep<code class="unc">izesConjugacyClasses>  <a href="hap71_mj.html#X7D9D2A45879A6A62>71.93<a  <r >
<span class="GAPprompt">gap></span> <span class="GAPinput">WriteLine(s,x);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">WriteByte(s,INT_CHAR('\n'));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">y := ReadAll(s);;</span>
<span>
10002
<span class="GAPprompt">gap></span> <span class="GAPinput">CloseStream(s);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">s;</span>
< closed input/output stream to rev >


<p><a id="X7CDF48447E823977" name="X7CDF48447E823977"></a></p>

<h5>10.8-3 ReadAllLine</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ReadAllLine</code>( <var class="Arg">iostream</var>[, <var class="Arg">nofail</varcode class"unc"SizeStabChain><ahrefchap43_mj.htmlX7EF36DC78465026A>43.-<a>  br>
<p>For an input/output stream <var class="Arg">iostream</var> <code class="func">ReadAllLine</code> reads until a newline character if any input is found or returns <code class="keyw">fail</code> if no input is found, i.e. if any input is found <code class="func">ReadAllLine</code> is non-blocking.</p>

<p>If the argument <var class="Arg">nofail</var> (which must be <code class="keyw">false</code> or <code class="keyw">true</code>) is provided and it is set to <code class="keyw">true</code> then <code class="func">ReadAllLine</code> will wait, if necessary, for input and never return <code class="keyw">fail</code>.</p>

<p>If the argument <var class="Arg">IsAllLine</var> (which must be a function that takes a string argument and returns either <code class="keyw">true</code> or <code class="keyw">false</code>) then it is used to determine what constitutes a whole line. The default behaviour is equivalent to passing the function</p>


<div class="example"><pre>
line -> 0 < Length(line) and Last(line) = '\n'
/></div

<p>for the <var class="Arg">IsAllLine</var> argument. The purpose of the <var class="Arg">IsAllLine</var> argument is to cater for the case where the input being read is from an external process that writes a <q>prompt</q> for data that does not terminate with a newline.</p>

<p>If the first argument is an input stream but not an input/output stream then <code class="func">ReadAllLine</code> behaves as if <code class="func">ReadLine</code> (<a href="chap10.html#X7D2CA44C7D110C4F"><span class="RefLink">10.3-4</span></a>) was called with just the first argument and any additional arguments are ignored.</p>

<p><a id="X8724699C7D67BA47" name="X8724699C7D67BA47"></a></p>

<h4>10.9 <span class="Heading">Dummy Streams</span></h4>

<p>The following two commands create dummy streams which will consume all characters and never deliver one.</p>

<p><a id="X7C732324806716C6" name="X7C732324806716C6"></a></p>

<h5>10.9-1 InputTextNone</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; InputTextNone</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns a dummy input text stream, which delivers no characters, i.e., it is always at end of stream. Its main use is for calls to <code class="func">Process</code> (<a href="chap11.html#X7B09033178D1107A"><span class="RefLink">11.1-1</span></a>) when the started program does not read anything.</p>

<p><a id="X7CC5C1FC81715E38" name="X7CC5C1FC81715E38"></a></p>

<h5>10.9-2 OutputTextNone</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OutputTextNone</code>(  )</td><td&;  rational  <a href.#824B6D328643CE04663/>< >
<p>returns a dummy output stream, which discards all received characters. Its main use is for calls to <code class="func">Process</code> (<a href="chap11.html#X7B09033178D1107A"><span class="RefLink">11.1-1</span></a>) when the started program does not write anything.</p>

<p><a id="X7CB5832F8721ADF3" name="X7CB5832F8721ADF3"></a></p>

<h4>10.10 <span class="Heading">Handling of Streams in the Background</span></h4>

<p>This section describes a feature of the <strong class="pkg">GAP</strong> kernel that can be used to handle pending streams somehow <q>in the background</q>. This is only available on operating systems that have <code class="code">select</code>.</p>

<p>Right before <strong class="pkg">GAP</strong> reads a keypress from the keyboard it calls a little subroutine that can handle streams that are ready to be read or ready to be written. This means that <strong class="pkg">GAP</strong> can handle these streams during user input on the command line. Note that this does not work when <strong class="pkg">GAP</strong> is in the middle of some calculation.</p>

<p>This feature is used in the following way. One can install handler functions for reading or writing streams via <code<code class=func</code   =".html#X83A917F67D45C7EA"42-/><r/

<p>Note that handler functions must not return anything and get one integer argument, which refers to an index in one of the following arrays (according to whether the function was installed for inputoutput or exceptions on the stream). Handler functions usually should not output anything on the standard output because this ruins the command line during command line editing.</p>

<p><a id="X81FB42517E3EA96D" name="X81FB42517E3EA96D"></a></p>

<h5>10.10-1 InstallCharReadHookFunc</h5>

<div class="func"><table class="func" width="100%&&; for atransformationa =".#X85FE9F20810BCC70<a  java.lang.StringIndexOutOfBoundsException: Index 108 out of bounds for length 108
<p>installs the function <var class="Arg">func</var> as a handler function for the stream <var class="Arg">stream</var>. The argument <var class="Arg">mode</var> decides, for what operations on the stream this function is installed. <var class="Arg">mode</var> must be a string, in which a letter <code class="code">r</code> means <q>read</q>, <code class="code">w</code> means <q>write</q> and <code class="code">x</code> means <q>exception</q>, according to the <code class="code">select</code> function call in the UNIX C-library (see <code class="code">man select</code> and <code class="func">UNIXSelect</code> (<a href="chap10.html#X87BC257A78F96828"><span class="RefLink">10.2-3</span></a>)). Morenbsp;&;  a  permutation  < ="chap54_mj.#X85280F1A7B1014BA">54314/>< >

<p>This functionality only works if the operating system has a <code class="code">select</code> function.</p>

<p><a id="X8492474C7A0B10AD" name="X8492474C7A0B10AD"></a></p>

<h5>10.10-2 UnInstallCharReadHookFunc</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; UnInstallCharReadHookFunc</code>( <var class="Arg">stream</var>, <var class="Arg">func</var> )</td><td class=chap42_mj42.1/>< >
<p>uninstalls the function <var class="Arg">func</var> as a handler function for the stream <var class="Arg">stream</var>. All instances are deinstalled, regardless of the mode of operation (read, write, exception).</p>

<p>This functionality only works if the operating system has a <code class="code">select</code> function.</p>

<p><a id="X848DD7DC79363341" name="X848DD7DC79363341"></a></p>

<h4>10.11 <span class=&bsp; &;for partial perm coll< hrefchap54_mjhtml">54.-12<a  br >

<p>In some situations it can be desirable to process data given in the form of a spreadsheet (such as Excel). <strong class="pkg">GAP</strong> can do this using the CSV (comma separated values) format, which spreadsheet programs can usually read in or write out.</p>

<p>The first line of the spreadsheet is usednbsp;nbsp; forpermutation<ahref=chap42_mjhtml".1<a><br />

<p><a id="X86FDC1EF82CAD2DA" name="X86FDC1EF82CAD2DA"></a></p>

<h5>10.11-1 ReadCSV</h5>

<divnbsp;&; nbspfortransformationahref=chap53_mjhtml#X86C0DDDC7881273A>53.-7<a>< java.lang.StringIndexOutOfBoundsException: Index 107 out of bounds for length 107
<p>This function reads in a spreadsheet, saved in CSV format (<em>c</em>omma <em>s</em>eparated <em>v</em>alues) and returns its entries as a list of records. The entries of the first line of the spreadsheet are used to denote the names of the record components. Blanks will be translated into underscore characters. If; nbsp;&;for atransformationcoll< href=chap53_mj#X86C0DDDC7881273A">53.7/> < >

<p><a id="X8779DAC585E05A47" name="X8779DAC585E05A47"></a></p>

<h5>10.11-2 PrintCSV</h5>

< class">tableclass="func"width=100%">tr>td class=tdleftcodeclass"#8227 PrintCSV</code>(varclass"Arg"filename</Arg"</var var class"fields/var>] )</td><td class=""(nbspfunction&;)/td>/r>/table</iv>
<p>This function prints a list of records as a spreadsheet in CSV format (which can be read in for example into Excel). The names of the record components will be printed as entries in the first line. If the argument <var class="Arg">fields</var> is given only the record fields listed in this list will be printed and they will be printed in the same arrangement as given in this list. If the option noheader is set to true the line with the record field names will not be printed.</p>

<p><a id="X87396F857ADA3F97" name="X87396F857ADA3F97"></a></p>

<h4>10.12 <span class="Heading">Opening files in the Operating System</span></h4>

<p>In some situations it can be desirablecodeclass=">SmallRing<code   href="chap56_mj#X7E86DCB7812DF04C"5691<a  br/

<p><a id="X86B98E287AD42BE8" name="X86B98E287AD42BE8"></a></p>

<h5>10.12-1 OpenExternal</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; OpenExternal</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Open the file <var class="Arg">filename</varSmith normal  a href"hap77_mj.#X79676CD27EF0F096>773</> br >


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap9.html">[Previous Chapter]</a>    <a hrefclass>mithNormalFormIntegerMata="chap25_mj.#X87089FEC7FBEEA8F>.26/></


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1<SmithNormalFormIntegerMatTransforms/code  ahref=.htmlX839C1F9E87273A93>.-</>  < />

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

Messung V0.5 in Prozent
C=96 H=100 G=97

¤ Dauer der Verarbeitung: 0.34 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.