Archive

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

Start MSD.

Go to “Debug” -> “Processes”.

Find the appropriate process, use the “Title” column to help.

Click “Attach”.

When the “Attach to Process” screen is displayed, click “OK”.

Click “Close”

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

Go to “Debug” -> “New Breakpoint”

Type in the name of a function, sub-routine or event that you want to trap.

Perform the actions in IE that would cause the function where you inserted the breakpoint to fire.

You should then be directed to MSD with the source code of the lines where you inserted the break point.

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

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

Huzzah!

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.

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?

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

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!

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!