Files
mql5-skills/skills/mql5/references/docs/34-standardlibrary/1746-standardlibrary-datastructures-carraystring-carraystringload.md
T
2026-06-23 21:47:51 +08:00

62 lines
1.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Load
Loads data array from the file.
```
virtual bool  Load(
   int  file_handle      // file handle
   )
```
Parameters
file_handle
[in] Handle of the binary file previously opened using the FileOpen(...) function.
Return Value
true successfully completed, false - error.
Example:
```
//--- example for CArrayString::Load(int)
#include <Arrays\ArrayString.mqh>
//---
void OnStart()
  {
   int           file_handle;
   CArrayString *array=new CArrayString;
   //---
   if(array!=NULL)
     {
      printf("Object create error");
      return;
     }
   //--- open file
   file_handle=FileOpen("MyFile.bin",FILE_READ|FILE_BIN|FILE_ANSI);
   if(file_handle>=0)
     {
      if(!array.Load(file_handle))
        {
         //--- file load error
         printf("File load: Error %d!",GetLastError());
         delete array;
         FileClose(file_handle);
         //---
         return;
        }
      FileClose(file_handle);
     }
   //--- use arrays elements
   for(int i=0;i<array.Total();i++)
     {
      printf("Element[%d] %s",i,array.At(i));
     }
   delete array;
  }
```