Zasy wrote:
Sure, I'm aware of Gosub but I learned it's not good programming practise, code should flow, not jump around.
Who says it's not good programming practice? Functions and Gosubs are VERY similar, and each has advantages and disadvantages:
Function: advantage: 1) Can be fed as many parameters from the main program as needed. 2) Isolates variables within from those in main program.
disadvantage: 1) Only one value can be ejected (returned) from it. 2) Isolates variables within from those in main program.
Gosub:1) Can be fed as many parameters from the main program as needed. 2) It returns back to the main program as many values as you need. 3) Uses the same variables as the main program.
disadvantage: 1) Uses the same variables as the main program.
As I see it, Functions have their use, and Gosubs do, also.
You will also note that for each of the above, an advantage has been listed that can also be a disadvantage, depending on your programming style.
Sure, I'm aware of Gosub but I learned it's not good programming practise, code should flow, not jump around.
Who says it's not good programming practice? Functions and Gosubs are VERY similar, and each has advantages and disadvantages:
Function: advantage: 1) Can be fed as many parameters from the main program as needed. 2) Isolates variables within from those in main program.
disadvantage: 1) Only one value can be ejected (returned) from it. 2) Isolates variables within from those in main program.
Gosub:1) Can be fed as many parameters from the main program as needed. 2) It returns back to the main program as many values as you need. 3) Uses the same variables as the main program.
disadvantage: 1) Uses the same variables as the main program.
As I see it, Functions have their use, and Gosubs do, also.
You will also note that for each of the above, an advantage has been listed that can also be a disadvantage, depending on your programming style.