[Coding Issues] Unable to read and select values from .csv file, function returns no error - page 2

 
ProfessorMetal: Makes perfect sense to me.
  1. Learn to code, no slaves here https://www.mql5.com/en/forum/145969
  2. Use SRC (not paste,) image (not attach) and edit
  3. Search and RTFM before asking
  4. stay on topic Any discussions except of concerning MetaQuotes Language 4 and auto trading are forbidden.
  5. My bag of goodies
 

Dear Prof. Metal,

Thanks for the effort, really appreciate it!

I did managed to solve it. I ended up doing it this way, and it does exactly what I want:

// Opens the file: from now on we are in the file
   int handle = FileOpen("Calendar.csv",FILE_READ|FILE_CSV,',');
   if (handle==-1||FileSize(handle)==0)
       Print("Error is ",GetLastError());
  
      while( FileTell(handle)< FileSize(handle) )
       {   
    	 NewsDate = FileReadString(handle);
    	 NewsTime = FileReadString(handle);
    	 NewsTimeZone = FileReadString(handle);
    	 NewsCurrency = FileReadString(handle);
    	 NewsEvent = FileReadString(handle);
    	 NewsImportance = FileReadString(handle);
    	 NewsActual = FileReadString(handle);
    	 NewsForecast = FileReadString(handle);
     	 NewsPrevious = FileReadString(handle);   
     
         if(StringFind(NewsEvent,Event)>=0)
           break;  

       }

Unfortunately I am not that comfortable with using arrays, so that's why I fixed it without using them, but I really understand that if you are able to use arrays, coding life is much easier. I really should learn it and I'll probably will :)

Also thanks for the effort to you WHRoeder!

 
Maarten91:

Dear Prof. Metal,

Thanks for the effort, really appreciate it!

I did managed to solve it. I ended up doing it this way, and it does exactly what I want:

Unfortunately I am not that comfortable with using arrays, so that's why I fixed it without using them, but I really understand that if you are able to use arrays, coding life is much easier. I really should learn it and I'll probably will :)

Also thanks for the effort to you WHRoeder!


You're most welcome. There's always more than one way to accomplish a programming task. What's important is that what you do works and that you understand what you're doing and why. You do really need to understand arrays because there are lot of things that you either can't do or have to bloated and practically incomprehensible code to accomplish otherwise. Hang on to my example code and you'll it to be a good reference when you do need arrays.


Cheers and Happy Coding!

 
WHRoeder:
  1. Learn to code, no slaves here https://www.mql5.com/en/forum/145969
  2. Use SRC (not paste,) image (not attach) and edit
  3. Search and RTFM before asking
  4. stay on topic Any discussions except of concerning MetaQuotes Language 4 and auto trading are forbidden.
  5. My bag of goodies

Cool


1) Goes w/o saying, IMO, as you probably gleaned from my posts in another thread.

2) Raptor already pointed me in the proper direction on that.

3) Again, goes w/o saying. As a professional developer, that's my first instinct. Tell me and I might remember but probably won't understand. Show me and I'll remember but might not understand. Do it for myself and I'll learn it, remember it and understand it. RTFM - yep definitely. I have the Trader's Guru course and now that I'm firming up some ideas in my mind for indicators and a Trade Management EA that I want to create, I'll be going through the manual thoroughly so I can code them myself.

4) Definitely good advice in any forum.

5) Haven't time to fully comb through but it looks like there's a good bit of information to be gleaned there. I bookmarked it for later reference.

Many thanks, WHRoeder. This looks to be a good forum and I'm looking forward to participating in it.

Have a great day - or night, whichever it is for you at the moment.