Error when "StringSubstr" used, pls help

 

Hi,

I'm porting my mq4 program to mq5 and I face compilation issues, not sure what variable expected here as I'm already passing str variable for StringSubst. 


   const string str=NewsArr[0][nomf];

   string time=StringConcatenate(StringSubstr (str,0,4),".",StringSubstr(str,5,2),".",StringSubstr(str,8,2)," ",StringSubstr(str,11,2),":",StringSubstr(str,14,4));


Error:

'StringSubstr' - variable expected   


Pls help

 
sathyaicm: string time=StringConcatenate..
Is this an indicator with code in OnCalculate where you have a parameter named time?
 

whroeder1: Thanks for your reply! No this is not for indicator, time is just a string array.

I'd initialized as below,

int time1[150],time2[150],time3[150];
string time[150],timeread[150],timeap[150];
string hour[150],hour1[150],hour2[150];

 
sathyaicm:

Hi,

I'm porting my mq4 program to mq5 and I face compilation issues, not sure what variable expected here as I'm already passing str variable for StringSubst. 


   const string str=NewsArr[0][nomf];

   string time=StringConcatenate(StringSubstr (str,0,4),".",StringSubstr(str,5,2),".",StringSubstr(str,8,2)," ",StringSubstr(str,11,2),":",StringSubstr(str,14,4));


Error:

'StringSubstr' - variable expected   


Pls help

It does not work when you use it within the StringConcatenate() function

Use it like this instead

   string time=StringSubstr(str,0,4)+"."+StringSubstr(str,5,2)+"."+StringSubstr(str,8,2)+" "+StringSubstr(str,11,2)+":"+StringSubstr(str,14,4);  
 
Mladen Rakic:

It does not work when you use it within the StringConcatenate() function

Use it like this instead

   string time=StringSubstr(str,0,4)+"."+StringSubstr(str,5,2)+"."+StringSubstr(str,8,2)+" "+StringSubstr(str,11,2)+":"+StringSubstr(str,14,4);  

Yes it works with StringConcatenate(), but the mql5 version of this function is not the same as mql4.

   string time;
   StringConcatenate(time,StringSubstr (str,0,4),".",StringSubstr(str,5,2),".",StringSubstr(str,8,2)," ",StringSubstr(str,11,2),":",StringSubstr(str,14,4));  
 
Alain Verleyen:

Yes it works with StringConcatenate(), but the mql5 version of this function is not the same as mql4.

   string time;
   StringConcatenate(time,StringSubstr (str,0,4),".",StringSubstr(str,5,2),".",StringSubstr(str,8,2)," ",StringSubstr(str,11,2),":",StringSubstr(str,14,4));  

Yep. My bad ;(

Thanks :)

 

Awesome!!!

Thanks Mladen Rakic It worked

 
sathyaicm:

Awesome!!!

Thanks Mladen Rakic It worked

Yes, but read this post too :

Alain Verleyen:

Yes it works with StringConcatenate(), but the mql5 version of this function is not the same as mql4.

   string time;

   StringConcatenate(time,StringSubstr (str,0,4),".",StringSubstr(str,5,2),".",StringSubstr(str,8,2)," ",StringSubstr(str,11,2),":",StringSubstr(str,14,4)); 


So it works within string concatenate too (if the first parameter is not omitted and is properly declared as variable)

It depends what form do you like more. I don't like StringConcatenate() (which is obvious:)) and I prefer using the + form (less code and simpler to follow) - but that depends on the style I guess

 

Hi,

Sorry to revive such an old post, but I'm trying to do the same thing and I am facing a different error.

I added the url specified at this link but I'm getting this error.




Any idea why?

Regards,

PS

Reason: