What about a community effort to create an AS enviroment where you can step through the code line by line?

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?

Doesn’t Script Debugger already do what you need:

2 Likes

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 you can, that’s what it was created for!
Practically everyone who does serious AppleScript uses it.

Go check it out.

2 Likes

I think that using debugger should do all of this (click Debugging in the toolbar).

I personally never use the debug mode but I’m sure others will give you more info.

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

3 Likes

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 :slightly_smiling_face:

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.

1 Like

You can run Script Debugger for free in a ‘lite’ mode - which is still much better than Script Editor.

1 Like

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

I didn’t know this. I’m gonna have to investigate - I didn’t even check; I just saw that I ran out of trial time and sulked for a few days lol

Thanks for the info!

Damn, those 20 second videos really look good.

You’d better be on commission cos I’m now getting a taste and it’s good, so I think I’m at the beginning of the “ok here’s my credit card” process

I thought like you when I starting scripting years ago.
But it has helped and saved me so much time after I bought it.
I couldn’t compute without it.

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.

Just a longtime user (ever since MacOS X was released)