'===========================================================================
' Subject: INTERNET SEARCH UTILITY            Date: 07-15-96 (22:07)       
'  Author: Darryl Schneider                   Code: QB, QBasic, PDS        
'  Origin: fish2@datanet.ab.ca              Packet: MISC.ABC
'===========================================================================
'This is a little internet search utility that
'searches all of the web sites or newsgroups in
'its database, depending on the keyword you type
'in. Modify it by adding your own sites to the
'database. It might be kind of hard to read,
'despite the fact I added in a few comments.
'Oh well, as long as it works! Enjoy :)
'
'Written by Darryl Schneider
'E-mail: fish2@datanet.ab.ca
'The QBasic Zone
'http://www.geocities.com/SiliconValley/8191/
'
SCREEN 12

DIM BCURSOR(1 TO 500)              'draw the little arrow cursor
LINE (50, 50)-(50, 60), 1          'Throughout the program I do
LINE (50, 50)-(70, 55), 1          'not use PSET to move the cursor.
LINE (50, 60)-(70, 55), 1          'Instead I just cover up my tracks
PAINT (55, 55), 3, 1               'with LINE (), , B and move ahead!
GET (50, 50)-(70, 60), BCURSOR     'Save the cursor

DEFSTR A, C-W                      'define some variables
DEFINT X-Y
DEFLNG Z
CASES = "N"                        'right now it is not case-sensitive
SEARCHLIMITS = "NONE"              'there are no search limits set

MAINMENU:                          'start of the main menu
CLS
ZTOTAL1 = 0                        'resets some variables to zero
ZTOTAL2 = 0
ZTOTAL3 = 0
ZHTML = 0
ZFTP = 0
ZNEW = 0
ZHTMLT = 2                         'these next three are the number
ZFTPT = 2                          'of sites in each database. When
ZNEWT = 2                          'you add a new site, make sure you
                                   'increase the number corresponding
                                   'to the database or else it won't
                                   'work properly!
ENTER = CHR$(13)
UP = CHR$(0) + CHR$(72)
DOWN = CHR$(0) + CHR$(80)

LINE (140, 46)-(500, 360), 9, BF        'draw the main menu screen
LINE (140, 46)-(500, 65), 11, BF
COLOR 10: LOCATE 4, 35: PRINT "QuickSearch"
COLOR 15: LOCATE 7, 25: PRINT "Enter keyword: "
COLOR 12: LOCATE 10, 34: PRINT "Search Options"
COLOR 15: LOCATE 13, 25: PRINT "Case-Sensitive: "; : COLOR 14: PRINT CASES
COLOR 15: LOCATE 15, 25: PRINT "Search Limits: "; : COLOR 14: PRINT SEARCHLIMITS; " "
COLOR 10: LOCATE 17, 25: PRINT "Search"
COLOR 15: LOCATE 20, 25: PRINT "About QuickSearch"
COLOR 15: LOCATE 22, 25: PRINT "End Search"

MM1:                                        'all of the MM labels are
C1 = ""                                     'the different cursor locations
PUT (168, 96), BCURSOR
DO
C1 = INKEY$
IF C1 = ENTER THEN
         LOCATE 7, 40: INPUT "", KEYWORD        'input the keyword
         GOSUB MM1                              'If you type "basic"
END IF                                          'you get 5 of the 6
IF C1 = UP THEN                                 'sites displayed
         LINE (168, 96)-(188, 106), 9, BF
         GOSUB MM6
END IF
IF C1 = DOWN THEN
         LINE (168, 96)-(188, 106), 9, BF
         GOSUB MM2
END IF
LOOP

MM2:
C2 = ""
PUT (168, 192), BCURSOR
DO
C2 = INKEY$
IF C2 = ENTER THEN
         SELECT CASE CASES
               CASE "N"                  'change to case-sensitive
                   CASES = "Y"
                   LOCATE 13, 41: COLOR 14: PRINT CASES
                   COLOR 15
                   GOSUB MM2
               CASE "Y"                   'change to case-insensitive
                   CASES = "N"
                   LOCATE 13, 41: COLOR 14: PRINT CASES
                   COLOR 15
                   GOSUB MM2
         END SELECT
END IF
IF C2 = UP THEN
         LINE (168, 192)-(188, 202), 9, BF
         GOSUB MM1
END IF
IF C2 = DOWN THEN
         LINE (168, 192)-(188, 202), 9, BF
         GOSUB MM3
END IF
LOOP

MM3:                              'this label grouping changes the
C3 = ""                           'search limits
PUT (168, 226), BCURSOR
DO
C3 = INKEY$
IF C3 = ENTER THEN
         IF SEARCHLIMITS = "NONE" THEN
                SEARCHLIMITS = "HTML"
                LOCATE 15, 40: COLOR 14: PRINT SEARCHLIMITS
                COLOR 15
                GOSUB MM3
         END IF
         IF SEARCHLIMITS = "HTML" THEN
                SEARCHLIMITS = "FTP"
                LOCATE 15, 40: COLOR 14: PRINT SEARCHLIMITS; " "
                COLOR 15
                GOSUB MM3
         END IF
         IF SEARCHLIMITS = "FTP" THEN
                SEARCHLIMITS = "NEWS"
                LOCATE 15, 40: COLOR 14: PRINT SEARCHLIMITS
                COLOR 15
                GOSUB MM3
         END IF
         IF SEARCHLIMITS = "NEWS" THEN
                SEARCHLIMITS = "NONE"
                LOCATE 15, 40: COLOR 14: PRINT SEARCHLIMITS
                COLOR 15
                GOSUB MM3
         END IF
END IF
IF C3 = UP THEN
         LINE (168, 226)-(188, 236), 9, BF
         GOSUB MM2
END IF
IF C3 = DOWN THEN
         LINE (168, 226)-(188, 236), 9, BF
         GOSUB MM4
END IF
LOOP

MM4:
C4 = ""
PUT (168, 258), BCURSOR
DO
C4 = INKEY$
IF C4 = ENTER THEN
         GOSUB STARTSEARCH           'begin the search!
END IF
IF C4 = UP THEN
         LINE (168, 258)-(188, 268), 9, BF
         GOSUB MM3
END IF
IF C4 = DOWN THEN
         LINE (168, 258)-(188, 268), 9, BF
         GOSUB MM5
END IF
LOOP

MM5:
C5 = ""
PUT (168, 306), BCURSOR
DO
C5 = INKEY$
IF C5 = ENTER THEN
         GOSUB ABOUT             'go to the about screen
END IF
IF C5 = UP THEN
         LINE (168, 306)-(188, 316), 9, BF
         GOSUB MM4
END IF
IF C5 = DOWN THEN
         LINE (168, 306)-(188, 316), 9, BF
         GOSUB MM6
END IF
LOOP
MM6:
C6 = ""
PUT (168, 338), BCURSOR
DO
C6 = INKEY$
IF C6 = ENTER THEN
         GOSUB QUIT                             'quit
END IF
IF C6 = UP THEN
         LINE (168, 338)-(188, 348), 9, BF
         GOSUB MM5
END IF
IF C6 = DOWN THEN
         LINE (168, 338)-(188, 348), 9, BF
         GOSUB MM1
END IF
LOOP

STARTSEARCH:
CLS
IF KEYWORD = "" THEN GOSUB MAINMENU
IF CASES = "N" THEN KEYWORD = UCASE$(KEYWORD)
PRINT "               QuickSearch Results for query: "; : COLOR 14: PRINT KEYWORD
COLOR 15
PRINT ""
IF SEARCHLIMITS = "NONE" THEN GOSUB SEARCH1     'a little filter depending
IF SEARCHLIMITS = "HTML" THEN GOSUB SEARCH1     'on the search limits
IF SEARCHLIMITS = "FTP" THEN GOSUB SEARCH2
IF SEARCHLIMITS = "NEWS" THEN GOSUB SEARCH3

SEARCH1:
RESTORE HTMLSITES                  'finds all the HTML sites
NEXTHTML:
IF ZHTML = ZHTMLT THEN
        Y1 = 1
        IF SEARCHLIMITS = "NONE" THEN
                IF ZTOTAL1 = 1 THEN ZTOTAL2 = 1
                IF ZTOTAL1 = 2 THEN ZTOTAL2 = 2
                IF ZTOTAL1 = 3 THEN ZTOTAL2 = 3
                IF ZTOTAL1 = 4 THEN ZTOTAL2 = 4
                GOSUB SEARCH2
        END IF
        IF SEARCHLIMITS = "HTML" THEN GOSUB NOMORE
END IF
PREV1:
READ HTMLSITE, HTMLADDRESS, HTMLDESCRIPTION, HTMLDESCRIPTION2
IF CASES = "N" THEN GOSUB HTMLUP
IF CASES = "Y" THEN GOSUB HTMLLOW
HTMLUP:
                IF INSTR(UCASE$(HTMLSITE), UCASE$(KEYWORD)) > 0 THEN
                COLOR 13: PRINT HTMLSITE
                COLOR 11: PRINT "       "; HTMLDESCRIPTION
                PRINT "         "; HTMLDESCRIPTION2
                COLOR 12: PRINT "       http://"; HTMLADDRESS
                COLOR 15:
                PRINT ""
                ZTOTAL1 = ZTOTAL1 + 1
                ZHTML = ZHTML + 1
                IF ZHTML = ZHTMLT THEN GOSUB NEXTHTML
                IF ZTOTAL1 = 4 THEN GOSUB NEXTPAGE
                GOSUB NEXTHTML
        ELSE
                ZHTML = ZHTML + 1
                GOSUB NEXTHTML
        END IF
HTMLLOW:       
         IF INSTR(HTMLSITE, KEYWORD) > 0 THEN
                COLOR 13: PRINT HTMLSITE
                COLOR 11: PRINT "       "; HTMLDESCRIPTION
                PRINT "         "; HTMLDESCRIPTION2
                COLOR 12: PRINT "       http://"; HTMLADDRESS
                COLOR 15:
                PRINT ""
                ZTOTAL1 = ZTOTAL1 + 1
                ZHTML = ZHTML + 1
                IF ZHTML = ZHTMLT THEN GOSUB NEXTHTML
                IF ZTOTAL1 = 4 THEN GOSUB NEXTPAGE
                GOSUB NEXTHTML
        ELSE
                ZHTML = ZHTML + 1
                GOSUB NEXTHTML
        END IF

SEARCH2:
RESTORE FTPSITES                     'finds the FTP sites
NEXTFTP:
IF ZFTP = ZFTPT THEN
        Y2 = 1
        IF SEARCHLIMITS = "NONE" THEN
                IF ZTOTAL2 = 1 THEN ZTOTAL3 = 1
                IF ZTOTAL2 = 2 THEN ZTOTAL3 = 2
                IF ZTOTAL2 = 3 THEN ZTOTAL3 = 3
                IF ZTOTAL2 = 4 THEN ZTOTAL3 = 4
                GOSUB SEARCH3
        END IF
        IF SEARCHLIMITS = "FTP" THEN GOSUB NOMORE
END IF
IF ZTOTAL2 = 4 THEN GOSUB NEXTPAGE
PREV2:
READ FTPSITE, FTPADDRESS, FTPDESCRIPTION, FTPDESCRIPTION2
IF CASES = "N" THEN GOSUB FTPUP
IF CASES = "Y" THEN GOSUB FTPLOW
FTPUP:
                IF INSTR(UCASE$(FTPSITE), UCASE$(KEYWORD)) > 0 THEN
                COLOR 13: PRINT FTPSITE
                COLOR 11: PRINT "       "; FTPDESCRIPTION
                PRINT "         "; FTPDESCRIPTION2
                COLOR 12: PRINT "       ftp://"; FTPADDRESS
                COLOR 15:
                PRINT ""
                ZTOTAL2 = ZTOTAL2 + 1
                ZFTP = ZFTP + 1
                IF ZFTP = ZFTPT THEN GOSUB NEXTFTP
                IF ZTOTAL2 = 4 THEN GOSUB NEXTPAGE
                GOSUB NEXTFTP
        ELSE
                ZFTP = ZFTP + 1
                GOSUB NEXTFTP
        END IF
FTPLOW:
                IF INSTR(FTPSITE, KEYWORD) > 0 THEN
                COLOR 13: PRINT FTPSITE
                COLOR 11: PRINT "       "; FTPDESCRIPTION
                PRINT "         "; FTPDESCRIPTION2
                COLOR 12: PRINT "       ftp://"; FTPADDRESS
                COLOR 15:
                PRINT ""
                ZTOTAL2 = ZTOTAL2 + 1
                ZFTP = ZFTP + 1
                IF ZFTP = ZFTPT THEN GOSUB NEXTFTP
                IF ZTOTAL2 = 4 THEN GOSUB NEXTPAGE
                GOSUB NEXTFTP
        ELSE
                ZFTP = ZFTP + 1
                GOSUB NEXTFTP
        END IF

SEARCH3:
RESTORE NEWSITES                       'finds some newsgroups
NEXTNEW:
IF ZNEW = ZNEWT THEN
        IF SEARCHLIMITS = "NONE" THEN GOSUB NOMORE
        IF SEARCHLIMITS = "NEWS" THEN GOSUB NOMORE
END IF
IF ZTOTAL3 = 4 THEN GOSUB NEXTPAGE
PREV3:
READ NEWSITE, NEWDESCRIPTION, NEWDESCRIPTION2
IF CASES = "N" THEN GOSUB NEWUP
IF CASES = "Y" THEN GOSUB NEWLOW
NEWUP:
                IF INSTR(UCASE$(NEWSITE), UCASE$(KEYWORD)) > 0 THEN
                COLOR 13: PRINT NEWSITE
                COLOR 11: PRINT "       "; NEWDESCRIPTION
                PRINT "         "; NEWDESCRIPTION2
                COLOR 15:
                PRINT ""
                ZTOTAL3 = ZTOTAL3 + 1
                ZNEW = ZNEW + 1
                IF ZNEW = ZNEWT THEN GOSUB NEXTNEW
                IF ZTOTAL3 = 4 THEN GOSUB NEXTPAGE
                GOSUB NEXTNEW
        ELSE
                ZNEW = ZNEW + 1
                GOSUB NEXTNEW
        END IF
NEWLOW:
                IF INSTR(NEWSITE, KEYWORD) > 0 THEN
                COLOR 13: PRINT NEWSITE
                COLOR 11: PRINT "       "; NEWDESCRIPTION
                PRINT "         "; NEWDESCRIPTION2
                COLOR 15:
                PRINT ""
                ZTOTAL3 = ZTOTAL3 + 1
                ZNEW = ZNEW + 1
                IF ZNEW = ZNEWT THEN GOSUB NEXTNEW
                IF ZTOTAL3 = 4 THEN GOSUB NEXTPAGE
                GOSUB NEXTNEW
        ELSE
                ZNEW = ZNEW + 1
                GOSUB NEXTNEW
        END IF

NOMORE:                             'no more matches to the keyword
LOCATE 25, 5: PRINT "No more matches...press enter to return to the main menu..."
DO
D2 = UCASE$(INKEY$)
IF D2 = ENTER THEN GOSUB MAINMENU
LOOP

'databases

HTMLSITES:
DATA The QBasic Zone, www.geocities.com/SiliconValley/8191/, - Includes programs; tutorials; compilers; a huge, list of links and much more!
DATA The All Basic Code Home Page, charlie.simplenet.com/abc/abchome.html, - Has ABC packets filled with tons of, source code for you to use.

FTPSITES:
DATA M / K Productions, members.aol.com/blood225/, - Lots of files to download,
DATA SimTel MSDOS Basic, oak.oakland.edu/SimTel/msdos/basic/, An archive of files to download,

NEWSITES:
DATA comp.lang.basic.misc, - Discussion of any BASIC programming language,
DATA alt.lang.basic, - Discussion of all the BASIC programming languages,

'end of databases

ABOUT:                     'the infamous about screen
CLS
PRINT "                   About QuickSearch"
PRINT ""
PRINT "QuickSearch was written in Microsoft QuickBasic by 14-year old Darryl"
PRINT "Schneider. It is designed to be an off-line search utility so you"
PRINT "do not have to go back and forth while 'web surfing' to search for"
PRINT "the address of a web site. Above this in the source code are the"
PRINT "DATA statements for HTML and FTP sites, as well as Newsgroups. You"
PRINT "may add your own sites to the list, and build up a large database."
PRINT "With the HTML and FTP databases, the first series of words is the title"
PRINT "of the site, the next series is the address, next the first line of the"
PRINT "description, and then the second line of description. It is the same for"
PRINT "newsgroups except there is no address. At the main menu you can have"
PRINT "a case-sensitive or non-sensitive search, and can search with no"
PRINT "limits (None), only in HTMLs (HTML), only in FTPs (FTP), or only in"
PRINT "newsgroups (NEWS), by cycling through pressing enter. I hope that this"
PRINT "application proves useful in some way and helps you with programming"
PRINT "or your web surfing!"
PRINT ""
PRINT "Press enter to return to the main menu..."
DO
D3 = UCASE$(INKEY$)
IF D3 = ENTER THEN GOSUB MAINMENU
LOOP

QUIT:
END

NEXTPAGE:
LOCATE 25, 5: PRINT "Press enter for more or 'Q' to quit..."
DO
D1 = UCASE$(INKEY$)               'goes to the next page after 4
IF D1 = ENTER THEN                'sites have been displayed
        IF Y1 = 1 THEN GOSUB NEXT2
        IF ZTOTAL1 = 4 THEN
           IF ZHTML = ZHTMLT THEN GOSUB NEXTHTML
           ZTOTAL1 = 0
           CLS
           PRINT "               QuickSearch Results for query: "; : COLOR 14: PRINT KEYWORD
           PRINT ""
           COLOR 15
           GOSUB PREV1
        END IF
NEXT2:     
        IF Y2 = 1 THEN GOSUB NEXT3
        IF ZTOTAL2 = 4 THEN
           IF ZFTP = ZFTPT THEN GOSUB NEXTFTP
           ZTOTAL2 = 0
           CLS
           PRINT "               QuickSearch Results for query: "; : COLOR 14: PRINT KEYWORD
           PRINT ""
           COLOR 15
           GOSUB PREV2
        END IF
NEXT3:
        IF ZTOTAL3 = 4 THEN
           IF ZNEW = ZNEWT THEN GOSUB NEXTNEW
           ZTOTAL3 = 0
           CLS
           PRINT "               QuickSearch Results for query: "; : COLOR 14: PRINT KEYWORD
           PRINT ""
           COLOR 15
           GOSUB PREV3
        END IF
END IF
IF D1 = "Q" THEN GOSUB MAINMENU
LOOP

'end of QuickSearch
