Monday, October 26, 2009

XML Extractor

Sub PullFromInternet()'The web address at which xml is storedURL = "http://jjh.virtual.vps-host.net:8080/restdemo/services/customers/0"Dim HttpReq As Object'Declare the request for information over the internetSet HttpReq = New WinHttpRequest'Specify the type of HTTP requestHttpReq.Open "GET", URL, False'or use GET instead of POST'Specify the type of content that can be recievedHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"'Send the actual requestHttpReq.Send'HttpReq.send postmydata'Note - if using GET set postmydata to ""Dim response As StringDim tag As StringDim data As Stringtag = "address"response = HttpReq.ResponseTextMsgBox (extractor(tag, response))End SubFunction extractor(tag As String, response As String) As StringDim tagLength As IntegerDim mypos As IntegerDim myposEnd As Integermypos = InStr(1, response, "<" & tag)myposEnd = InStr(1, response, "<" &"/" & tag)tagLength = Len(tag) + 2Dim address As Stringextractor = Mid(response, mypos + tagLength, (myposEnd - mypos - tagLength))End Function

Parsing XML in Visual Basic

Once I recieve the XML from a REST web servce, I need to be able to extract the useful information about of the XML document. Some useful links along that line are:

Sunday, October 25, 2009

Calling a REST Service from VB

I did not have much luck calling the Yahoo REST service, so I created my own web service using the MyEclipse tutorial and tested it out. The VB code to call the REST service is as follows:
Sub Macro1()url = "http://jjh.virtual.vps-host.net:8080/restdemo/services/customers/0"Dim HttpReq As ObjectSet HttpReq = New WinHttpRequestHttpReq.Open "GET", url, False 'or use GET instead of POSTHttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"HttpReq.send'HttpReq.send postmydata 'Note - if using GET set postmydata to ""MsgBox (HttpReq.responseText)End Sub
Now the next challange is to get the Microsoft XML parser working.

Thursday, October 22, 2009

How to Post and Get from HTTP using VB6

Thanks to some help from Doc's Coding, I was able to get Microsoft Excel 2000 to do a GET request.

I had to add a reference by going to Tools|Reference, then select Microsoft winhttp service version 5.1

Then I added the following code:
Sub Macro1()'' Macro1 Macro' Macro recorded 22/10/2009 by John Hufnagel'url = "http://www.google.ca/"postmydata = "variable=data&variable2=data2"Dim HttpReq As ObjectSet HttpReq = New WinHttpRequestHttpReq.Open "POST", url, False'or use GET instead of POSTHttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"HttpReq.send postmydata'Note - if using GET set postmydata to ""MsgBox (HttpReq.responseText)End Sub
Now that I have the basic GET working, the next challange is to make a Yahoo! Web Service REST Call

Friday, October 16, 2009

Are Upper and Lower control limits the same as tolerances

I was teaching about Statistical Process Control (SPC) and control charts today and a student asked an interesting question: Are the upper and lower control limit the same as the design tolerances on a manufactured part?

The answer is that they are not the same: the upper and lower control limit are based on the statistical information obtained from observing the process, while the design tolerances are what the designer wants to achieve.

This leads to the next question: what is the relationship between tolerances and upper and lower control limits? This hits on the core philosophy behind SPC. Traditionally people like to inspect quality into a part. To do this, every piece must be inspected and the rejects discarded - there is no thought put into the process that created these rejects. It can be a lot of cost and time to inspecting every part. In some ways it is easy to image every manufactured part being inspected, but what about services? Quality is also important in service. How can each service be inspected before it is delivered? Lets say the service is a bank teller. It is completely unfeasible for a third person to inspect every thing the teller is doing before the service is actually rendered to the customer.

This is where SPC comes in. SPC is not about inspecting every single part to see whether or not they are in tolerance, rather SPC is about monitoring the process and improving the process so that the process will automatically provide the desired quality. In other words, with SPC the process can be improved so that the upper and lower control limits fall within the desired tolerance.

This is a radically different way to look at manufacturing and servicing processes. With the old way of inspecting every part, people continually work in fear about ever making a mistake. The fear of an error is the predominate thought on their mind.

With an SPC controlled system, the focus is on trying to understand the process, where there is potential errors or defect (deviations from the desired outcome), and improving the process so the desired outcome can be achieved more predicatably.

Tuesday, October 13, 2009

My Alter Ego

I was watching the football game yesterday between Calgary and Montreal. The announcer kept talking about John Hufnagel, the coach of the Calgary Stampeders. It is nice hear my name on TV even if the Stampeders lost.