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

Re: [amibroker] Re: Global variables



PureBytes Links

Trading Reference Links

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@xxxxxxxxxxxx>
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

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