@Jacque.
I think each field has its own properties.
@ Jon.
Correct? In any case what Jacque mentioned is a powerful tool, and you should play with it.
A command handler is like a subRoutine, just what you have now. Execution branches from the "main" handler and continues in the subRoutine, and then returns to the main. The subRoutine does its business, and if you want variables to track from one to the other, set them as script local variables at the very least.
Function handlers (usually) return a value to the main handler:
Code: Select all
on mouseUp
put getRandomChar("ABCDEFG") into fld 1
end mouseUp
function getRandomChar var
return any char of var
end getRandomChar
Now could this have been done in-Line in the main handler? Yes, in this trivial case.
In your post, you definitely need a command handler. Lots of ordinary work is done there, and no returned value is required by the main handler.
You will know when you need a function, though, and feel free to ask for help. In the meantime, practice making some. They are reusable and will greatly streamline your code, which currently, I suspect, does all such labor in the main handler. No project of any substance could possibly be built without them.
Know that one can use a command handler to return a value as well, but that is a sort of miniKludge, and can wait...
Craig