Thanks to all REBOLers who contributed to this topic thread for helping me
get my head straight. What the heck wuz I thinking of to read the entire
database into a variable<g>. This would have truly become fun if 40 or 50
people were trying to look up values at once and tortured my poor server's
available memory.

As ever in REBOL, there are simple solutions. I hope this example proves
helpful.

Here are the basics of how I do it now. I pass the search criteria from the
form on the initial search page using the GET method (let's say we seach for
'Smith,' as example). My search.r script (http://abooks.com/cgi-bin/search.r
calls search1.r via the form action HTML line:

        <form method=get action='search1.r'>

The search1.r script gets the form name data ('Smith,') from search.r as
below:

        data: decode-cgi system/options/cgi/query-string

The above returns a block with the name/search info in the second position
(data/2). I now open my autograph price database (tab-delimited text), see
how long it is, and use the length to check all lines for matches to the
search string. Any line with a match is appended to block b. Now it is just
HTML stuff to print out the results from block b.

        a: open/lines %/autograph/auto.db

        b: []
        repeat count (length? a) [

         line: pick a count
         if find line data/2 [append b line]

                ]

                close a

We find 113 entries with the string "smith," in it.

I loves REBOL! With only a little more work, I'll have my complete autograph
price lookup service ready to go public in a day or two, and I only started
last Thursday, I believe<g>. REBOL is web application development on
steriods! And just imagine what we all can do when REBOL/Command is
available<g>.

Are we having fun yet? Yeah!

--Ralph Roberts


Reply via email to