|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
Just few questions.
for (int i=0; i>15; i++) { if (i==10) break; Print (i); } As I understand it starts at i=0 and will continue untill the i>15 is true but suddenly it will be stoped because i==10 should be break. Thus we will have the values from 0 to 10 only. Right? 1. It was example for Multistatement in Loops and we used braces (see example). What are the rules to use braces? ({) 2. As I understand i==10 in the example above is the test expression and we must use relation operators instead of simple assignment operators (=). So i==10 is right (because == is relation operator). I am right? 3. What is Print? Do we need to use/write Print in capital letter? Is it printing? Will we use this "Print" when we will write EA or indicator? 4. Why everything is located like this? I changed the font size but in the example everything is located in some strage way, not the same as you described us in Format lesson that we may use any space etc. A lot of indentions and different indentions: { is located under f letter, i on the next line is using indention, break is under f, P in Print is under i (if) and so on. Do we need to do it? And what are the rules for that indentions? Last edited by newdigital : 11-01-2005 at 08:44 AM. |
|
|||||
|
Quote:
for(int i=0;i<15;i++) { if((i==10) break; Print(i); } And it means the loop work every time the Test Expression i < 15 is true. So, it starts at i=0 and will continue until the i<15 is false In your example the loop will not work even for one time, because i will never be > 15. This was an example of Break statement which will terminate the loop when i==10. Quote:
1- Every opened brace ({) has to be matched with a close brace (}), or you will get an error. 2- There's no semi-colon after the braces. 3- You can use braces too in a single line statement to make your work tidy and readable. Quote:
Just keep in your mind that == means the question Is Equal. Quote:
And it must start with a capital latter, because as you said in the MQL4 Data types lesson the functions names [identifiers in general] are case sensitive, so you have to type it Print. Quote:
But, to make your code tidy, readable and it’s a recommended way to avoid bugs in your code. You have to use indentation like the above example. |
|
|||
|
I appreciate your taking the time to provide these tutorials. I haven't programmed in C since the 80's, so this is helping knock off some of the rust.
Not to be trite, but in your next rev of the tutorial, you might want to correct the statement below (it's in your reply above as well as on page 5 of the tutorial) in that the brackets/parenthesis for the 'if((i==10)...' are unbalanced. Thanks again, MarkC. Quote:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/lessons/169-loops-decisions-part1.html
|
|||
| Posted By | For | Type | Date |
| Strategie i Systemy Forex | This thread | Refback | 07-09-2008 07:33 PM |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Lesson 6 - Loops & Decisions (Part2) | codersguru | Lessons | 1 | 05-18-2007 02:20 PM |
| Lesson 10 - Your First Indicator (Part1) | codersguru | Lessons | 1 | 11-08-2005 11:17 PM |