Re: FADE DEAD
Re: FADE DEAD
- Subject: Re: FADE DEAD
- From: Jon Pugh <email@hidden>
- Date: Wed, 13 Mar 2002 22:43:01 -0800
At 2:36 AM +0100 3/14/02, JJ wrote:
>
Does anybody know why does every script ends with a hexadecimal
>
>
FADE DEAD
>
>
?
>
>
Simply a joke or does it makes any secret operation?
This was just a terminating sequence that won't appear in any script. Its joke value is obvious.
I suppose embedding this sequence in a script would be bad. Yes, it is. Check this script out:
prop p : fromHex( "FADEDEAD")
-- it won't compile, but it does run, that's why it won't compile
on fromHex(hStr)
set hStr to hStr as string
copy "0123456789ABCDEF" to hConst
copy 0 to theres
copy (length of hStr) to cCnt
repeat with i from cCnt to 1 by -1
copy (offset of (character i of hStr) in hConst) to hVal
copy (hVal - 1) * (16 ^ (cCnt - i)) to newVal
copy theres + newVal to theres
end repeat
return theres
end fromHex
-- FADEDEAD in hex (not ASCII) is the end of script marker
-- Having one inside a script is invalid
-- FasdUAS is the beginning marker, it is also invalid
-- However, compiling this into a valid script works
It won't compile, but what causes it not to compile is when it runs the initialization of the property. That's kind of twisted. I should have thought of running this script back during AppleScript testing. It would be have been a fun bug report. However, I would like to point out that AppleScript does highlight the offending invalid script segment.
Removing the property allows it to compile, since it's the embedding that causes the error, but AppleScript won't display the number in decimal to sufficient accuracy, which is probably one reason it was chosen as a marker.
>
And, what does it mean "FasdUAS "?
I believe this is the beginning tag, so now you can check a script in memory or on disk and see if it might actually *be* a script before trying to run it through the interpreter. There's a space on the end, as corrected above. UAS probably means Universal AppleScript Storage or somesuch. I don't know what Fasd stands for, but I'm sure it's something. I doubt Warren even remembers. ;)
"FasdUAS " (with or without the space) also works in place of "FADEDEAD" in the script above.
Another interesting point I see while playing around with this is that if you compile your script window, simply by hitting enter before you paste, you will be able to compile this script because this trick doesn't seem to invalidate a valid script id, it only prevents a valid script id from being created from scratch. Go figure.
OK, I think I've wasted enough of my time on this for the moment.
Jon
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: | |
| >FADE DEAD (From: JJ <email@hidden>) |