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

Re: FOR LOOP



PureBytes Links

Trading Reference Links

>I am trying to do a for loop that increased not by 1.

In most programming languages, a "for" loop is simply shorthand for
a "while" loop.

The general form in Visual Basic is:

for counter = initial_value to final_value [ step increment ]
   [loop body goes here]
next

This is identical to:

counter = initial_value
while counter <= final value
   [loop body goes here]
   counter = counter + increment
wend

So in EasyLanguage you would have:

counter = initial_value;
while counter <= final_value begin
   [loop body]
   counter = counter + increment;
end;

If your counter and increment AREN'T integers, then it's a good idea
to handle error accumulation as follows, so that the final loop is
guaranteed to be executed:

counter = initial_value;
fv = final_value + 0.01 * increment;
while counter <= fv begin
   [loop body]
   counter = counter + increment;
end;

>i.e.
>for i=0.1 to 1 begin

You can't use i by itself; that's a reserved word (for open interest)
just like O, H, L, C, V are reserved for open, high, low, close, volume.

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \     Unicorn Research Corporation -- http://unicorn.us.com 
 // __)    HTML FORMATTED MAIL SENT HERE WILL BE REJECTED AS SPAM.