Hello again,
Below is a function called randomsearch. Randomsearch takes two
parameters. The first is the name of a QuickSearch function. The
second is a path/name of a txt file. The function will pull a random
line out of the text file and apply the given function to it. I use
this function to implement a word-of-the-day study tool, but I can
imagine a number of other educational purposes.
Would one of you administrators mind adding this to the source if the
group deems it worthy? I apologize for no longer having any CVS tools
set up. Let me know if you wish me to send this in as an attachment.
Thanks,
Neel
<search function="randomsearch">
<name>Random Search</name>
<description>
Choses a random line item from the given file (second argument) and
uses the given search function (first argument) to look it up. Ideal
for a word of the day lookup tool.<br/>
<div class="helpboxDescLabels">Usage:</div>
<table class="helpboxDescTable">
<tr><td>randomsearch <<i>function</i>>
<<i>filename</i>></td></tr>
</table>
<div class="helpboxDescLabels">Example:</div>
<table class="helpboxDescTable">
<tr><td>randomsearch dic /searches/randomsearch.txt</td><td> -
</td><td>Uses the "dic" function to look up a random word from the
list.</td></tr>
</table>
</description>
<category>Search the Web</category>
<contributor>Neel Doshi</contributor>
<script><![CDATA[
function randomsearch(q)
{
if ( nullArgs("randomsearch", q) )
return false;
var args_array = q.split(' ');
var args_function = args_array.shift();
var args_file = args_array.shift();
var itemtable = readTabDelimitedFile(args_file);
if (itemtable == "")
{
alert("No words in " + args_file);
return false;
}
var irand = Math.round(Math.random() * (itemtable.length-1));
var stritemsearch = new String(itemtable[irand]);
performsearch(args_function, stritemsearch);
return true;
}
]]></script>
<copyright>
Copyright (c) 2002 David Bau
Distributed under the terms of the
GNU Public License, Version 2
(http://www.gnu.org/copyleft/gpl.txt)
</copyright>
</search>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-Devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dqsd-devel