Lesson 7 - Functions

 

Hi folks,

I hope you enjoyed the Loops & Decisions lesson and the previous lessons as well.

In this lesson we will know how to write Functions in MQL4 and how to call(use) them. and...

Why don't you download the lesson , it's FREE

I hope to see your comment.

Files:
lesson7.pdf  47 kb
 

I just finished with Lesson # 7 and have one question:

what is the sausage machine?

Sorry I've never seen in my life ...

 
newdigital:
I just finished with Lesson # 7 and have one question:

what is the sausage machine?

Sorry I've never seen in my life ...

I Didn't See It Either , but I think the attached image will make it clearer

Files:
 

Hi,

I am new to this programming language, and have been examining some MT4 programs. Having read this lesson, I am wondering, why do init(), deinit() and start() functions has int as a return type?

E.g.

int init()

{

comment ("blah blah");

return 0;

}

Why 0? Why wasn't the type void instead of int?

Thanks,

BlackWood

 

ok..... either i undrestand everithing, or either i undrestand absollutly nothing

1,

double // ok i got that, the function needs to be set a type

my_func (double a, bouble b, double c)

{

return (a*b+c);

}

// ok i got that the function can be named, and "my_func" is the name. I got that a,b and c are parameters, but what is "double"? a keyword??

// if "double" is not a keyword, but part of the parameter's name.. why is not "(double a * double b + double c)" .. or maby "double" is the type

// of parameters a,b and c... but why then we set the type of the function it self any way?

// explain in details pls i dont get it

2,

void

my_func (string s)

{

print (s);

}

// again... what is "string"? a keyword? and why nothing this time has no set of type? i got what is "void", but.. is void also meen the type setting?

3,

int collect (int first_number, int second_number)

// if here "int" in brakets is a seting of type, so double is a type seting after all?

{

return (first_number + second_number);

}

// "collect" is the function's name right?

4,

int a=10;

int b=15;

int sum = collect(a,b); // i dont underestand why we set a type of "int" if we call a function, witch when build we shuld already set the type

Print (sum);

// again... what is "collect"? name of diferent function? because there in the previus one has diferent parameters... and u say that we use previus function by different way, so it's the same function, but in that case...where the parameters of the previus function go? and what is the way to use new parameters in the old function... i dont understand what is... or how... the thing about "calling a function" i dont get it at all. i got it what is for, but not how, can be doned, not enough details i thing...

I am sorry about my bad english.. i try

Im pretty shure that u laughing a big time now when u read what i got underestand... pls help pls more... examples in many defferent samples, and pls explain all the words witch what is

this is the first lesson i dont underestand something

tank you!! respect!!

Reason: