Archive for the ‘Programming’ Category

Attaching Microsoft Script Debugger to a Running Process

October 7th, 2010 No comments

OK, I’ve just learnt how to do something that I’m going to find very useful in the future! I’ve wanted to do this for a while and didn’t know, but necessity is the mother of invention (or investigation in this case.)

Here’s the scenario. I have a running Internet Explorer session connected to a Live environment. I cannot change the Live code to add in a “Stop” statement. That Internet Explorer session is actually a hosted version of the IE ActiveX control inside of a custom executable. I have a VBScript bug and I need to see what’s happening.

So, what I need to do is to attached Microsoft Script Debugger (MSD) to the running IE session, and force a breakpoint in the code. Here’s how….

  1. Start MSD.
  2. Go to “Debug” -> “Processes”.
  3. Find the appropriate process, use the “Title” column to help.
  4. Click “Attach”.
  5. When the “Attach to Process” screen is displayed, click “OK”.
  6. Click “Close”

That will now attach you to the correct process. All you need to do now is to add a break point.

  1. Go to “Debug” -> “New Breakpoint”
  2. Type in the name of a function, sub-routine or event that you want to trap.
  3. Perform the actions in IE that would cause the function where you inserted the breakpoint to fire.
  4. You should then be directed to MSD with the source code of the lines where you inserted the break point.
  5. Step-Over, Out-of or Into as much as you’d like!

Simple really – just needed five minutes of Googling and playing around in MSD!

The End of :hover

June 8th, 2010 No comments

This article from Andy Croll is something that I hadn’t thought about before.

The End of :hover.

Basically, if you have a touch enabled device (like iPhone, iPad, Android, etc), you can’t use the :hover CSS attribute.

Andy also points out that the onmouseover etc items just don’t work either, and the same also applies to Flash.

Categories: Computers, iPhone, Programming Tags: , , , ,

Uh-Oh. Someone needs to learn some programming principles

October 5th, 2009 No comments

Changing the Default Java Swing Appearance

September 24th, 2009 No comments

The other day, I was playing with ArgoUML at work for a little bit of research.

When it opened up, it had that god-awful “Metal” look that all Java programs get. I knew that it was possible to change the appearance of Swing object programmatically so that they can have a native appearance and wondered if it was possible to change the default appearance.

I realised this morning that I had seen ArgoUML, with a Windows appearance, in a screenshot on their website. That made me realise that it must be possible to change the default setting.

Cue quick googling session!

That turned up this somewhat unhelpful page from Sun. This page explains how to do it programmatically, but at the bottom explains how to change the default setting. Unfortunately, the instructions on how to change it are practically non-existant (along the lines of “change this setting in this file. Create the file if it doesn’t exist” – no explanation of what to change it to, what the format of the file should be, etc.)

Fortunately, it also links through to this Java utility (German original, Google Translation) which lets you change the setting.

I ran this, chose my default setting, saved the file into my $JAVA_HOME/lib directory and now it works!


Leads me to question why there isn’t some Java settings utility bundled with the JRE in the first place!

Another interesting thing about the Sun Java page I listed earlier is that it argues

The underlying question is: should a Java program look and feel native anyway? One of the great ideas behind Java has always been “write once, run anywhere.” Taking that into account, shouldn’t a Java program look and feel the same, regardless which platform it runs on? Wouldn’t it be desirable if all Java programs had the same appearance?

Err, I would say “No”. The majority of the time, a user expects an application to look and feel like all of the other applications on their system. The vast majority of computer users do not care if I have written a program in Java, C, C++, Delphi, D, whatever – they just want it to work – hell most computer users probably haven’t even heard of Java! So why force Java to look differently? Default it to look like every other application on their system.

Categories: Computers, Programming Tags: ,

VBScript function IsNumeric

August 18th, 2009 No comments


Last night, we discovered that the VBScript function “IsNumeric” is a little more clever than you’d like, but there’s also no simpler version either.

Consider the following scenario.

We have the user input in a bit of text on screen. We need to process that (client-side), and part of that processing needs to find out if it is a number or not (i.e. if it’s a number, do this, otherwise, do that.)

Last night, we encountered a problem with the word “65d1” – clearly, it’s not a number (the “d” gives that away,) however, IsNumeric says that it is. If you CInt(“65d1”) you get 650. WTF?

A little more testing reveals the following:

CInt("65d0")  => 65
CInt("65d1")  => 650
CInt("65d2")  => 6500
CInt("65d-1") => 6

So obviously that “d” refers to “*(10 ^ following number)” – however, I can’t find a reference for that.

A bit of googling turns up this page , which shows that adding a space at the front doesn’t stop it from being classed as numeric.

The only real clue to what is going on is to read, and interpret, the MSDN reference page which states:

Returns a Boolean value indicating whether an expression can be evaluated as a number.

And there-in lies the answer – that expression can be evaluated as a number, not that it is a number.

Fortunately, there is an implementation listed on the first page which shows you an alternative way to get the job done.

I’m now wondering if there are other things that you can enter that will affect an number in that way. I tried


but that just errored. I’m wondering whether “e” has a similar effect.

Update: Yes, “e” (at first glance) appears to have an identical effect to “d”.

CInt("65D1") => 650
CInt("65D1") => 6500
CInt("65E1") => 650
CInt("65E1") => 6500

Why do Americans make up words?

August 10th, 2009 No comments

Check out the comment on the post below:

vagif comments on Hypothetical situation: if someone were walking down the street one day just minding their own business and they stumbled upon a lost flash disk with the entire Windows7 source code on it … What do you think it would be worth?… To Microsoft… To Google … To Apple?.

Google and Apple officials will immediately distantiate themselves from you.

“Distantiate”??? LOL, the word is “distance”, you pillock.

Americans, you’re so funny.

Categories: Computers, Programming Tags:

Debugging Client-Side VBScript

August 4th, 2009 No comments

Having used client-side VBScript for years at work, I discovered the joys of the Microsoft Script Debugger several years ago. Unfortunately, until now, I’ve been unable to get the debugger to invoke when I desired (rather than having to wait for a crash!)

Several times, I ran across web pages saying that you just type “debugger” – however that only works with Javascript and not VBScript. I also found loads of references to Server-side debugger with ASP.Net – again that doesn’t work with client side.

But, finally, today I managed to find an article which actually explains the process, and marvellously, it’s not difficult and it’s (logically) a one liner.

So I can reveal that to invoke the debugger in client-side VBScript, all you type is…..



RESTful Webservices

July 14th, 2009 No comments


Someone’s finally done the decent thing, read the book and then consolidated it online!

REST – a quick summary

Categories: Computers, Programming Tags:

Time to Delete

July 13th, 2009 No comments

Argh! I’ve just read an article that I can’t help but think is the most useful sounding useless idea ever.

Called “Time to Delete“, it’s an idea for an extension to Windows, and subsequent boiler plate code for an implementation, that lets you indicate the date and time that a file or folder should be deleted.

Now, while this sounds like a good idea, it’s actually not that useful. Think about it. How often do you know precisely when you’ll be able to delete a file in the future? You don’t, most of the time. It’s mostly around events happening, not dates and times, for example take the event of “Delete this when this project is completed.” What happens if the project overruns? You’ve got to remember to go back and remove that clause, otherwise, you’re hard work will disappear two weeks before the project actually ends.

And besides, a lot of the time, you don’t want to delete something, merely archive it to DVD/Flash Drive/Central Server/etc. I know that for my projects at work, deleting data is one of the worst things I can do – at least for a year afterwards, so moving it to the central server works immensely well!

What also really annoys me about this article is that it implements the code as a “Send To” extension in Windows. That’s the “Send To” option when you right click on a file or folder. Let’s just review the Grammar of that sentence: “Send To Time to Delete”. ARGH! Surely, you implement it is a shell extension so that it appears in the properties menu as it’s own item!

Categories: Computers, Programming Tags:

SQLite Concurrency

April 11th, 2009 No comments

Recently, I wrote an application that used a SQLite database and wrote data into a common database rapidly, over several connections.

I initially wrote the application to use one thread, and only one database connection, but as I improved the software, I converted it to use multiple threads with one connection per thread.

I quickly ran into the problem though that the database quickly became locked – one thread would block out the other and would not return the lock. It wasn’t consistent though as to which thread would be blocked – it was usually the second thread, but not consistently.

Having read a post from the pysqlite mailing list, I think it explains the problem a little bit more accurately, and kind of exaplins a solution. Although, it does seem a little bit drastic (essentially, reconnect everytime you need to run a concurrent query).

I’m now very interested to find out whether this will cure my problem. It does seem a bit drastic, and quite IO intensive, but it’s worth a shot!

I’ll let you know my mileage….