Page 1 of 1

translate code to fivewin : internet IP

Posted: Fri May 29, 2009 5:49 pm
by tnhoe
Hi all,

plz help to translate this piece of code into Fivewin,

FUNCTION MyWanIP
LOCAL oHTTP as "winhttp.winhttprequest.5.1"
LOCAL cHTML
oHTTP=NEWOBJECT("winhttp.winhttprequest.5.1")
oHTTP.Open("GET","http://www.ip-adress.com/",.f.)
oHTTP.Send()
cHTML = ohTTP.ResponseText
RELEASE oHTTP
RETURN STREXTRACT(cHTML,"My IP address: ","</h2>")

Thanks.
Regards
Hoe

Re: translate code to fivewin : internet IP

Posted: Sat May 30, 2009 1:05 am
by nageswaragunupudi

Code: Select all

function MyWanIP

   local oHttp, cHtml

   oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
   oHttp:Open( "GET", "http://www.ip-adress.com/", .f. )
   oHttp:Send()
   cHtml := oHttp:ResponseText()
   cHtml := StrExtract( cHtml, "My IP address: ", "</h2>" )
   msginfo( cHtml )

return cHtml

static function StrExtract( cText, cAfter, cBefore )

   local cRet  := SubStr( cText, At( cAfter, cText ) + Len( cAfter ) )
   local n

   if ( n := At( cBefore, cRet ) ) > 0
      cRet  := Left( cRet, n - 1 )
   endif

return cRet

 

Re: translate code to fivewin : internet IP

Posted: Mon Jun 01, 2009 5:41 am
by tnhoe
ok, thanks a lot.