PureBytes Links
Trading Reference Links
|
Terry,
This is exactly the use of VarSet, VarGet new functions !!
I suppose you already have 9 definitions
A1=...;
A2=...;
...
A5=...
...
A9=...;
After these definitions add the
for( i = 1; i <= 9; i++ )
{
if(i!=5)
VarSet( "A"+i, IIf(A5==1,0,VarGet("A"+i) ));
}
The loop will re-define arrays A1 to A4 and A6 to A9. If A5 is 1,
they will be 0, else they will have their initial value.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, Terry <MagicTH@xxxx> wrote:
> Keith,
>
> Thanks for pointing out my dumb error (vba habits die hard).
> Unfortunately I still get the same error with that fix in.
>
> Terry
>
> PS to Bob: I will enlarge the text. Itıs the transfer to my Mac
that is
> causing the size problem. I do virtually all email from my Mac to
avoid
> viruses.
> --
>
> > Terry --
> > You must use == instead of = for the conditional test in the 'if'
statement.
> > For example:
> > if (A5 == 1) A1= A2 = 0;
> >
> > -- Keith
> >
> > Terry wrote:
> >> How to get non array variables? Problem: I need a variable as
a number and
> >> not as an array to use in a subscript (see code below). Is there
a way to
> >> declare variables as array or numeric? I found the global vs.
local, but not
> >> array vs. numeric.
> >>
> >> Description: I have several conditions calculated that result in
arrays
> >> A1...A9. The values of these arrays are either 1, 0 or -1. When
A5 = 1, I
> >> want to zero out all other arrays for that bar. I keep getting
this error:
> >>
> >>
> >>> Error 6.
> >>> Array subscript has to be a number
> >>>
> >>
> >> The Code:
> >>
> >> //Compute values of A1-A9 first.
> >>
> >> i=BarCount; //I put this in to try and force a non-array
variable. It doesn't
> >> work with or without this line.
> >>
> >> i=BarIndex();
> >> if (A5[i]=1) //A5 trumps all other A rules so make all others =
0
> >> A1[i]=A2[i]=A3[i]=A4[i]=A6[i]=A7[i]=A8[i]=A9[i]=0;
> >>
> >> I suppose there is an array solution that could look something
like this:
> >> A1=A2=A3=A4=A6=A7=A8=A9=IIf(A5=1,0,?);
> >> but a) I donıt know what to put in the not true part that will
leave all the
> >> values unchanged and, b) I would like to know how to obtain a
number
> >> variable.
> >>
> >> I could also do this 8 times (once for each array), but it seems
so
> >> un-elegant:
> >> A1=IIf(A5=1,0,A1);
> >> A2=IIf(A5=1,0,A2);
> >> ...
> >>
> >>
> >> Thanks in advance for any solutions.
>
>
> --
> Terry
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
|