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

Re: [amibroker] Repetitive Statements with FOR (?)



PureBytes Links

Trading Reference Links




Ken, for 
 
(... i>19 should be i<19...)
 
the construct (i=0; ... i++)  increases 
increases i from 0 to the specified limit... so i>19 would never reach a 
limit...
 
there may be other issues also
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Ken Close 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">AmiBroker List 
  Sent: Monday, November 10, 2003 7:33 
  PM
  Subject: [amibroker] Repetitive 
  Statements with FOR (?)
  
  As I venture 
  into the land of more "pure" programming constructs, I stumble.  Any 
  help?
  I have a 
  complex series of variables calculating values for today, yesterday, up to 
  Ref<FONT face="Courier New" 
  size=2>(<FONT face="Courier New" 
  size=2>xx,-20)
  Instead 
  of
  <FONT face="Courier New" color=#000000 
  size=2>A0 =<SPAN 
  lang=en-us> <FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot<<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorRed<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot><SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2> 
  AND<SPAN 
  lang=en-us><FONT face="Courier New" 
  color=#000000 size=2> Tot<<SPAN 
  lang=en-us><FONT face="Courier New" 
  color=#ff00ff size=2>5<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorYellow<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorGreen<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>);
  <FONT face="Courier New" color=#000000 
  size=2>A1 =<SPAN 
  lang=en-us> <FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>1<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>)<<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorRed<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>1<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>)><SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2> 
  AND<SPAN 
  lang=en-us><FONT face="Courier New" 
  color=#000000 size=2><SPAN 
  lang=en-us> <FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>1<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  SIZE!="2">)<<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>5<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorYellow<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorGreen<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>);
  <FONT face="Courier New" color=#000000 
  size=2>A2 =<SPAN 
  lang=en-us> <FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>2<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>)<<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorRed<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>2<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>)><SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2> 
  AND<SPAN 
  lang=en-us><FONT face="Courier New" 
  color=#000000 size=2><SPAN 
  lang=en-us> <FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>2<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  SIZE!="2">)<<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>5<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorYellow<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorGreen<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>);
  <FONT face="Courier New" color=#000000 
  size=2>And repeat this 19 times,<SPAN 
  lang=en-us><FONT face="Courier New" 
  color=#000000 size=2> back 19 days;<SPAN 
  lang=en-us><FONT face="Courier New" 
  color=#000000 size=2><SPAN 
  lang=en-us> 
  <FONT face="Courier New" color=#000000 
  size=2>I wanted to try and use a For loop, and tried the following.  But 
  I get all sorts of error messages, the most frequent of which 
  is <FONT 
  face="Courier New" color=#000000 size=2>"Type Mismatch, number expected but 
  array found."
  <FONT face="Courier New" color=#800000 
  size=2>for<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(i=<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>0<SPAN 
  lang=en-us>; 
  i><SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>19<SPAN 
  lang=en-us>; 
  i++)
  <FONT face="Courier New" color=#000000 
  size=2>{
  <FONT face="Courier New" color=#000000 
  size=2>A[i]=<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-i)<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2><3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorRed<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>IIf<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(<SPAN 
  lang=en-us><FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-i)><SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>3<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2> 
  AND<!
 SPAN LANG="en-us"><FONT face="Courier New" 
  color=#000000 size=2><SPAN 
  lang=en-us> <FONT face="Courier New" color=#0000ff 
  size=2>Ref<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>(Tot,-i)<<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff00ff 
  size=2>5<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorYellow<SPAN 
  lang=en-us><FONT face="Courier New" color=#000000 
  size=2>,<SPAN 
  lang=en-us><FONT face="Courier New" color=#ff0000 
  size=2>colorGreen<SPAN 
  lang=en-us>! <FONT face="Courier New" color=#000000 
  size=2>);
  <FONT face="Courier New" color=#000000 
  size=2>}
  I tried 
  A+<FONT face="Courier New" 
  size=2>I and 
  that did not work either 
  <FONT face="Courier New" 
  size=2>"Error 
  3.
  Condition in 
  IF, WHILE, FOR statements
  has to be 
  Numeric or Boolean type.
  You can not use 
  array here,
  please use [] 
  (array subscript operator)
  to access array 
  elements<FONT face="Courier New" 
  size=2>"
  The "A"s are 
  arrays, so the A[i] seemed like the right way to go, but then the Type 
  Mismatch.
  I know the 
  answer is probably simple, but I can not see it.
  <FONT face="Courier New" 
  size=2>Help?
  <FONT face="Courier New" 
  size=2>KenSend 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.