hr

Archive for December, 2004

Playing with food

Sunday, December 26th, 2004

What a birthday I had this year.

I was given a Nutrigrain E.T. from a work colleague. Although I have had a life long fear of that horrifying (and most probably evil) movie character, I was impressed with the likeness and hopeful that once my colleague forgot about the gift I could flog it on ebay.nutriET
The next present I received was a tin of wasabi peas which I ate while admiring my new nutri-friend. Due to my equal mix of happiness and horror caused by simultaneosly thinking about my birthday and the ugly freak that Spielberg decided to unleash upon my untainted mind all those years ago, I became distracted and dropped a few of the wasabi peas on the floor.

As I picked up the last of the so-undeservedly-wasted peas, I noticed that it held a passable likeness to Waldorf (or is it Statler?), of “The Muppet’s Statler and Waldorf” fame. Wow! What a birthday this was shaping up to be.
nutriET

Unfortunately my plans for seeking my fortune with these babies on ebay went bad that very eve, after I accidently ate the wasabi pea, and a rat or a bunch of cockroaches or something of similar capabilities ate half of E.T. Oh well.

I also got a bunch of other cool stuff for my birthday, but none of them looked like celebrities. I wonder if I could get Steven Spielberg to reimburse me for the dropped wasabi peas.

What’s that VBScript Object?

Thursday, December 23rd, 2004

I recently needed to check for the existance and type of a VBScript object returned from a function. Perhaps you need to too.

I thought there must be a standard property of all objects, like, maybe, object.type or object.size or object.id or something. But I couldn’t dig up such a thing. I needed to check what kind of object was being returned - a Microsoft.xmlhttp XML object, or a “Nothing” object….

My “GetXMLObjectViaHTTP” function it was grabbing some xml and looking for errors like so:

If Err.number = 0 Then
    Set GetXMLObjectViaHTTP = objXMLDocument
Else
    Set GetXMLObjectViaHTTP = nothing
End If

If an error occurred in the function I had to set the return type to “nothing” which is an object (apparently). I originally set the return value as an error number, then just “”, but both wont work because of how I’m using the object returned:

Set objXML = GetXMLObjectViaHTTP( strXMLUrl )

You end up with Set objXML = “-1″, giving the error “Object required: '[number: -1]‘”

I was going to make a customer “error” class to handle it (which I ended up doing anyway…), but first I had a look around for other’s solutions. I couldn’t find anything, though eventually came across a VBScript function “TypeName()”. Running “Response.write( TypeName( objXML ) )” gives:
“DOMDocument” if it was okay, and “Nothing” if it something broke. Which is like, totally testable.

I’m too lazy to look up when TypeName was introduced to VBScript (maybe since forever), but the server I’m testing on is version 5.7426.

UPDATE: I found a couple-a more cool things: VarType() returns a type code, rather than a name. Google for the type codes, they’re everywhere unlike this function name.

Also, I never realised that you could do If objMyObject Is Null. I thought “Is Null” was only a VB construct. Anyhoo, thats useful in object detecter-ing too.