Working with files. - page 6

 
Yedelkin:

Haven't worked with file operations in a long time... Look, when you use FileOpen() you have a CSV type file declared. It used to specify that all written items are converted to unicode or ansi strings. Maybe this is where the dog is?

Fucking Winnipuh!!!

That's where it's "buried" :) I added the FILE_ANSI parameter and everything went smoothly!

FileOpen("Price Label\\\"+_Symbol+tpl_ext,FILE_READ|FILE_CSV|FILE_ANSI,';',CP_ACP);


Yedelkin ,TheXpert thanks for the tip!!!:)

 

is_vale: 

...

From what I can see in debugger (in sTF variable it reads file contents as unicode! When opening the file I've tried all the possible codepages, but the result is the same :( The file itself is written in Windows encoding.

Does anyone have any idea where the problem lies?

By default it's written in UNICODE. So setFILE_ANSI flag:

int handle=FileOpen("Price Label\\"+_Symbol+tpl_ext,FILE_READ|FILE_CSV|FILE_ANSI,';',CP_ACP);

 
tol64:

By default it is written in UNICODE. Therefore set theFILE_ANSI flag:

Promptly prompted. )))
 
uint  FileReadArray(
   int   file_handle,               // handle файла
   void  array[],                   // массив для записи
   int   start_item=0,              // с какой позиции массива писать
   int   items_count=WHOLE_ARRAY    // сколько читать
   );
Question about array[] size: should I set the size of array[] before using it inFileReadArray() or will the "terminal runtime" take care of its size in this case?
 
Yedelkin:
Question about array[] size: should I set the size of array[] before using it inFileReadArray() or will the "terminal executing system" take care of it?

No, the function will distribute memory for the necessary amount of data in the file.

By the way, you can read arrays of simple structures in the same way, if they were written there.

The FileReadArray() function does not recognize the type of saved data, so be careful, this is one of the features, you can save duplicates and read them as a collocation and parse them into bits.

 

Cool.

Urain:

The FileReadArray() function doesn't recognise the type of saved data, so be careful, this is one of the features, you can save duplicates and read them as a floating point and parse them into bits.

So, arrays should be of the same type when saving and reading, right? Is it enough?

 
Yedelkin:

Cool.

So the arrays must be of the same type when saving and reading, am I right? Is that enough?

Yes.
 
Urain:
Yes.
Gracias muchas!
 
bool  FileCopy(
    string  src_filename,       // имя файла-источника
    int     common_flag,        // место действия
    string  dst_filename,       // имя файла назначения
    int     mode_flags          // способ доступа
    );

The description says:

common_flag

[in] Flag defining the location of the file. If common_flag=FILE_COMMON, the file is in the shared folder of all client terminals. Otherwise the file is in the local folder.

If the source file is in the shared folder, then common_flag=FILE_COMMON, this is understandable. But if the file is located in a local folder, which flag should be specified? The common_flag parameter is not default, which means that some value must be specified anyway.
 
Yedelkin:

The description says:

If the source file is in a shared folder, then common_flag=FILE_COMMON, that's clear. But if the file is located in a local folder, which flag should be specified? The common_flag parameter is not default, so some value must be specified anyway.
If FILE_COMMON is not specified, the default is in the local folder.
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы ввода/вывода / Флаги открытия файлов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы ввода/вывода / Флаги открытия файлов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы ввода/вывода / Флаги открытия файлов - Документация по MQL5