Forums

ASP

This topic is locked

need help to convert asp to php

Posted 22 Oct 2008 16:18:24
1
has voted
22 Oct 2008 16:18:24 bbyyaa bbyyaa posted:
function get_zip(x, y)
whichfile = server.mappath("zipcode/statefile.txt"
Set fs = CreateObject("Scripting.FileSystemObject"
Set thisfile = fs.OpenTextFile(whichfile, 1, False)
state = ""
do while not thisfile.AtEndOfStream
thisline = thisfile.readline
if left(thisline, instr(thisline, "+"-1) = y then
this = split(thisline, "&&"
for each thing in this
if len(thing)>5 then
specific = split(thing, "|"
if cint(x) >= cint(specific(1)) and cint(x) <= cint(specific(2)) then
state = specific(0)
exit do
end if
end if
next
end if
loop
thisfile.Close
if state <> "" then
whichfile = server.mappath("zipcode/" & state & ".txt"
set thisfile = fs.OpenTextFile(whichfile, 1, False)
dist = 9999
zip = ""
do while not thisfile.AtEndOfStream
thisline = thisfile.readline
this1 = split(thisline, "|"
cdist = pdistance(this1(2), this1(3), cint(x)*10, cint(y)*10)
if cdist < dist then
dist = cdist
zip = this1(0)
end if
loop
thisfile.close
if zip <> "" then get_zip = zip
end if
set thisfile = nothing
set fs = nothing
set whichfile = nothing
end function

Edited by - bbyyaa on 22 Oct 2008 16:21:50

Reply to this topic