A subroutine, as the name suggests, allows you to parcel away bits of code that might otherwise clutter up your source... handy for your main loop where reading through a list of thoughtfully named subroutines (rather than the raw code they contain, all in a big heap) can help keep things clear. Or for instances where you might want to reuse code without repeating it inline.
Functions can take values, manipulate them and return a value - so you can apply the same process to any variables/objects you please (within the bounds of what makes syntactic sense) whereas a subroutine can only affect the variables/objects that it is hard-coded to alter.
Each has their place, I think - does Max have subs yet? ;D
Functions can take values, manipulate them and return a value - so you can apply the same process to any variables/objects you please (within the bounds of what makes syntactic sense) whereas a subroutine can only affect the variables/objects that it is hard-coded to alter.
Each has their place, I think - does Max have subs yet? ;D