Professional Documents
Culture Documents
MQL5 Language Basics STRING TYPES
MQL5 Language Basics STRING TYPES
//string str;
/*
"substrings";
*/
//string str1,str2,str3,str4,str5;
// passed to this function is a message template, that indicates the the placers for
// inserting variables and the set output formats; - it is then followed
// by enumeration of all variables in the order in which they appear in the template
// IS USED to search for a substring. it returns the index of the first occurence
// 3rd (optional) can determine the position at which the search starts
/////==== STRINGLEN()=====//////
int OnInit()
/*
if (StringLen(str1) != 0){
Print(str1);
*/
//assign values
// str1 = "Programming";
//str1 += str2;
//str1 += str3;
//OR
//Print(str4);
//Print(str3);
/* StringAdd(str1," ");
StringAdd(str1,str2);
StringAdd(str1," ");
StringAdd(str1,str3);
Print(str1);
*/
// Print(str1);
/*
int x = 1;
Print(str);
*/
//double x = 1.12345;
//The second parameter of this function determines the precison (the no. of dp)
/*
double x = 1.123456789;
*/
// eg 2023.03.01 17:50
// (year,month,day,hour,minute)
// Print(str1);
//Print(str2);
// when calling the time to string fn, we have the option to specify the date and
// time format
//OPTIONS AVAILABLE
/*
+ TimeToString(time,TIME_DATE|TIME_SECONDS);
Print(str1);
Print(str2);
Print(str3);
Print(str4);
Print(str5);
*/
// 255,0,0
Print(str1);
Print(str2);
*/
/*
double x = 123.4567;
Print(str);
*/
/*
uint variable1 = 1;
int variable2 = 2;
int variable3 = 3;
//----long addition
variable1,variable2,variable3);
Print(str1);
Print(str2);
*/
// double d = 5.5;
// you can set the required No. of the dp by using . followed by the no. of dp (.)
// You can specify the total length of the no. by writing "0" and a number that determines
// the length of the number at the hand right after the % and then specify the
// to print the % sign need to write it two times im a row, ie, "%%"
//Print(str);
/*
Print(str);
*/
// if the no. of the digits specified is less than the no. of digits in the number,
Print(str);
*/
Print(str);
*/
/*
Print(IntegerToString(position));
Print(str2);
*/
/*
//-------------- CHARTTOSTRING()------------//
ObjectSetInteger(0,obj_name,OBJPROP_XDISTANCE,100);
ObjectSetInteger(0,obj_name,OBJPROP_YDISTANCE,100);
ObjectSetInteger(0,obj_name,OBJPROP_FONTSIZE,50);
ObjectSetString(0,obj_name,OBJPROP_FONT,"Wingdings");
ObjectSetString(0,obj_name,OBJPROP_TEXT,(string)CharToString(93));
ObjectSetInteger(0,obj_name,OBJPROP_COLOR,clrWhite);
*/
/////===== stringgetcharacter()=====/////
//the function allows one to get the code of the character at a given position
u_character3,u_character4);
*/
Print(str);
*/
///===========---StringLen() fn======/////
if (length > 10 ){
Print(str);
return(INIT_SUCCEEDED);