set myScripts to {"MyDisK:User:Etnadan:Desktop:Current Scripts:Write Out TO TEXT.scpt", "MyDisK:User:Etnadan:Desktop:Current Scripts:Writein TO TEXT.scpt", "MyDisK:User:Etnadan:Desktop:Current Scripts:Read from Text.scpt"}
set scriptChoice to choose from list myScripts
if scriptChoice is false then return --user canceled
set vai to ((scriptChoice as string)) as alias
set copyScript to load script vai
run
Each script works fine
However i hope to be able to close the script the moment the new script opens.
How can I close this script and keep the "called script from the list?
Hi. Your entire script loops indefinitely because “run” is at the end, but it should be directed to the loaded object.
This is a little tighter and easier to read:
try--ignores errors
run (load script (choose from list {"MyDisK:User:Etnadan:Desktop:Current Scripts:Write Out TO TEXT.scpt", "MyDisK:User:Etnadan:Desktop:Current Scripts:Writein TO TEXT.scpt", "MyDisK:User:Etnadan:Desktop:Current Scripts:Read from Text.scpt"}))
end try
Save the ‘chooser’ as a bundle app – then it will close when it completes its work. If you’re running it in a script editor, you’ll have to tell the script editor to close it.