Freigeben über


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.

Comments

  • Anonymous
    February 16, 2007
    The comment has been removed

  • Anonymous
    March 08, 2007
    Peter - I got the following error when I tried to validate my script file: ERROR (E000000036): Resource must be encoded with Unicode UTF-16 (Big endian) with BOM (Spec 8.2.1) How do I save my script with BOM?

  • Anonymous
    March 08, 2007
    Most editors such as Notepad or Visual Studio or Eclipse will do this for you -- just try "Save As..." or "Save with Encoding..." instead of "Save", and choose an encoding.

  • Anonymous
    March 09, 2007
    Thanks Peter. I was using Textpad 4.7 and even I saved it as Unicode(Big endian), it didn't work. In this case I have to code a Java program that inserts the UxFEFF char at the beginning of the file.  But if I use Textpad or Visual Web Developer, it works OK as long as I save it as Unicode(Big endian). I have another question. Is it even possible to make an HTTP request from the player to some HTTP server, using ECMAScript?  If yes, how? Thanks a lot.

  • Anonymous
    March 09, 2007
    Correction of my previous comment: in "But if I use Textpad or Visual Web Developer, it works OK as long as I save it as Unicode(Big endian)", I meant Notepad rather than "Textpad". Sorry for the typo.

  • Anonymous
    May 07, 2007
    Hello World is a very basic application. But, now let's take a look at one of the samples that has a