Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass an array as a parameter?
#1
A question today, rather than a bug. :-)

Is it possible to pass an array as a parameter to a function or a sub?

And if so, does the function/sub receive a copy of the array or a pointer to the original? i.e. if I made changes to the array within a function, would those changes be local to the function or would they also be visible from the calling method?
Reply
#2
LTee Wrote:A question today, rather than a bug. :-)

Is it possible to pass an array as a parameter to a function or a sub?

And if so, does the function/sub receive a copy of the array or a pointer to the original? i.e. if I made changes to the array within a function, would those changes be local to the function or would they also be visible from the calling method?
Not yet. This is something "in the queue". Most deep code refactoring (like the new preprocessor and so on) are oriented to such things. Please, be patient...
Arrays will be pased like strings (pointers to the HEAP).
Reply
#3
That sounds ideal. Thanks for the prompt response!

I suspected it might not be in there yet, but wanted to check that I wasn't just messing up the syntax. :-)
Reply
#4
LTee Wrote:That sounds ideal. Thanks for the prompt response!

I suspected it might not be in there yet, but wanted to check that I wasn't just messing up the syntax. :-)
First thing first: ZX BASIC will allow dynamic arrays (Sinclair BASIC compatible). Later, the compiler will allow them be passed via parameters. Then use Lbound() and Ubound() to get the Dims...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)