Given the following script, executed from inside SD4 using the Script → Execute → open feature just choosing one single file (an OSAX):
global _scr_add_usr
global _scr_add_all
global _answ
global _scr_add_fol
global _files
global _file
on open of _files
set _scr_add_usr to path to "dlib" from user domain
set _scr_add_all to path to "dlib" from local domain
set _answ to button returned of (display dialog "Soll(en) die Scripting Addition(s) für den aktuellen oder für alle Anwender installiert werden?" buttons {"Alle", "Aktuellen"} default button 2 with icon note with title "OSAX Installer" giving up after 20)
if _answ is "Alle" then
set _scr_add_fol to _scr_add_all
else
set _scr_add_fol to _scr_add_usr
end if
set _scr_add_fol to ((_scr_add_fol as string) & "ScriptingAdditions") as alias
repeat with _file in _files
tell application "Finder" to copy _file to _scr_add_fol
end repeat
end open
It does not work for me. On debuggin I found out, that _scr_add_fol has the wrong value. It contains item 1 of {alias “Mac:Users:tjm:Desktop:XMLLib.osax:”} (path to the chosen file as list) instead of alias “Mac:Library:”.
_scr_add_all and _scr_add_usr both have correct values!
This seems really weird! Did anyone experience something like this as well and knows a workaround?
TIA,
Thomas
Model: Mac-Mini
Browser: Firefox 1.5.0.7
Operating System: Mac OS X (10.4)
global _scr_add_usr
global _scr_add_all
global _answ
global _scr_add_fol
global _files
global _file
on open of _files
-- this folder exists by default
set _scr_add_all to (path to "dlib" from local domain) as Unicode text
-- this folder it's not sure it exists. #1
set _scr_add_usr to (path to "dlib" from user domain) as Unicode text
set _answ to button returned of (display dialog "Soll(en) die Scripting Addition(s) für den aktuellen oder für alle Anwender installiert werden?" buttons {"Alle", "Aktuellen"} default button 2 with icon note with title "OSAX Installer" giving up after 20)
if _answ is "Alle" then
set _scr_add_fol to _scr_add_all & "ScriptingAdditions:"
else
-- #1 create the folder if not exists
tell application "Finder" to if not (exists _scr_add_usr & "ScriptingAdditions:") then
make new folder at _scr_add_usr with properties {name:"ScriptingAdditions"}
end if
set _scr_add_fol to _scr_add_usr & "ScriptingAdditions:"
end if
repeat with _file in _files
tell application "Finder" to try
-- you can't copy Finder items. Use duplicate instead
duplicate _file to _scr_add_fol --with replacing
on error e number n
display dialog e & return & n
end try
end repeat
end open