Code Editor
Search Frame
Change History

Search Lists
Shortcut Keys
Custom Icons
HTML Export
Drag & Drop
Hex View
Easter Eggs

Revision Control
Object Storage
Language Def
Remote Folders
Server Sync
Online Search
Import Code


Contact Me

GBIC >> gbWare >> gbCodeLib >> Search Frame
gbCodeLib - Online Search
From within gbCodeLib, users may search online gbCodeLib datbases. The database at the gbCodeLib server may be searched, as may any other gbCodeLib database uploaded to a user's server.

The search window (see above) is used to determine the location of the online search script and the gbCodeLib database. Both must be located in the same folder - typically the cgi-bin folder on the server. Users may modify the Perl search script so that the gbCodeLib database can be placed in another folder.

To search the online database, just type in a search term (Boolean online searches are not supported at this time) and press Enter. gbCodeLib will run the search script and display a list of the matching snippets in the the 'Online Source Code Update' frame (see the image below).

Once the matching snippets have been downloaded from the server and displayed click on a snippet title to see its code in the textbox to the right of the snippet list.

To import the snippets into the local database, select the snippets you want to import and press the Import button from the toolbar. By default, no snippets are selected.

    (click to enlarge)

For convenience several functions are available as a context sensitive menu in the downloaded matching snippets list. Right-mouse click a snippet to get the following menu selections:

  • Select All
    Selects all matching server snippets
  • Unselect All
    Unselects all matching snippets
  • Display Only Snippets With Matching Titles
    Limits the display to only those server snippets with a title identical to a snippet already in the current snippet database.

Also, the downloaded snippet source code can quickly be transferred to the source code editor by right-mouse clicking on the server snippet source code and selecting the "Replace Tree Code" menu selection.

Perl Search Script
The search script, written in Perl, is included in the gbCodeLib distribution as 'gbcodelibsearch.pl'. A listing of the script is as follows:


print "Content-type: text/html\n\n";
print "gbCodeLib Server Search Result\r\n";
print "Gary Beene's Information Centers\r\n";
print "http://www.garybeene.com\r\n";
print "\r\n";
$find = $ENV{'QUERY_STRING'};
if ($find ne "")  {
    $filename = "gbcodelib.txt";
    #read file text into array
    open GBDATA, $filename;
    @code = ;
    close (GBDATA);
    #create array of snippets (each starts with ----T)
    $code = join "",@code;
    @code = split(/----T/,$code);
    #print array elements containing the search term
    foreach $element (@code) {
        if ($element =~ /$find/i) {
            print "----T".$element;
#print end of gbCodeLib file
print "++++++++  ".$i

For a user to enable online searching of his gbCodeLib database, the Perl script and the gbCodeLib database must be placed on his server in the CGI-BIN folder (the exact folder may depend on how the ISP has set up the server. The correct folder to use is wherever CGI scripts must be placed), with executable access rights.

The user may modify the Perl script as desired. A suggested change for most users would be to change the $filename variable to reflect the same filepath as is used in the synchronization feature of gbCodeLib. That way, a single copy of the user's database can be kept online - using the built-in FTP transfer features of gbCodeLib.

View Results
When successful the search script will return a gbCodeLib-compatible snippet database. In the event of a problem with the server/script/Internet, the script may return an error message in HTML format.

From the search page, the user can open the most recent search result file using Notepad or the default browser - corresponding to the selection of the Text or HTML option settings in the Online Search window.