Cannot See Variables in Subroutine

Just getting started with Script Debugger
So I’ve got a routine that is stepping through all characters in a string… No problem there, but in Script Debugger, it is not showing any of the variables in the subroutine - it only shows variables from the main routine.

So, if I have this code:

set a to "John Q Smith"
set b to checkAuthorInitials(a)

on checkAuthorInitials(author)
– given an author name, add a period after initials
set newName to ""
set lastC to "1"
repeat with thisC in the characters in author
log thisC
set charid to id of thisC
set lastid to id of lastC

I see “a” and “b” variables, but even when I step into the subroutine, I don’t see newName, lastC, thisC, etc.

Am I missing something?

Variables local in a handler/subroutine must be explicitly declared local using an AppleScript local varName statement in order for Script Debugger to be able to “see” them.

This is explained in greater detail in Script Debugger’s help book. Just search for variables.

I also discuss this issue in this blog post.

2 Likes