Is there a way for Script Editor (or third party script editor) to open a .scpt file without trying to evaluate it? I have some scripts that send commands to a remote machine, but if that machine is not on the network, or not responsive for some reason, the script will hang while trying to open. I just want to see the text content of the script so I can make some additional scripts based on these. Seems like there should be a modifier key I could hold down while opening to tell script editor to just open the text file.
Are you running scripts from the Script Editor? If so, why?
You can get the text of a Compiled Script or script application by loading it and coercing to string. e.g.
set f to choose file
set s to load script f
set script_text to s as string
Thanks Kel, but no joy yet. When I run your script and choose a compiled script I get the following error:
Can’t make <> into type string.
And no, I’m not trying to run these scripts from Script Editor, I just want to refer to these scripts as I write new ones in Script Editor.
When I try to run these scripts normally (via hotkey) they also hang until applescript times out as the remote machine the scripts are trying to command is not there.
This is a bit of a “rock and hard place” situation. To run Kel’s script, you have to load the script and the Script Editor then tries to resolve references within it as it opens - the Script Editor always assumes you want to run it, not just look at it. Kel’s script will always work if the references in the script are resolvable - i.e., the shared volume is mounted when you do it.
Since it sounds as if you want to refer back to the constructions you used or to grab handlers that worked, I recommend that you set the script to text with the share point available, and then save the text or write it to a text file. This has the advantage that you now have a searchable copy of each of the scripts you care about that you can refer to even when the share point is not available.