Roland Wingerter
2008-12-06 10:02:16 UTC
Roland W. wrote >
*** Send request to google.com and save results to text file. ***
cStr1 = "http://www.google.com/search"
cStr2 = [hl=en&q=dbase&btnG=Google+Search]
objHttp = new OleAutoClient("Msxml2.XMLHTTP.4.0")
objHttp.open( "GET", cStr1 , false )
objHttp.Send(cStr2)
if objHttp.status == '200'
bSuccess = write2File(objHttp.responseText, "http_responseText.txt")
if bSuccess
* modi file "http_responseText.txt"
* The line above will throw an error:
* "contains line longer than 4096 characters"
// Open file using program associated with *.txt extension
openFile(set("Directory")+"\http_responseText.txt")
else
msgbox("Could not write repsonse text to file","Error")
endif
// inspect(objHttp)
endif
Function write2File( cString, cFileName )
local cString, bSuccess
bSuccess = false
try
oFile = new File()
oFile.create( cFileName, "W")
oFile.puts(cString)
oFile.close()
bSuccess = true
catch(exception e)
? e.code, e.message
endtry
return bSuccess
Function openFile( cFilePath )
set proc to :dUFLP:miscapi.prg addi
openURL(cFilePath)
return
Below is an enhanced version which saves the responseText to a file and
then displays it in an editor.
----------then displays it in an editor.
*** Send request to google.com and save results to text file. ***
cStr1 = "http://www.google.com/search"
cStr2 = [hl=en&q=dbase&btnG=Google+Search]
objHttp = new OleAutoClient("Msxml2.XMLHTTP.4.0")
objHttp.open( "GET", cStr1 , false )
objHttp.Send(cStr2)
if objHttp.status == '200'
bSuccess = write2File(objHttp.responseText, "http_responseText.txt")
if bSuccess
* modi file "http_responseText.txt"
* The line above will throw an error:
* "contains line longer than 4096 characters"
// Open file using program associated with *.txt extension
openFile(set("Directory")+"\http_responseText.txt")
else
msgbox("Could not write repsonse text to file","Error")
endif
// inspect(objHttp)
endif
Function write2File( cString, cFileName )
local cString, bSuccess
bSuccess = false
try
oFile = new File()
oFile.create( cFileName, "W")
oFile.puts(cString)
oFile.close()
bSuccess = true
catch(exception e)
? e.code, e.message
endtry
return bSuccess
Function openFile( cFilePath )
set proc to :dUFLP:miscapi.prg addi
openURL(cFilePath)
return