Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : CMM2: Can functions return an array?
Author | Message | ||||
johnd Newbie Joined: 22/10/2020 Location: United StatesPosts: 30 |
Just wondering if functions can return an array? I know functions and subs can be passed in an array and that can be altered, which is fine by me. But I'm just wondering if I'm missing something, and I'd like to be consistent between subs and functions if possible. I've tried function xxx(x%, y%) local integer a(2) a(0) = x% a(1) = y% xxx = a end function but no go. Just curious. Thanks, johnd |
||||
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261 |
Not that I’m aware... |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
Where is declared the return from this function? Maybe: function xxx(x%, y%) as integer local integer a(2) a(0) = x% a(1) = y% xxx = a end function Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
You cannot return arrays from functions. Regards, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
johnd Newbie Joined: 22/10/2020 Location: United StatesPosts: 30 |
@thwill: That is what I thought, but asked just in case. I'll just use subroutines and pass in the return array as an argument to be filled out within the subroutine. Thanks. |
||||
Print this page |