php-doc-en/reference/yaz/functions/yaz-scan.xml
2004-01-26 13:42:22 +00:00

96 lines
3.3 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/yaz.xml, last change in rev 1.8 -->
<refentry id="function.yaz-scan">
<refnamediv>
<refname>yaz_scan</refname>
<refpurpose>Prepares for a scan</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>yaz_scan</methodname>
<methodparam><type>resource</type><parameter>id</parameter></methodparam>
<methodparam><type>string</type><parameter>type</parameter></methodparam>
<methodparam><type>string</type><parameter>startterm</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
<para>
This function prepares for a Z39.50 Scan Request, where parameter
<parameter>id</parameter> specifies connection. Starting term
point for the scan is given by <parameter>startterm</parameter>.
The form in which the starting term is specified is given by parameter
<parameter>type</parameter>. Currently only type <literal>rpn</literal>
is supported. The optional parameter <parameter>flags</parameter>
specifies additional information to control the behaviour of the
scan request. Three indexes are currently read from the flags:
<literal>number</literal> (number of terms requested),
<literal>position</literal> (preferred position of term) and
<literal>stepSize</literal> (preferred step size).
To actually transfer the Scan Request to the server and receive the
Scan Response, <function>yaz_wait</function> must be called. Upon
completion of <function>yaz_wait</function> call
<function>yaz_error</function> and <function>yaz_scan_result</function> to
handle the response.
</para>
<para>
The syntax of <parameter>startterm</parameter> is similar to the
RPN query as described in <function>yaz_search</function>. The
startterm consists of zero or more <literal>@attr</literal>-operator
specifications, then followed by exactly one token.
</para>
<para>
<example>
<title>PHP function that scans titles</title>
<programlisting role="php">
<![CDATA[
<?php
function scan_titles($id, $startterm)
{
yaz_scan($id, "rpn", "@attr 1=4 " . $startterm);
yaz_wait();
$errno = yaz_errno($id);
if ($errno == 0) {
$ar = yaz_scan_result($id, &$options);
echo 'Scan ok; ';
while (list($key, $val) = each($options)) {
echo "$key = $val &nbsp;";
}
echo '<br /><table>';
while (list($key, list($k, $term, $tcount)) = each($ar)) {
if (empty($k)) continue;
echo "<tr><td>$term</td><td>$tcount</td></tr>";
}
echo '</table>';
} else {
echo "Scan failed. Error: " . yaz_error($id) . "<br />";
}
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->