Download MetaTrader 5
To add comments, please log in or register
Interested in earning money via MQL5 Cloud Network? Enter your profile!
Mimi
499
Mimi 2016.03.06 08:56 

Hi 

I have an indicator which reads from a csv file. Now after fetching the data it stored in Description which is a string data type.

On Description data are stored in following manners: 

"Apple Fruit"

"Potato Vegetables" 

Using stringfind I want to fetch only Fruit.

I am doing this:

int comp = StringFind(Description,"Fruit",0);

 But it returns comp = -1 all the time. Even if there is a data similar to fruit available on the csv file.

 Please help how to do this.

Thank you in advance. 

Carl Schreiber
5954
Carl Schreiber 2016.03.06 08:58  
Provide the full code to get help!
peter.MT4Web
158
peter.MT4Web 2016.03.06 09:11  

You can be shure that StringFind works correct.

Maybe there is a "fruit" in Description and no "Fruit" ?

You have to check each line of the csv-file seperately.

Keith Watford
Moderator
7960
Keith Watford 2016.03.06 09:18  
Do a small test and Print Description before using StringFind to make sure that "Fruit" is in the string variable
Mimi
499
Mimi 2016.03.06 09:24  

Thank you everybody for such a quick reply. Actually I figure, its happening because of the space. If I search for Apple then its not problem. But if I search for Fruit, then it creates problem. In case of stringfind I need to give start point, I use 0 as start point. But as soon it hit space, I guess it stopped there. 

So I need to find where the space is located. So that In stringfind I can search after the space.

Any idea?

Thank you again. 

peter.MT4Web
158
peter.MT4Web 2016.03.06 09:30  

A space is no problem for StringFind!

Check what's in Description.

Mimi
499
Mimi 2016.03.06 09:35  
eddie:

A space is no problem for StringFind!

Check what's in Description.

Yes checked it out. 
I am extremely sorry, I made a silly mistake, space is not a problem. 

Search type spelling was wrong.

I Solved it now.. Thank you again..

Have a nice day... everybody... 

/
To add comments, please log in or register