a use-case code example
Code:
alias example {
  var %Error


  ;; Create an instance of MS provided http requester
  ;; and use it to request http://example.com
  .comopen example MSXML2.SERVERXMLHttp.6.0
  if (!$com(example) || $comerr) {
    %Error = Unable to create an instance of MSXML2.SERVERXMLHttp.6.0
  }
  elseif (!$com(example, open, 1, bstr, GET, bstr, http://example.com, bool, false) || $comerr) {
    %Error = Unable to initialize the request
  }
  elseif (!$com(example, send, 1) || $comerr) {
    %Error = Request failed
  }
  else {



    ;; To get the response as purely text, this works flawlessly
    if (!$com(example, responseText, 2) || $comerr) {
      %Error = Failed to retrieve response text
    }
    else {
      noop $com(example, &example).result
      echo -s Reponse Text( $+ $bvar(&example, 0) $+ ): $bvar(&example, 1, 4000).text
      echo -s -
      bunset &example
    }


    ;; But to retrieve the response body as binary data
    ;; This echos an empty string due to mIRC being unable
    ;; to handle VT_ARRAYs
    if (!$com(example, responseBody, 2) || $comerr) {
      %Error = Failed to retrieve response text
    }
    else {
      noop $com(example, &example).result
      echo -s Reponse Body( $+ $bvar(&example, 0) $+ ): $bvar(&example, 1, 4000).text
      echo -s -
      bunset &example
    }

  }


  ;; Handle errors
  :Error
  if ($error) {
    %Error = $v1
    reseterror
  }
  if ($com(example)) {
    .comclose example
  }
  if (%Error) {
    echo -s Error: $v1
  }
}


I am SReject
My Stuff