Not being able to execute AS-code line by line and follow how variables etc change is, IMO, one of the biggest disadvantages with AppleScript.
OTOH, with reservations for me not being an AS-expert, I think it should be quite easy to create with osascript and something like ncurses, shouldn’t it? Execute line by line using, under the hood, osascript -e (you probably have to surround the line with some helper code that handles variables etc). Keeping state by converting all variables to properties and displaying the output using ncurses (or similar), where you can drill down into variables, lists etc and examine their values?
Wouldn’t that be both very useful and not that complicated (famous last words!) to implement?
No? How? Can you step the code line by line, “play” it until a breakpoint (if there are multiple lines, a loop etc that you don’t need to verify) like you can in e.g., IntelliJ/PyCharm or Eclipse?
Yes, Script Debugger allows you to step through every line of code, and see local and global variables as their values change with each line as it executes. Plus much more.
It has a free trial period and it’s definitely worth a look
I think Script Debugger is excellent, and I really like supporting independent developers, but for me $100 is just too much.
I write a lot of scripts but they’re just for home use - I’ve got one that records everything I feed my dog and works out how much fat she’s getting, I’ve got one that goes through all my TV and films and burns in subtitles, I made one that gets light levels and adjusts the brightness of my lights up or down depending on the lux level.
So you can see that I love AppleScript but this is all strictly amateur coding, for use at home, to do mostly useless things, but I love writing the code.
I really can’t justify paying $100 for a (brilliant) program that would help my silly amateur scripts get better. If I was using code commercially I’d happily pay. But it’s just a hobby
Fair enough. Some people will pay a lot more than that to support their hobbies.
Just keep in mind that if you ever feel like making scripts work or finding why a script doesn’t work is too tedious and time consuming, even for a hobby, check out Script Debugger.
Also, anyone interested should check out this page which has links to numerous 20 second videos that illustrate how ScriptDebugger works.
Yeah you’re totally right. It’s strange where people draw their lines. For other hobbies I might spend endlessly.
I think what makes me not want to pay $100 is cos I can do everything I need to do without it. It’s a brilliant piece of software and I loved using it during the trial, but I guess the fact that every aspect of what I was doing (using AS, Numbers, HomeKit, weather APIs; Pages and so on) was free (part of the price of the computer), so my brain says “you can do all this for free so $100 is too much”.
It’s not a big deal, but I do find it interesting how we all draw our lines in different places. I know I would pay $50 for it, but not $60. Why? No idea. I appreciate your thoughts
It is possible to do things like insert a “log” command between every line. We can process AppleScript documents with AppleScript. Various approaches are possible, such as detecting the variables in each line and passing the detected variables to the log command as parameters.
--Original
repeat with i from 1 to 10
display dialog (i as string)
end repeat
--Processed by other AppleScript to line by line (image)
repeat with i from 1 to 10
log i
display dialog (i as string)
log i
end repeat
In the end, the code is written in a way that checks the execution results of blocks of code such as subroutines, rather than executing them line by line.