Errors, bugs, questions - page 898

 

lazarev-d-m:

Yedelkin:

sergeev: does the file have lines?

FILE_LINE_END

Get end ofline indication

I more or less figured it out, the terminal sees csv file not as a table, but as a usual file where all the variables are lined up and separated by a delimiter, and to orientate in it as in a table, I wrote a little sample script to work with csv as with a table, however strange it may sound, today / tomorrow I will throw in CodeBase, I think many will be interesting

lazarev-d-m, my message is not for you. It is for Sergeyev personally.
 
Yedelkin:

FILE_LINE_END

Get end ofline indicator

I'm not telling you anything. You're already smart.

and you understand that the file has control characters in its line mapping. so that some viewers of its contents will show it according to generally accepted rules.

Управляющие символы — Википедия
  • ru.wikipedia.org
Управля́ющие си́мволы — элементы данной кодировки, которым не приписано графическое представление, но которые используются для управления устройствами, организации передачи данных и других целей. Сейчас для этих целей применяются форматы файлов, языки управления устройствами (такие как Postscript) и сетевые протоколы. Поэтому многие...
 
lazarev-d-m:

I have more or less figured it out, the terminal does not see the csv file as a table, but as a normal file where all variables are lined up and separated by a separator

It doesn't just see csv like that, it sees everything as a file.
 

lazarev-d-m:

you have to come up with a mechanism to search for strings,

does the file have lines? how do you mark a new line? (hinting at a special symbol :)

Imagine the file is a one-dimensional array of characters.

how do you find a "new line" in the array?

 

 

FILE_LINE_END

Get end of line character

sergeev: I won't tell you anything. you're smart enough as it is. you understand that a file has control characters in its linear representation. for some viewers to display its contents according to accepted rules.
:) Let's assume that the answers to the questions "what is a new line in a file? Does a file have lines?" You got them. The answer was not expected from you.
 
Yedelkin:
:) Let's assume that the answers to the questions "What is a new line in the file? You got it. You're not supposed to get an answer.

it's all about the concepts used and the perception of those concepts.

What is a"new line" in the file? This is what I am trying to find out from lazarev-d-m. If I wait for an answer, I will correct and explain the concept correctly, if necessary. And then I will direct to the solution of the problem.

And while I do not know what lazarev-d-m imagines when he asks about a "newline". And I can not give an answer how to find it. He knows FileSeek and FileIsLineEnding and FileRead. But does not seem to know what they are for.

It is clear that in his case you can find some character only by searching. But whether he understands that the new string is just a character - I do not know.

 
sergeevвсе дело в I am trying to find out from lazarev-d-m what is a"new string" in the file. If I expect an answer, I will correct and explain the concept correctly. Meanwhile, I do not know what lazarev-d-m is thinking about when he asks about a "newline". He knows FileSeek and FileIsLineEnding and FileRead. But it seems he does not know what they are for. It is clear that in his case you can find some character only by searching.

The point isthat this forum is a forum for the MQL5 community. And MQL5 implies such a notion as "end of line sign in a file":

FILE_LINE_END.

Getting the end-of-line flags

Therefore, Mr. Lazarev's question is absolutely correct. It is absolutely correct within the MQL5 community.

 
Yedelkin:

The point isthat this forum is a forum for the MQL5 community. And MQL5 language implies such a notion as "end of line sign in a file":

Question - tell me which numbers divide by two?

The answer is all.

Moral - do not confuse the end and what you need lazarev-d-m

 
sergeev: Question - tell me, what numbers are divisible by two? The answer is all. Moral - don't confuse the end with the right lazarev-d-m
Yep. The answer to your question "Does a file have strings?" You already got it. Now you are comparing the end and what Lazarev needs. :)
 
sergeev:

Question - can you tell me which numbers are divisible by two?

The answer is all.

Moral - do not confuse the end and what you need lazarev-d-m

I understand that there are ways to identify a single line, but no separate command to access it, you need to recalculate the number of characters in line separators, to get to the right string (if you know the "number" of lines).

Or my variant to scan file line by line, which is also a hell of a lot of handy, especially with large files, where there may be hundreds of lines, and if suddenly come across this in the tester, then generally awful.

Here's how I did it, it's not working properly, I'll fix it when I'm free

MqlDateTime mqldt;
string qwerty="EURUSD";
int filehandle;

void OnStart()
  {
   filehandle=FileOpen("News.csv",FILE_READ|FILE_CSV|FILE_ANSI,';');
   uint column1=FileReadInteger(filehandle);//Code
   string column2=FileReadString(filehandle);//Symbol
   uint column3=FileReadInteger(filehandle);//Year
   uint column4=FileReadInteger(filehandle);//Month
   uint column5=FileReadInteger(filehandle);//Day
   uint column6=FileReadInteger(filehandle);//Hour
   uint column7=FileReadInteger(filehandle);//Minute
   while(column2!=qwerty&&column3!=mqldt.year&&column4!=mqldt.mon&&column5!=mqldt.day&&column6!=mqldt.hour)
     {
   column1=FileReadString(filehandle);//Code
   column2=FileReadString(filehandle);//Symbol
   column3=FileReadInteger(filehandle);//Year
   column4=FileReadInteger(filehandle);//Month
   column5=FileReadInteger(filehandle);//Day
   column6=FileReadInteger(filehandle);//Hour
   column7=FileReadInteger(filehandle);//Minute
     }
   Alert("Искомое находится в ",column1,"-й строчке");
  }
Now it always returns column1=Code, while it should return the number of the line, which matches the hour with the current time, I think it is clear from the code