Quote: "Wouldn't functions work as well?"
Yes sure they would. There's very little difference between a function and a procedure (that you Gosub).
The main difference is that with procedures, you still have access to all your variables and any changes you make are global. Eg if A=10 before you Gosub a procedure and you say A=20
inside the procedure, A will equal 20 when you get back.
Inside a function, the variable A would be
local which means it is an entirely separate entity to the variable A
outside the function. If it was 10 before calling the function, it will not exist on entering the function and will still be 10 on return from the function - regardless of what it is set to inside the function*.
For this reason, you have to pass variables you need to use in a function in the function's calling parameters. For the same reason, functions can also return a parameter.
Function Tutorial:
http://www.computechtenerife.com/DB/tutorials.htm
So, I tend to use procedures all the time, and Functions when I want to create extra commands or need something that calculates a specific result.
There are no hard and fast rules on which you use though!
TDK_Man
* Ignoring the non-destructive bug in DB Classic.