He's not trying to test if a script is loaded, he's trying to test if an asynchronous command is still "running" (like a socket operation).. his variable name %alreadyloaded might have been a little misleading.
To the OP:
You could have solved the loading problem (%alreadyloaded exists on start) by simply:
ON *:START:unset %alreadyloaded
As far as sharing instances goes, global vars would indeed not be able to get around that.
Another solution might be to create a hash table and check its existence much like a window
alias start {
if ($hget(mytable,running)) {
echo -a RUNNING! | halt
}
hadd -m mytable running $true
; do stuff
}
alias end {
hdel mytable running
}
This is a little cleaner in that it doesn't open a window. You can also use the hash table to store data that might be needed by the asynchronous command anyway, rather than global vars.