Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1118

 
Top2n:
  FileReadArray(file_handle,arr);

Please advise on possible developments.

I have array[100], also saved binary file with size [1000], how to return array of binary file last 100 values. Is there anything universal? I've been working on this for 12 hours and nothing.

If I remember correctly, it was written in mql4, that if count = WHOLE_ARRAY or value exceeds the number of array elements, then the entire array is written to the end. And it didn't say anything about any margin. I.e. it's out of the question not to mention 1,000.

To check it, count how many values are written and the size of the file.

 
Alexey Viktorov:

If I remember correctly, it was written in mql4, that if count = WHOLE_ARRAY or value exceeds the number of array elements, the whole array is written to the end. And it didn't say anything about any margin. So it may be absolutely out of question if there is not a 1000-thousand-point margin.

To check this, calculate how many values are written and the resulting file size.

I do not mean that after writing the array to the binary, new data appear, and I keep writing them to the binary via a new dimensioned array (= the dimension of the primary array column), each time to the end of the file, for a new j column

then we need to remove the data from the binary equal in number to the index of the original array, which was transferred to the binary in the first integration. However, the last data will be included in this limited array, because the binary is larger than the primary array, as secondary rows have been added. Secondary rows must go into read array, and first rows in binary must be out of area.

 
Top2n:

I do not mean that after writing the array to the binary, new data appears after a moment of time, which I continue to write to the binary via a new dimensioned array (= dimension of the primary array column), each time at the end of the file, for a new j-column

then we need to remove the data from the binary equal in number to the index of the original array, which was transferred to the binary in the first integration. However, the last data should be removed in such a way that the last data are included in this limited array, because the binary is larger than the primary array due to the addition of secondary rows.

Then it is not necessary to assign a dimension to the array before reading. If it is not the first data that is needed, then it is necessary to calculate the size in bytes and shift the start position for reading by the right amount.
 
Alexey Viktorov:
Then you don't need to assign a size to the array before reading. If it is not the first data that is needed, then calculate the size in bytes and shift the start position for reading by the right amount.

That is the question how to calculate bytes

FileWriteInteger(h,s1,INT_VALUE); //ножно ли перед записью записывать размера массива?
s1=FileReadInteger(h,INT_VALUE); //ножно ли перед восстановлением считываем размер массива?

может как то через это sizeof
 
Top2n:

This is the question how to calculate bytes

FileWriteInteger(h,s1,INT_VALUE); //ножно ли перед записью записывать размера массива?
s1=FileReadInteger(h,INT_VALUE); //ножно ли перед восстановлением считываем размер массива?

может как то через это sizeof

If data is of double type then divide file size by the number of bytes occupied by the number of double type, i.e. by 8.

Документация по MQL5: Файловые операции / FileSize
Документация по MQL5: Файловые операции / FileSize
  • www.mql5.com
Файловые операции / FileSize - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:

If the data is double, then divide the file size by the number of bytes occupied by the double number, i.e. by 8.

Is it byFileFindFirst?

or just scan each new line in bytes

Короче при записи начал суммировать вторичный массив в байтах, каждая запись плюсуется с предыдущей
file_size=+FileSize(handle); // чтобы выяснить индекс от которого открывать

FileReadArray(file_handle,arr,file_size,WHOLE_ARRAY);
wrong
 
Top2n:
WithFileFindFirst?
You have the name of the file and its handle.
 
Top2n:

ThroughFileFindFirst?

Or just bysummarize each new line in bytes

Короче при записи начал суммировать вторичный массив в байтах, каждая запись плюсуется с предыдущей
file_size=+FileSize(handle); // чтобы выяснить индекс от которого открывать

FileReadArray(file_handle,arr,file_size,WHOLE_ARRAY);
it's not right.

You should not have corrected your post after answering it...

Wrong. Before reading an array, define its size file_size = FileSize(handle); and divide by memory occupied by data type, i.e. for double by 8. You get the number of numbers in the file. If array is two-dimensional, then the number of records in the file will be twice less. And you get how many bytes should be shifted to read from the desired line.

 
Alexey Viktorov:

You should have corrected your post after replying to it...

Wrong. Before reading an array, define its size file_size = FileSize(handle); and divide by memory occupied by data type, i.e. for double by 8. You get the number of numbers in the file. If array is two-dimensional, then the number of records in the file will be twice less. And you get how many bytes should be shifted to read from the desired line.

I ended up dividing by 8000 so that the array values would fit into their indexes.
 
Top2n:
as a result, I divided by 8000, so that the array values fit into their indexes

You tell me...

FileSize

Returns file size in bytes.

Type

Size in bytes

Positive minimum value

Maximum value

Analog in C++

float

4

1.175494351e-38

3.402823466e+38

float

double

8

2.2250738585072014e-308

1.7976931348623158e+308

double


file size in bytes, the size occupied by type double in bytes, and it is necessary to divide it by zhzhezhezhezhezhezhezhez



Reason: