Monday, October 26, 2009

Good Solidworks resources

Lennys SolidWorks

XML Extractor


Sub PullFromInternet()

'The web address at which xml is stored
URL = "http://jjh.virtual.vps-host.net:8080/restdemo/services/customers/0"

Dim HttpReq As Object

'Declare the request for information over the internet
Set HttpReq = New WinHttpRequest

'Specify the type of HTTP request
HttpReq.Open "GET", URL, False
'or use GET instead of POST

'Specify the type of content that can be recieved
HttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

'Send the actual request
HttpReq.Send
'HttpReq.send postmydata
'Note - if using GET set postmydata to ""

Dim response As String
Dim tag As String
Dim data As String
tag = "address"
response = HttpReq.ResponseText

MsgBox (extractor(tag, response))

End Sub

Function extractor(tag As String, response As String) As String
Dim tagLength As Integer

Dim mypos As Integer
Dim myposEnd As Integer
mypos = InStr(1, response, "<" & tag)
myposEnd = InStr(1, response, "<" &"/" & tag)
tagLength = Len(tag) + 2
Dim address As String
extractor = Mid(response, mypos + tagLength, (myposEnd - mypos - tagLength))

End Function

Just in case you thought that seeing is believing

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 Object
Set HttpReq = New WinHttpRequest

HttpReq.Open "GET", url, False
'or use GET instead of POST

HttpReq.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 Object

Set HttpReq = New WinHttpRequest

HttpReq.Open "POST", url, False
'or use GET instead of POST

HttpReq.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.

Thursday, October 8, 2009

Drop Down Menus

Drop down menus on web pages add an elegant style to the presentation, but they can be very quirky. Commonly, the menus are build with lists and using CSS that control the visiblity of list items based styles estalished for the the hover property in CSS.

Another method that I have seem demonstrated quite eligently at The Ojibway Club is to use a combination of tables and divs. That site was developed by The Big Brain.. The source code for that page shows a very clean layout of the menus. This was created with Joomla in conjunction with a third party joomla menu system.