Restored from previous forum. Originally posted by pusztry.
To my knowledge you can only return 1 value from a procedure. As an alternative you could use a structure or an array. Arrays in PureBasic are always global so no need to even send it out just manipulate the data in the array and use it as you please. You can actually DIM the array in or out of the procedure.
Restored from previous forum. Originally posted by PB.
> How to return multiple values from a procedure?
You can't -- you can only return one value from a procedure.
Workaround: Make the variables in the procedure global, so that they
retain their values when the procedure is done, and you also don't
need to use ProcedureReturn with them.
Restored from previous forum. Originally posted by pusztry.
Originally posted by PB
> How to return multiple values from a procedure?
You can't -- you can only return one value from a procedure.
Workaround: Make the variables in the procedure global, so that they
retain their values when the procedure is done, and you also don't
need to use ProcedureReturn with them.
Procedure.l MultiReturn(*ret2.l) PokeL(23, *ret2) ; Second return value
ProcedureReturn(45) ; First return value
EndProcedure
a.l = MultiReturn(@b.l)
You can just keep adding pointers, although if you have to have many returned values, you could create a structure to store the values you want to return and pass a pointer to it.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)