Subject: functions for working with the internet Date: Monday, April 08, 2002 8:34 AM /* functions for working with the internet rich@autotraker.com www.autotraker.com examples with each function these functions are based on information gathered from the dBase newsgroups and elsewhere. Of course there are other ways to alter these functions to give to added functionality. See InternetConnected and HowInternetConnected. These are examples of two different ways to use the same API. URLExists is an example of combining several functions to give added usability. */ function URLExists // tells you if a URL exists // ? URLExists("http://www.autotraker.com/index.html") parameters URL local cTempName, lResult URL=iif(left(URL,7)<>"http://","http://"+URL,URL) if PathIsURL(URL) and InternetConnected() cTempName = fUnique("Temp????.txt") lResult = DownloadToFile(URL,cTempName) erase cTempName return lResult endif return false function InternetConnected // Are you connected to the internet ? // ? InternetConnected() If type("InternetGetConnectedState")#"FP" Extern cLong ; InternetGetConnectedState; (cLong,cLong) "wininet.dll" endif return InternetGetConnectedState(0,0)>0 function HowInternetConnected local result If type("InternetGetConnectedState")#"FP" Extern cLong ; InternetGetConnectedState; (cLong,cLong) "wininet.dll" endif result = InternetGetConnectedState(0,0) if result = 1 return "Connected via modem" elseif result = 2 return "Connected via Lan/Cable" endif return "Not Connected" function DownloadToFile // Downloads a URL to a local file // ? DownloadToFile("http://www.autotraker.com/index.html","Temp.htm") parameters URL, File if file("&file.") erase "&file." endif if type('URLDownloadToFile') # "FP" extern culong URLDownloadToFile(cptr,cstring,cstring,; culong,culong) URLMON.DLL from "URLDownloadToFileA" endif nHResult = URLDownloadToFile(null,URL,File,null,null) return iif(file("&file."),true,false) function PathIsURL // Is the path a good URL // ? PathIsURL("http://www.autotraker.com") parameters URL if type('PathIsURLA') # 'FP' extern CLOGICAL PathIsURLA(CSTRING) ; "shlwapi.dll" from "PathIsURLA" endif return PathIsURLA(URL) function GoWeb // starts internet explorer and go to a URL // GoWeb("http://www.autotraker.com") parameters cWeb #define SW_HIDE 0 if type("ShellExecute") #"FP" extern cHandle ShellExecute; (cHandle, cstring, cstring, cstring, ; cstring, CINT) SHELL32 from "ShellExecuteA" endif return ShellExecute(0,"open",cWeb,null,null,SW_HIDE)>32