Hi Earik,
Can you pass arrays into functions? If so, can you provide an example of the syntax?
I tried doing this numerous ways, including the c++ syntax but could not get it to work. I'm assuming arrays would be passed by reference but I kept running into an issue where the function would not recognize the input as an array and I couldn't figure out how to cast it correctly.
Let me know if you need an example of what I was trying to do.
Thanks!
hjelmstade
Passing arrays into functions?
-
- Posts: 34
- Joined: Wed May 18, 2016 6:51 pm
- Contact:
Re: Passing arrays into functions?
Yes, sort of. I haven't done it in a while, so I had to mess around to remind myself though. Try it like this:
indicator:
function: "testfunc"
So basically, just pass it as a regular variable. The trick is that the function isn't going to know it's an array, and will think it's a regular variable, so you can't use array-specific functions (sort, etc) and have to also pass in things like length along with the array itself.
Regards,
Earik
indicator:
Code: Select all
define array one[];
if (barnum == barsback) {
push(one,1);
push(one,2);
push(one,3);
ret=testfunc(one);
}
plot1=ret;
Code: Select all
input:myin;
return myin[1];
Regards,
Earik
-
- Posts: 34
- Joined: Wed May 18, 2016 6:51 pm
- Contact:
Re: Passing arrays into functions?
Got it, thanks Earik. My issue was trying to use clear() in the function after I had passed. I'll just avoid passing arrays and will instantiate where I need them.
Thanks!
Thanks!
Who is online
Users browsing this forum: No registered users and 66 guests