If you have written an AppleScript before, you might have felt the same way as I did,
that it was a poor experience to use the Script Editor app, it's barely better than
writing the script in any text editor or in a heredoc to run using osascript
.
Luckily you could try the JXA variant instead, AppleScript using Javascript. But writing such a file in the Script Editor app is not a better experience sadly.