Did anyone else have trouble reading the Delphi 2005 CDs?

I tried installing Delphi 2005 a couple of weeks ago, but I started getting read errors partway through disc 2. We have four copies of D2k5 at the moment, so I grabbed one of the other packages and tried its disc 2. Same error, though at a slightly different place. So either there’s a problem with my CD drive, or there was a problem with that batch of CDs.

I came back to it earlier this week, with a plan to find out whether the discs were readable or not. The CD worked just fine if I just popped it in and browsed through it; it could read the directories just fine, just not the contents of some of the files. So the problem was only with some of the later tracks.

So, I did something that would be guaranteed to read every track: I ripped the CDs into ISO images.

(And no, I’m not using those ISOs to install on more than one computer, or to share with friends, any more than I would have used the original discs for the same thing. If I were pirating, do you think I’d be blogging about it? Borland has my contact info from my BorCon registration, and Danny Thorpe knows me by sight.)

So anyway, I put in the first CD and started ripping. And guess what? Now my PC couldn’t even get all the way through disc 1. Evidently it didn’t try to read all the tracks when I first tried to install, but some of them were bad nonetheless. (Or the drive had problems, and they’ve gotten worse. Hard to say, but I was stuck in either case.)

I tried the same thing from a different computer, and still got errors. But I kept hitting Retry, and eventually it successfully read the whole disc. (My computer never did finish reading disc 1 in its entirety, even if I did keep hitting Retry.)

But now I was in good shape: even if my computer couldn’t read the original discs, it could read the ISOs. One of our other engineers had already used Daemon Tools, a shareware program that lets you mount an ISO image as a virtual CD drive. I found another app, this one from Microsoft, that does the same thing for free; it’s called “Virtual CD-ROM Control Panel”, it only runs on Windows XP, and it’s downloadable from this Microsoft server. Virtual CD fit the task admirably, and Delphi 2005 is now installed on my work PC. Hooray! (Now I just need to find some time to actually run the thing.)

So… back to the question I posed in this post’s title: Has anyone else had troubles reading the D2k5 install discs? I think the license agreement includes a warranty on the CD media (haven’t checked, but they usually do), but I’m still not sure whether it’s the media or my drive that’s the problem.


Dan Miser posted some links to articles on multithreading. I’ve already read “Multithreading – the Delphi Way“, but “Waking from Threadmare” was new to me, so I spent a few minutes browsing through it. Methinks I’m going to have to spend some time reading it in more depth.

One interesting tidbit in “Waking from Threadmare” was a new take on null objects. The author suggests making all the public methods non-virtual, and starting each one with “if Self = nil then Exit;“. Then “nil” becomes a null object — you can call methods on a nil reference, and it just works. Obviously this only works in Delphi for Win32; in other languages, or in .NET, you would have to use a proper null object. But it’s still an intriguing idea.

His system for inter-thread communication looks very intriguing. It only allows status reporting, so I’m wondering how you have your thread return data when it’s done (why doesn’t Finish take a data object?), but it still looks well worth some more digging. It should apply to .NET, too (maybe I can use it in DGrok).



I skipped my Adderall over the Christmas weekend, since I was running low and didn’t have a refill yet, and wanted to save it for work days. (Insurance doesn’t really get it that I’m taking two pills a day, not one — but Adderall doesn’t come in anything bigger than a 30mg pill, so I’m stuck. The doctor says he got a waiver from insurance approving the two-a-day, but the department that approves prescriptions doesn’t seem to know about it yet.) I’ve also been skipping the lithium until I’m convinced I’ve gotten myself rehydrated, which hasn’t happened yet.

So, three days without Adderall. Then I took my usual 60 mg this morning.

Whoo. Now I’m thinking I should’ve phased it back in. My hands (my whole arms) are shaking, kinda like the way-way-too-much-coffee jitters. I can feel my heart pounding (I just checked, and my resting pulse is about 120 at the moment). You know the head-rush you sometimes get when you stand up too fast? I’ve gotten that once this morning while I was sitting still. And I feel like I have to dash frantically around because there’s so much to do. (It’s definitely going to be a hyperfocus day.)

I don’t think this is expected behavior. Definitely gotta talk to the doc about it. Either this is normal if I’ve been off it for a while, or I’m on too high a dose. (Insurance would certainly be happier if I dropped back to a lower dose.)

I dunno. Adderall is classed as an amphetamine (that’s probably part of why insurance is cautious about it). Is this how people feel when they take speed? Somehow, I don’t see the appeal.


Ah… long weekend. (Sigh… cold basement.)

So there’ve been a couple of times at work lately when it would’ve been nice to have some code that would do diffs, on arbitrary lists of things. I’ve been writing tools to semi-automate some complicated refactorings, and it’d be nice to see what the tool changed before I tell it to save and check in. There’s also an app my company sells that might benefit from some proper diff support (although it remains to be seen whether the customers actually want that).

I’ve been curious about the diff algorithm for years, and on several occasions I’ve searched for Delphi code that will calculate diffs. No luck yet. So a year or two ago, I went hunting for a diff algorithm that I could translate into Delphi.

I looked at GNU diff, but I wasn’t too excited about reading C source code. But I had a hunch that somebody had probably written this for Perl, and I wasn’t disappointed; a search of CPAN quickly turned up Algorithm::Diff.

It’s an interesting algorithm. A naïve approach to calculating diffs would take exponential time; but Algorithm::Diff is guaranteed to return the best possible set of diffs, and it runs in something like quadratic time, or possibly a little better. Its implementation is really pretty simple, once you get past the optimizations (including an if statement marked “optimization: most of the time this will be true” that never gets hit once by the test suite).

Once I did get past the optimizations, it wasn’t all that hard to understand how it works. Trying to figure out why it works took a little longer. In the end, the algorithm is pretty amazing — there are four or five seemingly-unrelated design decisions that all fit together, and the thing wouldn’t work unless every one of those things was just so. Hard to imagine how somebody figured this all out to begin with, but the end result certainly is slick.

Now I just need to sit down and code the algorithm. Sigh. (Although I’m thinking I can take a shortcut that the Perl code didn’t take, and make the code both a little simpler in a couple of spots, and a little more memory-efficient.)

Yes, I know there already two articles on CodeProject about how to write a diff algorithm in C#. But it doesn’t look like either one uses the same algorithm as the Perl code did, and I suspect Algorithm::Diff might end up being a better algorithm. (And, of course, the CodeProject articles don’t have Delphi code… although I’ll probably write a C# implementation too, mainly because Delphi is godawful expensive these days, so I don’t have my own copy of it at home.)

So here’s the question for you guys. I know I’m supposed to be writing a killer search tool, but what would y’all think about me writing a few articles picking apart the diff algorithm? Presumably I’d write some code along the way, and end up with a working diff algorithm in C# and/or Delphi (ideally both).

If I wrote about diff, would anybody read it? Let me know what you think.

Fixing the “break on F12” problem

A few years ago, I was writing a Delphi app that used the F12 key for something or other (I think it was to pop up a dialog showing the current record ID). And at some point, it stopped working on my computer. The users had no problems, but on my development machine, F12 broke into Delphi and popped up the CPU window (!), and after I resumed, my app had never seen the F12 keystroke. I couldn’t find anything in the Delphi docs to explain it, and I finally just gave up and made the app respond to both F12 (which the users were already used to) and F11 (so I could test).

Deepak Shenoy just posted about this very same issue, including the fix. Turns out it’s not a Delphi problem at all; it’s Windows 2000 (and later) that hijack F12, which is probably why I didn’t see the problem at first (I started developing that app on Windows 95, and later switched to Windows 2000 — that would probably be when F12 stopped working). Deepak’s post includes a link to an MS support page that explains how to tell Windows to hijack a different key instead (I like his suggestion of using Pause).

I just tested this with a .NET app in Visual Studio, and F12 only forces a break if you have the native debugger attached (by attaching to an already-running program with Debug > Processes and checking the “Native” checkbox). Normally you would only have the CLR debugger attached (this is what Debug > Start does), so F12 isn’t hijacked and your program works as expected.

Sleep? What’s that?

Looks like it’s been over a month since I last blogged about my forays into ADD treatment. What can I say? I’ve been distracted.

So the doctor started me off on Ritalin, starting small and gradually working up, trying to find the right dose.

Two weeks later, I was still having trouble focusing, and I was getting stomachaches too. Since I know I’m somewhat prone to anxiety, if not a full-fledged anxiety disorder, I figured the Ritalin was making the anxiety worse. He was a little surprised that I wasn’t seeing any noticeable improvement, but he switched me over to Adderall, this time with a much quicker ramp-up, since I seemed to have a fairly high tolerance for this stuff.

End of week; end of trial supply of Adderall, and I was still having trouble focusing. Sam can attest that my ADD can be extremely apparent when I’m driving, and I used that as a gauge: take my morning dose about 45 minutes before I head to work, and if I’m still getting distracted while I’m on the road, then the Adderall isn’t doing what it’s supposed to do.

Meanwhile, I was under a deadline at work — big project, due at the end of November. And I was enjoying the project; it was a big refactoring job, and I was writing tools to semi-automate some of the more labor-intensive parts (tools built on top of other tools, built on top of other tools). I was putting in a lot of time, getting a lot done, and having a lot of fun at it.

This may seem like a bit of a contradiction; doesn’t that sound like the meds were working fine? Well, not totally clear. As the doctor explained the first time I met with him, people with ADD can focus; it’s just a lot of extra work (the body has to pump out higher quantities of certain neurotransmitters for the duration), and they tend to get absorbed in the task and irritated when they have to switch to something else (which describes my whole life). So I can focus, but only when it’s something I’m really, really interested in. (Which makes a great deal of sense to me, and goes a long way toward explaining all the projects I start and never finish.) As he explained it, the goal of ADD treatment is to switch from an “interest-based brain” to an “importance-based brain”.

I had been working on a project that interested me, so I assumed that was why I was able to put in that sustained effort. One could argue that it interested me because the drugs were working, but I didn’t think so — during the day, I still had plenty of periods where I got distracted by other things, or couldn’t keep the details straight in my head for long enough to get something done. Or where I spent three hours polishing the UI for an internal tool that we were probably never going to use again, chewing myself out for it all the while, and then working until midnight or later to make up for the time I felt like I had wasted. So once again, I wasn’t convinced that the meds were having any clear impact.

However, I had been working pretty late a lot of nights (late = leave work at 1:30 am, and set off the alarm system). And the symptoms of sleep deprivation can look an awful lot like the symptoms of ADD.

I had also, by this time, realized that there was another reason for my stomachaches… like the fact that I was so absorbed in work that I was forgetting to eat. One meal a day doesn’t really cut it, especially over a period of a week or two. (I’m a little slow sometimes.)

So, the next time I saw the doctor and explained all this, he was debating whether to switch me to yet another med. He asked me which way I’d like to go, and since the next drug would take about six weeks to really tell if it was working, I figured it’d make more sense to give the Adderall one more shot. (With instructions to try to get more sleep.)

So he wrote me a prescription for a 90-count of 10-mg pills (so I could adjust the dose in 10-mg increments, as I had been doing).

Insurance threw a fit. I guess they thought it was a 3-month supply, and they didn’t want to fill it. The doctor fought with them for the better part of a week, and never got anywhere. Finally he gave up, and wrote a new prescription for a 30-count of 30-mg pills, which the insurance did approve. Go figure.

Jennie picked up the prescription from Walgreens, and brought it to me at work. I figured, I was on 70 mg when I ran out on the last ramp-up, and couldn’t tell that it was doing much, so I’d start with 60 this time and work from there. Took it about 2:00 in the afternoon (I usually take it first thing in the morning).

I got a lot done that afternoon. Stayed late, plowing through stuff. And when I finally came home, I didn’t get to sleep until about 2:00 am.

Hmm, I thought. Maybe this stuff is more effective than I’d given it credit for. It was particularly dramatic for the fact that I hadn’t been taking it (not having any left) for the better part of a week.

The doctor said I could go as high as 150 mg a day, but I never wound up going above 90. The first day I took 90, I felt a little unsteady whenever I was standing up, and the whole day I felt a little disconnected. It was like when you’ve got a fever, you sometimes feel a little detached from everything around you. And that night, I was awake, literally, the entire night — the second real all-nighter of my life. (But when I braved 90 mg again a few days later, I was just fine.)

But I still had trouble focusing.

There seem to be two different sorts of focusing involved here. One is getting absorbed in a project, and not wanting to switch to something else (like eating, or sleeping), and that I was doing just fine. (The doctor said it’s called “hyperfocus”.) But then there’s what I called “detail focus”, where you can keep more than one or two details straight in your head for long enough to get something done. That, I wasn’t doing. More than once, I would be talking to someone, and a sentence or two would just slide right in one ear and out the other, and I’d have to blink and ask them to repeat themselves.

I’m not sure if this is a dosage thing, or if it’s just the wrong drug for my brain chemistry. I’ve certainly never had a problem with achieving hyperfocus, and it’s easy enough to believe that I’m actually, despite the side effects, on too low a dose of Adderall at this point — that it’s exaggerating the hyperfocus to the point of being a distraction in itself, without actually being enough to make me able to focus on the important details instead of just the interesting details.

But I am having enough trouble with side effects — specifically, insomnia and appetite suppression — to be leery of upping the dose. He did say, when I met with him again today, that I’ll get my appetite back over time, but it’s been really weird; I’ll be eating a meal, and after a while, my stomach will just say, “Okay, that’s it, I’m done,” and I’ll have to struggle just to finish swallowing. This is especially annoying when it’s obvious that my stomach is still hungry at the time.

Anyway. The verdict from today’s appointment: I’m sticking with the 60 mg of Adderall for now, and he’s also starting me on, interestingly enough, lithium. You usually hear about lithium being used for bipolar disorder, but he said he’s actually seen research that suggests that lithium can help with adult ADD, especially in people with a history of head injury (I got a concussion when I was in third grade, but that’s a story for another day). He also said that lithium actually helps with the lower levels of sleep (I think he said levels 3 and 4, though I don’t remember for sure), so in addition to helping the ADD symptoms, he’s hoping it will help me get to sleep and get a good night’s sleep.

Lithium does have nasty side effects (kidney damage) if too much builds up in the bloodstream, but it’s not supposed to be a problem at this dose. Still, I’m supposed to drink plenty of water (I usually seem to be teetering on the edge of dehydration) to keep that from happening, and he’ll be getting me tested regularly to make sure the levels don’t get too high.

I’m also supposed to go home at a reasonable hour so I can get some sleep. And on that note, the time now being nearly midnight and me having left work six hours ago, I think I’ll quit blogging and go to bed.

Well, a wiki did seem like a good idea…

I’ve taken down the BorCon 2004 wiki. If you want a good overview of everything that happened at the con, read Erwien’s summary on BDN.

A conference wiki, where everyone could post their conference notes in one place and compare notes and organize everything to be all nice and pretty, certainly did seem like a great idea. But it would have been a community site — and community sites don’t really work without a community, which just takes time.

(And it might have helped if the idea had occurred to me before the conference started, instead of halfway through.)

And then there’s the wiki spam. I subscribed to the wiki’s RSS feed and figured that would take care of it; I’d get notified any time someone tried to edit the wiki and stuff in a bunch of link spam. But I forgot that out of the box, UseMod‘s RSS feed doesn’t actually notify you of each and every change — it just notifies you that the page changed on this date. If somebody edits the page, and I fix it, and somebody edits it again later in the same day, I never know about that second change, so spam kept creeping in and not getting swept back out. I was just so used to the wiki we use at work (which started life as UseMod, but that we’ve hacked a fair number of tweaks into) that it never even occurred to me that I wouldn’t see every single change in the RSS feed.

(I also forgot to edit the BorCon wiki.pl to remove the “This change is a minor edit” checkbox. Even the hacked UseMod wiki we have at work only reports major edits. I meant to take out that checkbox, but I guess I never did. Oops.)

We really should publish our UseMod patches sometime. There are quite a few interesting ones, like the RSS feed tweaks, the shorthand syntax for <nowiki>, the “Edit” link at the top of the page, the “Save” button at the top of the preview, the tag for two-column layout (a bit cumbersome, but often very useful), and the many tweaks to the auto-link regex to make it nicer for people who are using the wiki to talk about Delphi code (e.g., “TDataModule” is not automatically linked, because the two leading capitals are a clue that it’s probably a Delphi class name, not a WikiName).

Of course, it was only recently that Sam set up CVS and put our wiki source code into it, so reconstituting the patches for any of these changes would be a lot of work. Ah well — someday, in my copious spare time.

Particle physics

Our youngest cat has a multitude of names. He came with the name Sox, but we also commonly call him Monkey (because he climbs things), Kangaroo (because he jumps like one — stiff back legs and everything), Prairie Dog (I’ve never seen a cat sit straight up on its haunches and stay there for that long like he does), as well as the affectionate titles of Goober and Wumpus.

(Why Wumpus? Well, obviously, because he’s a scary monster, and it’s dangerous to be in the same room with him. Or something. Don’t ask me, it was just one of those spontaneous name things.)

He earned yet another nickname this morning. He’s not the swiftest on the uptake, and he hasn’t quite figured out that, when he jumps into the tub while one of us is taking a shower, he tends to get wet. He didn’t actually jump in this morning, though; he just stood on the edge of the tub, poked his head around the shower curtain, and then jerked back as if mortally wounded when he got hit by the spray. Then he did it again a minute or two later.

As I was drying off after my shower, Jennie happened into the bathroom, and I said to her, in a very serious tone, “I have a question.”

“Oh God,” she said. “What?”

When he’s underwater,” I said, in the same serious voice, “does he get wet? Or does the water get him instead?

She chuckled, and said, “Y’know, I think the water might get him.”

I shrugged. “Nobody knows. Particle Cat.”

She laughed out loud.

A few minutes later, I was going down the stairs, and our newly-christened Particle Cat was flopping around on his back. I must have startled him on my way by, and he took off, using my foot as a launching pad. With his claws extended, of course.

“They have a fight,” I amended. “Particle wins.” After a moment’s thought, I added, “‘Cause Particle has Triangles.”

(If you’re clueless, go read the lyrics link I posted. If you’re still clueless after that, I wouldn’t worry about it too much.)