OS 8.1 / OS 9 views

I’m making a script which I’d like to run on a computer running OS9, AND a computer running OS8.1.
Unfortunately, I need to set the view of the desktop for OS9 to “not arranged”.
I placed the following (which I discovered in these boards) near the beginning of my script, but my computer running OS8.1 won’t compile it.
tell application “Finder”
set theWindow to the desktop
set theItem to startup disk of theWindow
set bvaSetting to button view arrangement of theWindow
set svaSetting to spatial view arrangement of theWindow
set button view arrangement of theWindow to not arranged
set spatial view arrangement of theWindow to not arranged
end tell
I tried placing it between “try”…“end try”, but that didn’t work either.
Any ideas?
Thanks.

: I’m making a script which I’d like to run on a computer
: running OS9, AND a computer running OS8.1.
: Unfortunately, I need to set the view of the desktop for
: OS9 to “not arranged”.
: I placed the following (which I discovered in these
: boards) near the beginning of my script, but my
: computer running OS8.1 won’t compile it.
: tell application “Finder”
: set theWindow to the desktop
: set theItem to startup disk of theWindow
: set bvaSetting to button view arrangement of theWindow
: set svaSetting to spatial view arrangement of theWindow
: set button view arrangement of theWindow to not arranged
: set spatial view arrangement of theWindow to not arranged
: end tell
: I tried placing it between “try”…“end
: try”, but that didn’t work either.
: Any ideas?
: Thanks.
It would probably be better to write different versions for the two systems. However, if you’re set on having the same script for both, you could try compiling it on the OS9 machine - with the view arrangement code in a ‘try…on error…end try’ block - and copy it across to the OS8.1 machine.
If this isn’t possible - or if you really want to show off - you could store the view arrangement code as a ‘script object’ in its own file. On the OS9 machine, you’d compile and run this:
– Start
script viewArrangements
to turnOff(theWindow)
tell application “Finder”
set bvaSetting to button view arrangement of theWindow
set svaSetting to spatial view arrangement of theWindow
set button view arrangement of theWindow to not arranged
set spatial view arrangement of theWindow to not arranged
end tell
return {bva:bvaSetting, sva:svaSetting} – return the old settings as a record
end turnOff
to turnOn(theWindow, theSettings)
tell application “Finder”
set button view arrangement of theWindow to bva of theSettings
set spatial view arrangement of theWindow to sva of theSettings
end tell
end turnOn
end script
set storageFile to “Macintosh HD:Desktop Folder:Finder view arrangements” – or whatever
store script viewArrangements in file storageFile with replacing
– End
This saves the ‘script’ block as a script object in a file on the desktop. The object contains routines for turning the view arrangements both on and off. On both machines, you’d compile this:
– Start
tell application “Finder”
set theWindow to the desktop – or whatever
try
set viewArrangements to (load script file “Macintosh HD:Desktop Folder:Finder view arrangements”)
tell viewArrangements to set origSettings to turnOff(theWindow)
on error
end try
set position of disk “Macintosh HD” of theWindow to {100, 100}
try
tell viewArrangements to turnOn(theWindow, origSettings)
on error
end try
end tell
– End
The OS9 machine will carry out the script object stuff; the OS8.1 one will simply throw an error and skip it. There are obviously different ways you could arrange the code, but this is just to give an idea.
NG