<doc>
  <legacy_id>1490</legacy_id>
  <name>read from driver</name>
  <type>command</type>
  <syntax>
    <example>read from driver<i> deviceName</i> [at <i>start</i>] {until {<i>string</i> | end | EOF | empty} | for <i>amount</i> [<i>chunkType</i>]} [in <i>time</i>]</example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>Networks &amp; Communication</category>
  </classification>
  <references>
    <command tag="write to driver">write to driver Command</command>
    <command tag="read from process">read from process Command</command>
  </references>
  <history>
    <introduced version="1.1.1">Added.</introduced>
    <changed version="2.0"></changed>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
  </classes>
  <security>
  </security>
  <summary>Takes incoming data from a <glossary tag="peripheral device">device</glossary> that has been opened with the <command tag="open driver">open driver</command> <glossary tag="command">command</glossary>, and places the data in the <keyword tag="it">it</keyword> <glossary tag="variable">variable</glossary>.</summary>
  <examples>
    <example>read from driver ".BIn" for 3 lines</example>
    <example>read from driver it for 2 chars in 2 seconds</example>
  </examples>
  <description>
    <p>Use the <b>read from driver</b> <glossary tag="command">command</glossary> to get data from a <glossary tag="peripheral device">peripheral device</glossary> such as a modem.</p><p/><p><b>Parameters:</b></p><p>The <i>deviceName</i> is the name of a <glossary tag="device driver">device driver</glossary> that's installed on the system and that you have previously opened with the <command tag="open driver">open driver</command> <glossary tag="command">command</glossary>.</p><p/><p>The <i>start</i> specifies the <keyword tag="character">character</keyword> or <glossary tag="byte">byte</glossary> position in the <glossary tag="peripheral device">device's</glossary> input where you want to begin reading.</p><p/><p>The <i>string</i> is any <glossary tag="expression">expression</glossary> that <glossary tag="evaluate">evaluates</glossary> to a <keyword tag="string">string</keyword>. When LiveCode encounters the <i>string</i> in the data coming in from the <glossary tag="peripheral device">device</glossary>, it stops reading. If the <i>string</i> is not encountered, the <b>read from driver</b> <glossary tag="command">command</glossary> continues reading as long as there is data to be read.</p><p/><p>The <i>amount</i> is a positive <keyword tag="integer">integer</keyword> and specifies how much data to read.</p><p/><p>The <i>chunkType</i> is one of chars, characters, words, items, lines, int1, uInt1, int2, uint2, int4, or uint4. The <b>read from driver</b> <glossary tag="command">command</glossary> reads <i>amount</i> of the specified <i>chunkType</i>. If you don't specify a <i>chunkType</i>, <i>amount</i> <keyword tag="characters">characters</keyword> are read.</p><p/><p>The <i>time</i> is the time to wait for the read to be completed, in <function tag="milliseconds">milliseconds</function>, seconds, or <function tag="ticks">ticks</function>.</p><p/><p><b>Comments:</b></p><p>The device to read from must be opened first with the <b>open driver</b> <glossary tag="command">command</glossary>, and the mode the device was opened in must be either read or update. If the device is not open or is open write-only, the <function tag="result">result</function> <control_st tag="function">function</control_st> is set to "File is not open for read.".</p><p/><p>The until <i>string</i> form reads data until the specified string is encountered. The until empty, until end, and until EOF forms read data until there is no more data to be read.</p><p/><p>The data is placed in the <b>it</b> <glossary tag="variable">variable</glossary> after reading. If you specified a <glossary tag="binary data">binary data</glossary> <i>chunkType</i> (int1, uInt1, int2, uint2, int4, or uint4), the data consists of a comma-separated list of numbers, one for the numerical value of each chunk that was read. Otherwise, the data is placed in the <keyword tag="it">it</keyword> <glossary tag="variable">variable</glossary> as it appears in the output.</p><p/><p>If you specify a <i>time</i> and the read is not completed when that time has elapsed, the <function tag="result">result</function> <control_st tag="function">function</control_st> is set to "time out". If the read was successful, the <b>result</b> is set to empty.</p><p/><p><b>Changes:</b></p><p>Support for using serial drivers with OS X systems was added in version 2.0.</p>
  </description>
</doc>