Ben,
Thanksgiving is already there!
Furthermore there is no "E"aster, but "F" with param 3,0,0
And if you are interested, there is a way to avoid reading the dat-file twice:
Spoiler:
Code:
target.init = function () {
var i, tempfile,lines, tempnumevents;
//this.bubble("tracelog","initialising...");
this.appTitle.setValue(kbook.autoRunRoot._title);
this.appIcon.u = kbook.autoRunRoot._icon;
// Load events from save file
try {
if (FileSystem.getFileInfo(datPath)) {
// read whole file in first to count how many events there are
tempfile = getFileContent(datPath,'savefile missing');
if (tempfile!='savefile missing') {
lines = tempfile.split("\r\n"); // CR LF is used by stream.writeLine()
tempnumevents = (lines.length-1)/5;
//this.bubble("tracelog","Events="+tempnumevents);
for (i=0; i<tempnumevents; i++) {
events.push([lines[i*5],lines[i*5+1],lines[i*5+2],lines[i*5+3],lines[i*5+4]]);
}
/* this isn't necessary! As there are already lines[]
// now read file in using stream
var stream = new Stream.File(datPath);
for (i=0; i<tempnumevents; i++) {
temptype = stream.readLine();
tempmonth = stream.readLine();
tempdate = stream.readLine();
tempyear = stream.readLine();
tempdescription = stream.readLine();
events.push([temptype, tempmonth, tempdate, tempyear, tempdescription]);
}
stream.close();
this.bubble("tracelog","Events="+_Core.debug.dumpToString(events,"",2));
*/ }
} else {
// no savefile, so push default events
events.push(["Y", "1", "1", "2006", "New Year's Day"]);
events.push(["V", "2", "14", "2005", "Valentine's Day"]);
events.push(["F", "3", "0", "0", "Easter Sunday"]); // easter is a special float with param 3,0,0
events.push(["Y", "3", "17", "2005", "St. Patrick's Day"]);
events.push(["F", "11", "4", "5", "Thanksgiving"]);
events.push(["C", "12", "25", "2005", "Christmas"]);
}
} catch (e) { stream.close(); }
Regards
Mark
PS: Maybe editing (of the dat-file) would be easier if one event per row would be stored. Using something like a CSV-format, allowing events.push(lines[i].split(";"))