Ahhh. Ok. I've got you... I was under the impression it was where they are 
'first used'.

i.e. if a function is not called in the main code until after the declaration 
of a variable (outside of the function) then it was 'first used' in the main 
code and hence global... I guess 'first used' means 'first parsed'...


--- In amibroker@yahoogroups.com, "Mike" <sfclimb...@...> wrote:
>
> Your assumption is mistaken. Unless explicitly stated otherwise, the scope of 
> the variable is dictated by where it first appears. Since test_sig first 
> appears within your procedure, it defaults to local to that procedure. You 
> can override that by declaring it global from within the procedure, or move 
> the main initialization above the procedure usage.
> 
> http://www.amibroker.com/guide/a_userfunctions.html
> 
> Mike
> 
> --- In amibroker@yahoogroups.com, "sidhartha70" <sidhartha70@> wrote:
> >
> > I'm going to shame myself by asking a very simple question... why does the 
> > following code produce an error...? Namely that 'test_sig' has been used 
> > without being initialized.
> > 
> > procedure Test()
> > {
> >    if( test_sig ) _TRACE("Hello");
> > }
> > 
> > test_sig = 0;
> > 
> > Test();
> > 
> > I was under the impression that defining test_sig after the procedure (i.e. 
> > I always put my functions & procedure definitions before the main body of 
> > my code) it was automatically assigned "global" status....?
> > 
> > Thanks
> >
>


Reply via email to