I’ve been trying to learn to code in various languages for many years.

First, I’m not sure when, I tried QBASIC. It seemed simple enough. I later read some recommendation for Pascal and tried to give that a shot, but to no avail. I played around with some PHP too, but ultimately I couldn’t get the hang of the abstract thinking required.

Years passed and I gave up on the idea. Then recently a thread on AskReddit recommended Harvard’s online computer science primer course, CS50. I’ve only done week 0’s lecture and problems so it may seem silly to talk of progress and normally I’d try not to. There’s a reason I’m making an exception though – as an assessment for the module I’ve finally written my first complete program.

It’s a Warhammer 40,000 imperial date converter. Sure, it’s not much, but it’s complete and it works, and I made it myself, graphics and sounds aside.

(As a side note the graphics and sounds are actually just because they were a requirement of the course exercise. If I actually wanted graphics I’d have drawn them myself)

bsa-report

For an example of what it’s for see the image above. The date is in the following format:

Checksum|Year fraction|Year|Millennium

Hardly human readable, but then again even in the fiction it’s not supposed to be a commonly used format. Instead it’s for official stuff. Pain in the arse if you happen to be a person trying to sort through documents to create a timeline.

So for that date, 8431345m35, it works out as 07:36 on 6th June 34,345. Admittedly the checksum suggests that time on Earth could be completely bloody different, but at least I think my maths is right.

converter-sourceAs Scratch doesn’t have a nice way of handling dates the code ends up being a little amusing to look at.

That’s only some of it but it’s what does the processing of the date. The huge bit is multiple For/Else bits to figure out which month it is. Getting the day of the year number is easy, for example, but as the months have assorted lengths a loop wouldn’t work.

I’m impressed that I finally coded something, even if it’s not code in the traditional sense.

Perhaps for my next project I’ll try to recreate it in actual code. Better yet, after that maybe I’ll create something for converting dates into Imperial. How hard can it be?

Well, not that hard, but perhaps I’ll some how be good enough to pull it off.

0 responses to "I didn’t feel like attempting a game just yet."

Leave a Reply