Hi, hope this is possible.
I am creating a script that will use several peaces of coding over and over for at least 50 times! How can I change a script like this:
tell application "Finder"
display dialog "Hello"
open folder "my folder" of folder "Desktop" of disk "Maindisk"
end tell
to a script like this:
set MyDialgog to "display dialog \"Hello\""
set open_comand to "open folder \"my folder\" of folder \"Desktop\" of disk \"Maindisk\""
tell application "Finder"
MyDialgog
open_comand
end tell
Any idea will help! thank you for your time!
brian
Hi,
second level evaluation (compiling scripts at runtime) is not recommended because it’s slow.
The best way to run recurring code is a handler, for example if you want to open a folder on desktop with a variable hierarchy level use something like this
openSubfolderOfDesktop({"folder1", "folder2"})
on openSubfolderOfDesktop(pathComponentList)
set {TID, text item delimiters} to {text item delimiters, ":"}
set thePath to pathComponentList as text
set text item delimiters to TID
tell application "Finder" to open folder thePath of desktop
end openSubfolderOfDesktop
Thank you for replying! Its not exactly the idea I had but its good to know you can do this! thank you very much 