Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 03:39 29 Mar 2024 Privacy Policy
Jump to

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 States
Posts: 30
Posted: 12:31pm 23 Nov 2020
Copy link to clipboard 
Print this post

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 States
Posts: 261
Posted: 12:32pm 23 Nov 2020
Copy link to clipboard 
Print this post

Not that I’m aware...
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 12:49pm 23 Nov 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 3807
Posted: 12:54pm 23 Nov 2020
Copy link to clipboard 
Print this post

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 States
Posts: 30
Posted: 02:38pm 23 Nov 2020
Copy link to clipboard 
Print this post

@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


To reply to this topic, you need to log in.

© JAQ Software 2024