Nope ... but I think I got it:
In script debugger, your line:
tell application "System Events" to tell process "WhichSpace" to title of menu bar items of menu bar 1
returns a triplet, e.g: 2, missing value, missing value
which is then saved to a KM variable which SHOULD be an integer but is a string. And so subsequent calculations don't work.
Replacing the script by
tell application "System Events" ¬
to tell process "WhichSpace" ¬
to set temp to (title of menu bar items of menu bar 1)
return item 1 of temp
works like a charm!
I don't know if the AS dictionnary of WhichSpace changed, ( I installed it via homebrew?) but there you have it !
Thanks for the set of macros, very useful.