How to call a script from another script and close the previous?

I am still a new user … and I use this script


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?

Thanks you very much

There are three scripts here – the two on your desktop and the script you’ve posted. Which do you want to close?

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

I hope to close the script I posted

Thanks

Thanks you but after opening the list to choose the chooser script doesn’t close

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.