A tip for writing script for HD DVD

A very quick tip today, although this one trips me up a lot.

When you write script files for your HDi applications, always include a blank line at the start of the file and at the end of the file.

This is because the player will concatenate all the individual files together and execute them as a single large virtual file. So, for example, if you have two files like this:

first.js

var x = 42;
// end of first.js

second.js

var y = 42;

Then the player will see this:

<virtual_file>

var x = 42;
// end of first.jsvar y = 42;

And then later on when you try to reference the y variable, it doesn't exist because it was considered part of the comment. Doh!

At least, that's what the players do, but HDiSim doesn't. Which is why you can get away without the padding when running on the simulator, and then you get weird errors when running on the emulator / player.