I dont like STATIC for the SUB, it is not needed here, you only use the SUB once and it seems dangerous to preserve values as you are likely to assume they are cleared with each call to SUB. One of SUBs strengths is independence to main module, if you want to preserve values use GOSUB.
I don't know, maybe it's just programming style, I can't imagine anyone in habit of using STATIC for SUBs.
I am sure there is a case for using it, maybe with recursion?
So SHARED can be used in SUB, somehow I learned it couldn't maybe it was with OPTION _EXPLICIT, the variable has to be declared in main to be able to use SHARED in SUB, something like that.