Welcome to MSDN Blogs Sign in | Join | Help

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.

Published Friday, February 16, 2007 11:46 AM by ptorr
Filed under:

Comments

# re: A tip for writing script for HD DVD

omg you serious? It's good to know that before go crazy about bad behaviour!

Friday, February 16, 2007 3:35 PM by Xavi

# Encoding Requirement for the script

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?

Thursday, March 08, 2007 4:13 PM by jinsongyang

# re: A tip for writing script for HD DVD

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.

Thursday, March 08, 2007 10:36 PM by ptorr

# re: A tip for writing script for HD DVD

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.

Friday, March 09, 2007 2:06 PM by jinsongyang

# re: A tip for writing script for HD DVD

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.

Friday, March 09, 2007 2:52 PM by jinsongyang

# Dissecting "Chapters"

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

Monday, May 07, 2007 1:21 PM by Application Development for HD DVD
New Comments to this post are disabled
 
Page view tracker