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

Re: [amibroker] Re: Global variables



PureBytes Links

Trading Reference Links

yes ... Arrays have been very confounding for me too ...


----- Original Message ----- 
From: "Barry Scarborough" <razzbarry@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, November 02, 2005 11:15 AM
Subject: [amibroker] Re: Global variables


> I may have given you a wrong lead. I am a C++ programmer and the AFL 
> syntax is much like it. I just use the C++ conventions and I have 
> not had any trouble, well not with syntax anyway. Hope I have not 
> misled you.
> 
> The unreliability may be caused by the sequence in which you declare 
> the "globals". If a function earlier in the code relies on a global 
> declared later that may cause the problem you have. A C++ compiler 
> would tell you but AFL does not and seems quite unforgiving at times.
> 
> I still think that passing parameters is the safest way to go. Or 
> declaring your globals at the beginning. Then you know for sure they 
> are global. If you declare them in functions you are just asking for 
> trouble and trouble seems to have found you so try some other way 
> and see if it helps.
> 
> Confusing huh? Learning AFL has been one confusing moment after 
> another for a couple of years now. I can't quite get the array based 
> mentality down pat and revert to procedural thinking and get all 
> screwed up. Thanks for trying to help me understand how AFL works, I 
> need all the help I can get.
> 
> Cheers,
> Barry
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@xxxx> wrote:
> >
> > Barry
> > 
> > this is getting confusing ...
> > 
> > Globals defined as such within a function seem available 
> globally ... but as
> > I indicated earlier... not reliably.
> > 
> > According to the help files, there is no distinction between 
> globals defined
> > within functions and variables initialized outside of functions.
> > 
> > Where did you see the distinction you mentioned?
> > 
> > Hope this thread resolves the "mystery" of globals.
> > 
> > 
> > Ara
> > 
> > ----- Original Message ----- 
> > From: "Barry Scarborough" <razzbarry@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Wednesday, November 02, 2005 8:54 AM
> > Subject: [amibroker] Re: Global variables
> > 
> > 
> > > 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
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > 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
> > >
> > >
> > >
> > >
> > >
> > >
> >
> 
> 
> 
> 
> 
> 
> 
> 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
> 
> 
> 
>  
> 
> 
> 


------------------------ 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/