There is a bug somewhere in the AppleScript ecosystem that prevents scripts like this from compiling in Script Editor:
tell application "Finder"
Packet-written UDF format
MS-DOS format
end tell
Presumably because the hyphen is interpreted as a minus symbol. After reading page 310 of AppleScript: The Definitive Guide backwards and forwards several times (from different angles and in different areas of the house), I finally worked out that I need to specify a raw constant containing the enumerator code along with the code of the enumeration that said enumerator belongs to.
To track these things down I opened Finder’s dictionary in Script Editor, hit shift-command-s to save it as an .sdef file, and then opened that with TextEdit. There I discovered the enumerators in question nested inside the enumaration edfm. The enumerators themselves were easily identifiable by name, and each contained a unique four-letter code. Using this information I was able to write the following script:
tell application "Finder"
«constant edfmdfpu»
«constant edfmdfms»
end tell
Which compiles and produces code that matches the former scriptlet. If, however, we try to compile this code again, we will get a syntax error. The solution is to write the affected code as a string, and then execute it with the run script command.
run script "
tell application \"Finder\"
«constant edfmdfpu»
«constant edfmdfms»
end tell
"
I’m really not sure how often this issue comes up in scripting, but perhaps in time my experience will aid 1 or… maybe even 2 (!) other visitors to this forum. Any additional insights regarding this behavior are welcome.
Edit: I’ve stumbled on yet another interesting wrinkle. That is, if you fudge the enumeration reference, the raw code will not be replaced at compile time, but it will still work! This, for example, successfully locates the DVD in my optical drive:
tell application "Finder"
disks whose format is «constant xxxxdfud»
end tell