//*********************************************************
// aCGI Project: Zip Code lookup utility (aCGI Sample)
//*********************************************************
// Author: Michael McVicker
// Date: © 01/02/03 - All Rights Reserved
// FileName: ZipCode.prg
//
// Last Update: 01/02/03 by MMM
//
//*********************************************************
#Include "aCGI.ch"
//*******************************
Procedure Main ( )
//*******************************
Local oCGI := aprCGI():New()
Local cZip := oCGI:GetVar("ZipCode") Local cDir := "C:\DataPath\" // Directory containing the database and indexes
Local aResults := {}, nStart := 0, nEnd := 0
Local nMaxReturn := 100
nStart := Seconds()
dbUseArea(,,cDir+"ZipCode.dbf","Zip",.T.)
OrdListAdd(cDir+"ZipCode.ntx")
cZip := oCGI:GetVar("ZipCode")
If !Empty(cZip)
aAdd(aResults,{"<b>Zip Code</b>","<b>State</b>","<b>City</b>","<b>County</b>"})
If dbSeek(cZip) // Found
Do While Zip->ZipCode = cZip .and. Len(aResults)-1 < nMaxReturn
aAdd(aResults,{Zip->ZipCode,Zip->State,Zip->City,Zip->County})
dbSkip()
EndDo
EndIF
Endif
If Len(aResults) > 1
oCGI:CSS("/Default.css")
oCGI:CSS("/ZipCodeStyle.css")
oCGI:Start("text/html")
oCGI:Header("Results for Zip Code: "+cZip)
oCGI:Body()
oCGI:TableStart("Center",,,1,3,0)
oCGI:Row(ltrim(str(Len(aResults)-1))+" out of "+ltrim(str(LastRec()))+" found.",,4)
oCGI:Data(aResults)
nEnd := Seconds()
oCGI:Row('<font size="1">Total processing time (including database search): '+ ;
ltrim(str(nEnd-nStart))+" seconds.</font>","Center",4)
oCGI:Row(oCGI:BackLink("Go Back", "#660000",.F.,.F.),"Right",4)
oCGI:TableEnd()
oCGI:Footer()
Else
// Display Default Failure Screen
oCGI:CSS("/Default.css")
oCGI:CSS("/ZipCodeStyle.css")
oCGI:Message("No valid Search criteria was entered.","<b>Invalid request</b>","Center",.T.)
EndIF
oCGI:Destroy()
dbCloseAll()
Return
|