| 
 PureBytes Links 
Trading Reference Links 
 | 
Dave,
Yes but you should use global keyword inside function to make sure
it is treates  variables as global and you don't need to declare them before function call:
function SetTwoArrays()
{
   global staReturn1, staReturn2;
   staReturn1 = C;
   staReturn2 = ROC( C, -1 );
   return MACD(); // you can return 3rd array
}
SetTwoArrays();
//staReturn1 and staReturn2 variables are accessible there;
WriteVal( staReturn1);
WriteVal( staReturn2 );
Hope this helps.
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Dave Merrill" <dmerrill@xxxxxxx>
To: "AmiBroker list" <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, February 01, 2004 6:56 PM
Subject: [amibroker] returning more than one array from a function
> Say I have a function that I'd like to have return two arrays. As far as I
> know, there's no direct way to do that, but I'd like to confirm this for
> certain, since it would be very handy, and allow better coding practices.
> 
> The closest we can come I think is to set some variables outside the
> function, before calling it, so they're global, and have the function set
> them. What I don't like about this is that in contrast to some other
> languages, the names of those variables have to be hard coded inside the
> function. I'd much rather pass the names of the result arrays to use (or
> pointers to them) into the function.
> 
> For example:
> 
> ResultArrayOne = ResultArrayTwo = Null;
> function SetTwoArrays() {
> ResultArrayOne = C;
> ResultArrayTwo = ROC(C, 1);
> }
> 
> You have to use the variables named ResultArrayOne and ResultArrayTwo for
> this function to work correctly; those variables are what it sets, no matter
> what.
> 
> Do I have it right that this is the only way to get more than one array back
> from a function?
> 
> Dave Merrill
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> 
> Yahoo! Groups Links
> 
> To visit your group on the web, go to:
>  http://groups.yahoo.com/group/amibroker/
> 
> To unsubscribe from this group, send an email to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
> 
> Your use of Yahoo! Groups is subject to:
>  http://docs.yahoo.com/info/terms/ 
> 
> 
> 
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
To visit your group on the web, go to:
 http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:
 amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 
 |