mt2d2

Somewhere I stop, waiting for you.

MessageFormat

Posted by mt2 July 02, 2009

During a stint programming with Qt, I became quite fond of using QString’s arg(), which allows you embed arguments into a template string. QString copies the template, replacing markers with the arugments. It seems obvious, but it is dead useful, especially when it comes to translating software. For example, straight from the documentation:

     QString i;           // current file's number
     QString total;       // number of files to process
     QString fileName;    // current file's name

     QString status = QString("Processing file %1 of %2: %3")
                     .arg(i).arg(total).arg(fileName);

See, dead useful, right? I’ve recently been programming with my first love (Java, obviously) and have run against a problem that made Qt/C++ once seem so much more attractive. Althogh String itself is pretty barebones, it turns out there’s help; allow me to introduce MessageFormat. I’m not sure how I never came to know this class, but it’s satisfied me for want. It has a slightly more verbose format, but also has some swell extras. For example, how about agreeing with the number of a noun?

     MessageFormat.format("You did not guess {0} {0,choice,0#words
                          |1#word|1<words}.\n", allWords.size());

Color me smitten. Harmony between Java and me is, for the moment, restored.

Sic Transit Gloria Mundi

Posted by mt2 June 23, 2009

I’ve been meaning to write for literally months now. With each passing day, the pressure to achieve a dramatic and powerful comeback increases, eventually leading to a point during each day (and sometimes night) that I just don’t want to let myself down. I decided to do soemthing about that.

I’m in here.

Window in the Sky

Posted by mt2 April 13, 2009

This is what the sky might look like if we could see what Hubble can.

If we could see

Do you ever wonder what we’re missing?

Forever’s Not So Long

Posted by mt2 March 11, 2009

optical communication
Forever’s Not So Long from garrettmurray on Vimeo.

“George discovers that the end of the world is the perfect time to lose everything.” A worthwhile 12 minutes, which  makes me want to produce short films, too.

Written & Directed by Shawn Morrison
Produced by Garrett Murray

« Older blog posts