Ended up getting tangled and confused again by an example given in the manual/tutorial regarding Function Calls. Here's the code:
Here is the explanation given for what is happening in Expression_1 of the 'for' loop:
In the header of the operator 'for', we specify the call to the user-defined function Func_yes_ret() that can return one of two values: 1 or 5. According to this value, the amount of iterations in the cycle will change: there will be either 10 (i changes from 1 to 10) or 6 (i changes from 5 to 10) iterations.
Which leads to my question:
Why would 'int i=Func_yes_ret(T)' return 'one of two values'? Shouldn't this return just the value 15? As variable 'T' is assigned with the value 15 in this previous line and 'Func_yes_ret' is calling 'T'.
I assume this has something to do with the lines:
But I fail to understand what 'int i=Func_yes_ret(T)' in the 'for' loop is actually doing if not calling 'T' and then assigning integer 'i' with it's value before testing the condition 'i<=10'.
I'm sure the answer to this is extremely simple for anyone familiar with function calls but I am a total beginner so this is all new information to me.. I apologise in advance for my lack of knowledge/experience around the subject.
Thanks in advance to anybody willing to provide help/assistance.
//------------------------------------------------------------------------------------- int Func_yes_ret (int Times_in) // Description of the user-defined function { // Start of the user-defined function body datetime T_cur=TimeCurrent(); // The use of the function in.. // ..the assignment operator if(TimeHour(T_cur) > Times_in) // The use of the function in.. //..the header of the operator 'if-else' return(1); // Return value 1 return(5); // Return value 5 } // End of the user-defined function body //-------------------------------------------------------------------------------------
... is ...
if(TimeHour(T_cur) > Times_in) { return(1); }
You missed the indentation.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Ended up getting tangled and confused again by an example given in the manual/tutorial regarding Function Calls. Here's the code:
Here is the explanation given for what is happening in Expression_1 of the 'for' loop:
In the header of the operator 'for', we specify the call to the user-defined function Func_yes_ret() that can return one of two values: 1 or 5. According to this value, the amount of iterations in the cycle will change: there will be either 10 (i changes from 1 to 10) or 6 (i changes from 5 to 10) iterations.
Which leads to my question:
Why would 'int i=Func_yes_ret(T)' return 'one of two values'? Shouldn't this return just the value 15? As variable 'T' is assigned with the value 15 in this previous line and 'Func_yes_ret' is calling 'T'.
I assume this has something to do with the lines:
But I fail to understand what 'int i=Func_yes_ret(T)' in the 'for' loop is actually doing if not calling 'T' and then assigning integer 'i' with it's value before testing the condition 'i<=10'.
I'm sure the answer to this is extremely simple for anyone familiar with function calls but I am a total beginner so this is all new information to me.. I apologise in advance for my lack of knowledge/experience around the subject.
Thanks in advance to anybody willing to provide help/assistance.