Qbasicnews.com

Full Version: functions or subs?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To be honest you can do either one. But the general idea is that if the routine returns something back to you (e.g. a calculated value, an error message, anything really) its a function. If it just does something and then comes back to the calling code, its a sub. Some languages (C for example) don't really have a difference (a sub is a function that doesn't return anything, it returns a VOID).

So for your 3d cube, my first gut thought would be to say a sub. BUT, if you want to return an error code (e.g. if it would be drawn offscreen for example) then maybe a function.

If you have to ask (because you are a beginning programmer, no insult meant) then go always go with a sub unless you KNOW you need to make a function. Why? Because its easier to go with a set rule until you understand why not to :-).