Thanks Hood. Sometimes you can stare at a piece of code and not see a simple error!
It's a script to home my axis which is called from a brain. The script is much cleaner than that now, the counts and other variable sets were just a test to confirm the script was running as if there is an error in the code the whole script gets ignored. I wanted to do the whole thing as a brain so I could have a timer set so that the button needs to be held for 2 seconds. Using the refall in a brain does not home my dual screw axis as I like, so to align it for square I had to go with the brain / macro pump way.
Why do you think it will be slow and unpredictable? If the condition at the beginning is not met, it just exits and runs again when it's called. If I've asked for a refall (led 2000 is active), there is nothing else going on with the machine, and nothing else in the pump that needs to be done, so it's ok if the pump timer pauses whilst the code runs.
If there is abetted way to do this please tell me.
It's working pretty good now.