Return value from a function

Blitz3D Forums/Blitz3D Beginners Area/Return value from a function

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It's true that a function can only return one value, so it requires one more layer of abstraction in order to "return" multiple values. This is probably what he meant by "trickery".

The first thing I can think of is that you can return a custom type with two fields for each value. Or, if you're returning two ints that are less than 2^16, you can use bit shifting\masking techniques to pack the shorts into one int and return that (and then unpack them afterwards). You could also use a bank.

Anyway, I prefer the custom type method. No matter what you do, though, another layer of abstraction means more processing/muddling.