QBSearch Source Code


'\ITECH\MISC\TQBFFIND\SEARCH
' Searches the QBasic Forum! Version 1.0
' (C) 2006 i-TECH and Kristopher Windsor

DEFLNG A-Z: CONST pcount = 129412, tcount = 26560
SCREEN 0: WIDTH 80, 25: DIM i(1 TO 32) AS STRING
OPEN "subjects.txt" FOR RANDOM AS #1 LEN = 128
OPEN "people.txt" FOR RANDOM AS #2 LEN = 32
OPEN "urls.txt" FOR RANDOM AS #3 LEN = 4
OPEN "threads.txt" FOR RANDOM AS #4 LEN = 4 'threads.txt has item #26561 (0)

GOSUB load
DO: GOSUB search: LOOP 'search GOSUB uses SYSTEM

search:
CLS : found = 0
LOCATE 3, 5: PRINT "Welcome to Kristopher Windsor's QBasic Forum Search Utility!"
LOCATE 5, 5: LINE INPUT "Find: ", s$
LOCATE 7, 5: PRINT "Searching..."

FOR a = 1 TO LEN(s$): SELECT CASE MID$(s$, a, 1): CASE ".", ",", CHR$(34): MID$(s$, a, 1) = " ": END SELECT: NEXT a
s$ = LTRIM$(RTRIM$(LCASE$(s$))): IF s$ = "" THEN SYSTEM ELSE s$ = s$ + " "
                                 
OPEN "results.htm" FOR OUTPUT AS #5
PRINT #5, "

"
PRINT #5, "QBasic Forum Search: " + s$ + ""
PRINT #5, ""
PRINT #5, "
" PRINT #5, "

Search Results for " + s$ + "

" PRINT #5, "
This page was generated at " + TIME$ + " on " + DATE$ + " by Kristopher Windsor's QBasic Forum Search Utility." PRINT #5, "You may need to refresh this page if it was not reopened for your latest search.
" PRINT #5, "" a = 0: whichi = 0: whichp = 0: GET #4, 1, nthreadpost DO pa = a: a = INSTR(a + 1, s$, " ") IF a - pa > 1 THEN whichi = whichi + 1 IF whichi > 32 THEN SYSTEM i(whichi) = MID$(s$, pa + 1, a - pa - 1) END IF LOOP UNTIL a = 0 'main search code FOR a = 1 TO tcount 'loops for each thread IF (a MOD 200) = 0 THEN LOCATE 9, 5: PRINT LEFT$(STRING$(INT((a * 1!) / tcount * 72), CHR$(219)) + SPACE$(72), 72) threadpost = nthreadpost: GET #4, a + 1, nthreadpost searchme$ = "": whichtp = whichp + 1: summary$ = "" DO whichp = whichp + 1 GET #1, whichp, subject$ 'adds subject to search string and strings for web page searchme$ = searchme$ + subject$ + " " IF whichp = whichtp THEN threadtitle$ = subject$ ELSE GET #2, whichp, name$ IF whichp - whichtp < 6 THEN summary$ = summary$ + "
" + subject$ + " (" + name$ + ")" END IF GET #3, whichp + 1, url LOOP UNTIL url = nthreadpost 'both will equal zero at end of files matched = 0: searchme$ = LCASE$(searchme$) FOR b = 1 TO whichi IF INSTR(searchme$, i(b)) THEN matched = matched + 1 NEXT b IF matched = whichi THEN GOSUB match NEXT a PRINT #5, "

" PRINT #5, "
 + CHR$(34) +
" PRINT #5, "
Hosted by www.Geocities.ws

" CLOSE #5 IF found THEN LOCATE 13, 5: PRINT "Search Complete!" SLEEP 1: SHELL "CMD /C START " + browser$ + " RESULTS.HTM" ELSE LOCATE 11, 5: PRINT "No Posts Have Been Found!" END IF DO: LOOP UNTIL INKEY$ = "" FOR a = 1 TO 10 LOCATE 13, 5: PRINT "Restarting in" + STR$(11 - a) + " seconds. Press [Escape] to quit." DO: LOOP WHILE INKEY$ > "": SLEEP 1: k$ = INKEY$ IF k$ = CHR$(27) THEN SYSTEM ELSE IF k$ > "" THEN a = 10 NEXT a RETURN load: ON ERROR GOTO missingprefs: OPEN "qbsearch.txt" FOR INPUT AS #5: ON ERROR GOTO 0: LINE INPUT #5, browser$: CLOSE #5 RETURN match: IF whichp - whichtp > 5 - 9 THEN summary$ = summary$ + "
(" + LTRIM$(STR$(whichp - whichtp)) + " Replies)" found = found + 1: IF found < 100 OR (found MOD 100) = 0 THEN LOCATE 11, 5: PRINT LTRIM$(STR$(found)) + " Posts Found" GET #2, whichtp, name$: GET #3, whichtp, url PRINT #5, "|
|Thread" + STR$(a) + " (Post #" + LTRIM$(STR$(whichtp)) + ")" + threadtitle$ + "" + summary$ + "" + name$ + "|
|" RETURN missingprefs: CLS LOCATE 3, 5: PRINT "Please enter the name of your browser, such as IEXPLORE or FIREFOX." LOCATE 7, 5: PRINT "(This name can be modified through QBSearch.txt if necessary.)" LOCATE 5, 5: LINE INPUT "Browser name: ", browser$ IF browser$ = "" OR LEN(browser$) > 16 THEN browser$ = "IEXPLORE" OPEN "qbsearch.txt" FOR OUTPUT AS #5: PRINT #5, browser$: CLOSE #5 RESUME

(C) 2006 i-TECH
Hosted by www.Geocities.ws

1