One of the things that attracts me to REBOL is its easy facilitation of e-commerce applications. I invite everyone to check out my company's "Search Elephant" for our book catalog at http://abooks.com/catalog. I wrote it in one evening (last night actually) and published it to the net. All the search functions are handled by just a few lines in REBOL. (You will note I gave REBOL a big plug<g>.) Of course, it would be uncivil of me to just brag about the neat ap I wrote without telling you HOW it works. It's pretty trival; the real headache is getting the HTML commands to format right--nothing to do with the REBOL code, HTML is just a pain on good days. I'll be publishing more complete details soon but this search (and any online search) program requires two components--a way to get the search term into REBOL; and a place for REBOL to get the data to compare against. Until REBOL/Command arrives (*pant, drool*) and we can query databases like mySQL, the simple method is a plain old textfile (flat database). We pass the search term to REBOL via an HTML form using the 'get' method: <form method=get action='cgi-bin/booklist-title.r' name="Search Booklist"> <table width='380' bgcolor='ivory' height="60"> <tr><td height="25"> <p align="center"><b>Search Booklist</b>:</p> </td><td align=right height="25"><input name="name" size=30></td></tr> <tr><td height="27"><input type="submit" name="submit" value="Submit"></td> <td align=right height="27"><input type="reset" name="reset" value="Reset"></td></tr> </table></form> The HTML form calls the REBOL script (in my case, booksearch-title.r). The script gets the search term from the from via: data: decode-cgi system/options/cgi/query-string searchtitle: data/2 The second line above is necessary because REBOL receives form information as a block value; I'm just pulling out the value that contains the actual search term. Now we get the database (i.e. textfile): a: read/lines %/catalog/booklist.txt You might want to put your datafile in a non-web accessible area of your server just for security reasons, as I did above. Now, we have both the search term and the database to be searched in REBOL. In my case, I have a text file with three kinds of lines--category names; lines with title, author, isbn, publisher, price; and lines that contain descriptions of books. I use loops and parsing to determine the type of line and how to handle it for output back to HTML, letting the REBOL script constuct the search results page. I should mention that your database, if large, can exceed memory space. Use the technique: a: open/lines %textfile.txt This creates a port to the file instead of pulling the whole thing into memory. Remember to close it when done. Hope this general technique proves of use to it. ... As already stated, I'll be publishing more detailed database and other REBOL techniques later. Maybe even in a book, when I can announce it<g>. Meanwhile, enjoy. REBOL truly is Perl without the complication. --Ralph Roberts
