//*********************************************************************** // (c) Copyright 1998-2007 Santronics Software, Inc. All Rights Reserved. //*********************************************************************** // // File Name : html-suggest-test.wcc // Subsystem : Wildcat! RPC Ajax // Date : 11/22/07 // Version : 452.4a // Author : HLS/SSI // // Revision History: // Build Date Author Comments // ----- -------- ------ ------------------------------------------- // 452.4a 11/22/07 HLS - Created for Auto-Suggest plugin test // Simple sorted text file search //*********************************************************************** #include "htmlutil.wch" const crlf = chr(13)+chr(10) function NoItems(byval s as string) Print "no items: ";s HttpSetResponseHeader("","404 No Items Found") end function //---------------------------------------------------- // MAIN //---------------------------------------------------- dim srch as string = httpunescape(paramstr(1)) dim limit as integer = 0 srch = GetParamStr(paramstr(1),"q",srch) limit = GetParamInt(paramstr(1),"limit",limit) if srch = "" then NoItems(paramstr(1)) end end if srch = lcase(srch) dim srchLen as integer = len(srch) dim total as integer = 0 dim lines as string = GetText("wc:\http\public\test\baddomain.txt") dim i as integer = instr(lines,crlf) do while (i > 0) if (limit > 0 and total >= Limit) then exit do end if dim w as string = left(lines,i-1) lines = mid(lines,i+2) if lcase(left(w,srchLen)) > srch then exit do end if if lcase(left(w,srchLen)) = srch then inc(total) print w end if i = instr(lines,crlf) loop if total = 0 then NoItems(paramstr(1)) end end if