[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Global variables



PureBytes Links

Trading Reference Links

Global variables defined withing a function are scoped to that 
function and all the sub functions within that function. But once 
you call outside that function the variable is not available. If you 
want the variable to be global it has to be in a global scope, 
outside of the functions that will use it. Declare it at the top of 
your code and it will have global scope as you mentioned. Otherwise 
pass it as a parameter. This is much safer. You have to be careful 
when using globals because anyone can change a global anytime and 
anywhere, darn hard to debug if that happens. If that is OK then 
make it global.

I would have to look at your code to see what you are doing. 

Barry

 --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@xxxx> 
wrote:
>
> I have had some problems with defining globals within a function. 
> 
> Globals defined withing a function are not always available to 
code later on. In one situation, a global defined within a prior 
function and used in an indicator, was not available to some copies 
of the indicator and was available to some others where the 
indicator was used multiple times in same instance, but on different 
panes.
> 
> If I initialize the variable at the beginning of the program, it 
is automatically a global and always works reliably.
> 
> Anyone with similar issues?
> 
> Ara
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/