;;=====================================================================================----- 
;Function   GetPage() - Deprecated in ITCG Coding - See URL() for full functionality 
; 
;Action     Loads an (uncached version of a) webpage into a variable. 
; 
;Author     Lonkero, Masken 
; 
;Version    1.1 - 2003/09/05 
; 
;History    1.0 - 2003/07/01 - Original Version. 
;           1.1 - 2003/09/05 - Suggestion by Bryce implemented. The UDF now changes 
;                              the IE  cache settings to make sure a non-cached page  
;                              is retrieved. The original cache setting is restored 
;                              after each call. 
; 
;Syntax    GetPage(STRING) 
; 
;Parameters 
;   STRING - REQUIRED - String 
;    - URL of the page you want to retrieve. 
; 
;Remarks 
;   Lonkero has helped me out with this one    I only added the Status bit, and 
;   posted it in a UDF-friendly format with a sample    
;   HTTP Status Codes: 
;   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/http_status_codes.asp 
;   For example, An unknown DNS name returns .Status = 12xxx (ex: 12007), and  
;   .Statustext = "Unknown" 
; 
;Returns    Response Text or HTTP Status Code 
;   * The Response text (non-cached version) if successful 
;   * Error code 1 along with the returned HTTP status code and status text if 
;     there was an error getting the page. 
; 
;Dependencies   KiX 4.02+, IE v.5+ 
; 
;Examples 
;   ; *** Get the webpage, and extract the title *** 
;   $myPage = GetPage("http://www.kixtart.org/cgi-bin/ultimatebb.cgi") 
;   IF @ERROR = 0 
;       $myPageTitle = SPLIT($myPage, "</title>")[0] 
;       $myPageTitle = SUBSTR($myPageTitle, INSTR($myPageTitle, "<title>") + 7, LEN($myPageTitle)) 
;       ? "Web page title: " + $myPageTitle 
;   ELSE 
;       ? "An error occured: " + $myPage 
;   ENDIF 
 
 
Function GetPage($_Url)
 
  Dim $_Rc
  Dim $_HTML
  Dim $_IECacheKey
  Dim $_IECacheVal
  Dim $_Exit
 
  $_Exit = 0				; prepare successful exit code 
 
  $_IECacheKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
 
  ; Preserve the current IE cache setting 
  $_IECacheVal = ReadValue($_IECacheKey, "SyncMode5")
 
  ; update the cache value if necessary 
  If $_IECacheVal <> 3
    $_Rc = WriteValue($_IECacheKey, "SyncMode5", "3", "REG_DWORD")
  EndIf
 
  ; create the object and get the URL content 
  $_Html = CreateObject("microsoft.XMLhttp")
  $_Html.Open("GET", $_Url, NOT 1)
  $_Html.Send
 
  ; check the response and return the page or error code 
  If $_Html.Status = 200
    $GetPage = $_Html.ResponseText 	; or ResponseBody 
  Else
    $GetPage = "HTTP Status Code: " + $_Html.Status + " (" + $_Html.StatusText + ")"
    $_Exit = 1		; prepare to return error state 
  EndIf
 
  ; restore the original cache state 
  $_Rc = WriteValue($_IECacheKey, "SyncMode5", $_IECacheVal, "REG_DWORD")
 
  Exit $_Exit				; exit with proper status 
 
EndFunction