Monthly Archives: July 2007

Help

Spur of the moment post.  I haven’t touched batch scripts in a very long while, but just recently picked up an old script I had, to tailor it for something I’m doing now.  What it did isn’t exactly important for the purposes of this discussion.

Every batch script should ideally have a help text.  For example, imagine foo.cmd, when you run it with the generic help option "/?":

Usage: foo.cmd [options]
This script foo will do wonderful things for you depending on the options:
    /bar – will do thing 1
    /baz – will do thing 2
    /?   – displays help

How does one do this in a batch script?  Simple:

if "%1"=="/?" (
    echo.
    echo Usage: %0 [options]
    echo This script will do wonderful things depending on the options:
    echo     /bar – will do thing 1
    echo     /baz – will do thing 2
    echo     /?   – displays help
    goto :EOF
)

Great!  Now let’s run it.  Here’s the output:

Usage: foo.cmd [options]
This script foo will do wonderful things for you depending on the options:
    /bar – will do thing 1
    /baz – will do thing 2
Displays messages, or turns command-echoing on or off.

  ECHO [ON | OFF]
  ECHO [message]

What the hell?  You have to escape question marks?  You might see the bug in the script right away, but I will admit it took me several minutes of scratching my head before figuring out what the hell was going on.  My thought process went something like this:

C:>echo /?
Displays messages, or turns command-echoing on or off.

    ECHO [ON | OFF]
    ECHO [message]

C:>echo ?
?

C:>echo /
/

C:>echo /^?
Displays messages, or turns command-echoing on or off.

    ECHO [ON | OFF]
    ECHO [message]

C:>echo ^/?
Displays messages, or turns command-echoing on or off.

    ECHO [ON | OFF]
    ECHO [message]

I am ashamed to admit it took many iterations of fooling around like this before I figured out what the hell is going on.  (What’s the problem?  ..figure it out yourself.)

So what is the solution?

C:>echo.    /?    – displays help
    /?    – displays help

Yet another batch script oddity.

Big Red Pushpins

There’s been so much hubbub going on lately about the iPhone, I’m sure it will make a very interesting case study.  Here’s another marketing blitz I thought was brilliant: What’s with those big red pushpins all over town?

I haven’t seen these in person, (they look more like giant spools of thread on a sewing machine than pushpins to me,) but I think this is a really cool marketing promotion.  MS isn’t even paying for the installations either.  We need more promotions like this, than stupid puzzle games where we send some random geek into space.  I love this quote from the article: "It has come to this in Microsoft’s online struggle against Google and Yahoo: oversized office supplies."

I’ve been playing with the Virtual Earth API lately, and found it surprisingly quite easy to work with (although limited in its functionality).  I haven’t played with Google Maps‘ API so I can’t compare the two.  I’ve always been a fan of Live Maps (better aerial photos in spots; collections) but started using Google Maps recently as well (the latter can plot GPS co-ords; the zoom based on mouse location is a nice add-on to the copycat zoom feature).

I would love to have one of those giant pushpins in my office.