06-09-2024, 06:14 PM
In c, there really is no SUB or FUNCTION. The main difference is that what basic considers to be a SUB would basically be a Function with a return; with no value attached to it.
For example, let's look at the simple sub_preset:
See the return there, with no value attached. That's basically what we'd call a SUB.
And compare that to the FUNCTION Console:
See where we return the screen handle for the console there?
That's basically the difference in what we consider to be SUB vs FUNCTION, on the c-side of things.
So, the person who wrote the example for us basically decided that they didn't need the error return value, and they'd rather call it as a SUB than as an errorcode = FUNCTION type routine.
Unless you need the return value, for most c-style routines (like the windows API), you can use SUB instead of FUNCTION.
Now, if you want that return value, then you're definitely going to want to use FUNCTION when you reference it.
For example, let's look at the simple sub_preset:
Code: (Select All)
void sub_preset(float x, float y, uint32 col, int32 passed) {
if (is_error_pending())
return;
if (!(passed & 2)) {
col = write_page->background_color;
passed |= 2;
}
sub_pset(x, y, col, passed);
return;
}
See the return there, with no value attached. That's basically what we'd call a SUB.
And compare that to the FUNCTION Console:
Code: (Select All)
int32 func__console() {
if (is_error_pending())
return -1;
return console_image;
}
See where we return the screen handle for the console there?
That's basically the difference in what we consider to be SUB vs FUNCTION, on the c-side of things.
So, the person who wrote the example for us basically decided that they didn't need the error return value, and they'd rather call it as a SUB than as an errorcode = FUNCTION type routine.
Unless you need the return value, for most c-style routines (like the windows API), you can use SUB instead of FUNCTION.
Now, if you want that return value, then you're definitely going to want to use FUNCTION when you reference it.
