The loop functionality basically repeats few programming statements again and again with a certain change.
At present two different types of loops are supported by 'tradepp'.
- 'fund' loop
- 'counter' loop
Fund Loop
This loop repeats given programming statements for each 'fund' in a 'family'. Consider the following .mfv file. It is a small example of how a typical ForFund loop looks (and works).
As in the example, the line starting with 'ForFund' defines a variable 'my_fund' for the family SELECT. This loop repeats the statements within the pair of 'BeginFundLoop' and 'EndFundLoop' for every fund in the family SELECT. For each repeatition, the variable 'my_fund' is substituted by the actual ticker of the fund in family SELECT. The resulting svg1.ini file produced by the 'tradepp' program when operated on svg1.mfv will be ===>
As we can see, the syntax ForFund/BeginFundLoop/EndFundLoop is interpreted by the 'tradepp' and the output produced contains just the syntax that can be processed by 'trade'.
Counter Loop
This loop repeats given programming statements for each 'counter' variable going from 'start value' upto 'end value' with each repetition the 'counter' variable is incremented by 'increment' variable. Consider the following code-fragment from a .mfv file. It is a small example of how a typical ForCounter loop looks (and works).
As in the example, the line starting with 'ForCounter' defines the 'counter' variable [i], the 'start value' 0, the 'end value' 4 and the 'increment' 1. This loop repeats the statements within the pair of 'BeginCounterLoop' and 'EndCounterLoop' for every repetition, the 'counter' variable is substituted with the appropriate value. For the example above that will be 0, 1, 2, 3 and 4. The resulting code-fragment from svg2.ini file produced by the 'tradepp' program when operated on svg2.mfv is ===>
Again, as before, the syntax ForCounter/BeginCounterLoop/EndCounterLoop is interpreted by the 'tradepp' and the output produced contains just the syntax that can be processed by 'trade'.
Date Loop
At present this type of loop is not implemented. When I find time, I will work on this. (As the name suggests, this loop will do date increment and decrement.)
Enumeration Loop
At present this type of loop is not implemented. When I find time, I will work on this as well ! And as the name suggests, this loop will be for the enumeration defined by the user. If there is a need to repeat certain code-fragment for user defined variables (say Fibonacci numbers !) then such a loop may come in handy !
|