Giacecco
unread,Jul 28, 2010, 7:00:11 AM7/28/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to appenginejs
See the code below. Don't worry too much about what the code does. The
interesting bit is that I get the syntax error above on the line with
the delete() statement! It looks all good to me! Thank you in advance
for any hint...
var firstAvailableShortURL = undefined, numericShortURL;
if (IsGarbageCollectionNecessary()) {
throw new Error("I did not write this bit of code, yet!!!");
} else {
for(;!firstAvailableShortURL;) {
// I create an empty placeholder, so that I can read its id
firstAvailableShortURL = new ShortURL({});
firstAvailableShortURL.put();
// then I calculate the short URL, from the Datastore numeric id
for(numericShortURL = firstAvailableShortURL.key().id();
numericShortURL > MAX_ENCODABLE_NUMBER; numericShortURL %=
MAX_ENCODABLE_NUMBER) {};
firstAvailableShortURL.shortURLNumeric = numericShortURL;
firstAvailableShortURL.shortURL =
NumberToShortString(numericShortURL);
// I found a suitable numericShortURL, now I need to check
// that it has not been used before
if (Retrieve(firstAvailableShortURL.shortURL)) {
// it has been used before, I need to try again!
firstAvailableShortURL.delete();
firstAvailableShortURL = undefined;
}
}
}
return firstAvailableShortURL;