Hello
Just answered myself.  The visibility of a variable is global, but proper value 
only exists inside the if statement. So outside, the value is indeterminate, 
hence the run error.

Still unsure what use a single pass using status("stocknum")==0 could be used 
for.  In my case I tried to initialise constants a single time rather than for 
every symbol iteration, thinking I could save time and memory.  TJ no doubt has 
this covered.
regards

--- In [email protected], "oceanchimes" <oceanchi...@...> wrote:
>
> Hello all,
> Hope someone can shed some light on this.  I thought I could set variable 
> constants once by using
> 
> if (Status("Stocknum")==0)
> { WLNum=12; }
> 
> then later in the exploration/backtest code
> 
> symlist = categorygetsymbols(categorywatchlist,WLNum);
> 
> This code checks ok, but a run error occurs,
> variable 'WLNum' not initialised before being used.
> 
> Easy way out was to remove the if statement. I thought the variable would be 
> global andso valid.  I'm using latest beta AB ver 5.30.1 and win7.
> 
> Since it seems variables declared in the if statement aren't visible to the 
> rest of the code, when could you use status("stocknum")==0 ?
> many thanks
>


Reply via email to