iPod Notes: Above and Beyond
Pages: 1, 2
Hacking Your History
Whenever you navigate through your iPod menus--regular menus as well as notes--the iPod maintains a history stack to keep track of your progress. Pressing the Menu button moves you back one step at a time through this stack. Because there are times that you might want to either skip one stage or reset the stack completely, Apple offers a couple of modifier tags for your anchor elements. Here you'll see what these tags are and why you might want to use them.
POPALL
Say that your user just completed a tour or a lesson. You want him or her to be able to jump right back to your main menu without either having to press Menu a few hundred times or leaving a history track through the already-completed segment. The POPALL tag empties the entire history stack, allowing you to return to the main menu without a history.
To use the tag, just add it to your anchor that links to the main page. The POPALL tag only links to the top of the notes hierarchy--to either the Notes folder itself or the main.linx (or index.linx) file. You cannot use it to link to an arbitrary file, whether or not it's in the home Notes folder.
<A HREF="/" POPALL>Finish this tour</A>
<A HREF="/main.linx" POPALL>Leave this lesson</A>
NOPUSH
Sometimes a menu or screen helps users choose how they want to explore parts of your tours or lessons, but they're not really helpful when you visit them a second time. For example, you might ask your user whether they want to listen to a presentation or read it, or you might choose whether to play the audio track with the background music or not. Similarly, introductory screens might not be as helpful the second, third, or fourth time you have to page through them when returning up the history stack. When you have a note that really only works in a forward direction, use the NOPUSH tag to link to it without letting it enter the history stack. Your user will see it only once, when navigating through it from higher to lower in the notes tree.
<A HREF="introscreen.txt" NOPUSH>Start Your Tour</A>
<A HREF="/chooseTextOrAudio.txt" NOPUSH>Read or Listen</A>
Using Language Encoding
Note files use Latin1 encoding by default unless the iPod language is set to Japanese, Korean or Chinese. (In which case, those languages are used to set the encoding.) You can tag note files to override the standard encoding as follows:
<?xml encoding="Korean" ?>
Valid encoding schemes include Latin1, MacRoman, MacJapanese, Traditional Chinese, Simplified Chinese, Korean, UTF8 Unicode, and UTF16 Unicode. Always place the encoding tag at the very top of a note, and only include one encoding per file. Please refer to Apple's documentation for further details about encoding schemes, character entities, URI encoding, and so on.
Debugging Your Notes
Set your iPod to report errors by adding <ERROR> to your notes. You'll see a list of any errors found while parsing that notes file, including badly formatted tags, dead links, and so forth. Figure 5 shows an error report for a note with a bad link.

Figure 5. The <ERRORS> tag generates an error report.
Make sure to remove all <ERROR> mentions after you finish debugging your note. Notes without any errors that are tagged with the error code will display as a simple blank screen. This can be both confusing and annoying when you've just forgotten to remove the tag.
Conclusions
It wouldn't be far off the mark to accuse Apple of over-engineering some of their products. When they deliver such delightful gems as iPod Notes, you really have to forgive them. It's a joy to discover these little-known but extremely useful extras and get the opportunity to explore and see how they can be used to get more value from your equipment.
This article and the previous one in this series have covered a fair majority of the features currently available in iPod Notes. You've read how to create notes and customize them, link them together, and produce menus that let users decide how they want to proceed. You've seen how to set up your iPod for "notes-only" museum mode and learned how to incorporate HTML text in your presentations, without having to remove tags by hand. You've also discovered how to control your history stack and debug your notes, and more.
I hope this article has inspired you to dig into iPod Notes and to try them out for yourself. To discover more about iPod Notes and how to develop your own notes presentations, please visit the following Apple links.
- Apple iPod developer information page
- Apple iPod Note Reader User Guide (PDF)
- Apple iPod Notes Feature Guide (PDF)
Erica Sadun has written, co-written, and contributed to almost two dozen books about technology, particularly in the areas of programming, digital video, and digital photography.
Return to the Mac DevCenter.
Showing messages 1 through 4 of 4.
-
Here's a quick tool for your readers -
2006-12-13 09:56:39 ObviousTroll [Reply | View]
I used to have an eBook library website, back in the day, and your first article inspired me to play with the Note feature. This program is the result; it's too short for a sourceforge project, so I hope you don't mind if paste it here for your readers. It will take any text file and chunk it up into iPod notes, with previous page and next page links.
-----------------
#include <stdio.h>
#include <sys/param.h>
#include <string.h>
#include <unistd.h>
// Each file should be slightly less than the maximum possible.
#define FILE_SIZE 4096
#define SLACK_SIZE 256
#define BUFLEN 32
char title[BUFLEN] = "Converted Text";
char prefix[BUFLEN] = "N";
int main(int argc, char **argv)
{
char c;
int hungry_mode = 1;
int gobble = 0;
int count = 0;
int page = 0;
char filename[MAXPATHLEN];
FILE *in = stdin;
FILE *f = NULL;
while ((c=getopt(argc,argv,"i:t:p:")) > -1) {
switch (c) {
case 't':
strncpy(title,optarg,BUFLEN);
break;
case 'p':
strncpy(prefix,optarg,BUFLEN);
break;
case 'i':
in = fopen(optarg,"r");
if (!in) {
perror("Failed to open file for writing.\n");
return -1;
}
break;
case '?':
default:
fprintf(stderr,"Usage: ipodconvert [-i source] [-t title] [-p prefix] \n");
return -1;
break;
}
}
c='#'; // bogus non-whitespace initial value.
do {
if (f) {
fclose(f);
}
sprintf(filename,"%s%03d",prefix,page);
f = fopen(filename,"w");
if (!f) {
perror("Failed to open file for writing.\n");
return -1;
}
fprintf(f,"<TITLE>%s %03d</TITLE>\n",title, page);
if (page > 0) {
fprintf(f,"Back To Page %03d (\"%s%03d\") \n",
prefix,page-1,page-1);
}
/*
* When we hit the size limit, we want to continue till
* the end of the current word.
*/
count = 0;
while (((count < (FILE_SIZE-SLACK_SIZE)) ||
(!isspace(c) && (count < FILE_SIZE))) &&
((c=fgetc(in))!=EOF)) {
if (c=='\r') {
//throw it on the floor.
} else if (c=='\n') {
// If this is our first EOL, output a space.
if (!gobble) {
gobble = 1;
fputc(' ',f);
count++;
} else {
// consume the EOL.
gobble++;
}
} else {
if (gobble>1) {
// Emit a double EOL to create a blank line.
fputc('\n',f);
fputc('\n',f);
count+=2;
}
fputc(c,f);
gobble = 0;
count++;
}
}
if (c != EOF) {
fprintf(f,"Go to Page %03d (\"%s%03d\") \n",
prefix,page+1,page+1);
}
page++;
} while (c != EOF);
return 0;
}
-
Here's a quick tool for your readers -
2006-12-13 10:00:35 ObviousTroll [Reply | View]
Sigh. It looks like the code tags didn't respect the indenting.
In any case, paste the source into a file called "ipodconvert.c" then, in Terminal, type
gcc -o ipodconvert ipodconvert.c
To use it, type ipodconvert -i text file name -t title of document -p file name for notes






http://www.oreillynet.com/pub/a/mac/2006/11/28/building-interactive-ipod-experiences.html?page=last#thread)
I have added POPALL to my links back to the Notes index (as in "Finish this tour (/) ").
However, having completed one quiz exercise and returned to the menu using the above method, when I repeat the same exercise, all the correct links are still highlighted! I am not convinced that POPALL actually clears the cache; it only provides a quick link back to the menu.
See my own notes and exercises at:
http://ashcombeweb.blogspot.com/
http://www.ashcombe.surrey.sch.uk/ipod/ipod.html