FileWriteComplexDouble

파일 포인터의 현재 위치에서 complex 파라미터 값을 바이너리 또는 CSV 파일에 씁니다.

uint  FileWriteComplexDouble(
   int      file_handle,      // 파일 핸들
   complex  value             // 쓸 값
   );

매개변수

file_handle

[in] FileOpen()에서 반환된 파일 설명자.

value

[in]  complex 타입의 값.

반환 값

성공한 경우 함수는 기록된 바이트 수를 반환합니다. 파일 포인터는 같은 바이트 수만큼 이동합니다.

참고

오류 정보를 얻으려면 GetLastError()를 호출해야 합니다.

바이너리 파일에는 16바이트가 기록됩니다.

텍스트 또는 CSV 파일에는 복소수의 텍스트 표현이 기록됩니다.

예:

//+------------------------------------------------------------------+
//|                                         TestWriteReadComplex.mq5 |
//|                                  Copyright 2026, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| 스크립트 프로그램 시작 함수                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   complex  complex_value=1.012345+0.0001i;
   complexf complexf_value=complexf(0.00678+0.005i);
//--- CSV 파일에 쓰기
   int  file_handle=FileOpen("complex.csv",FILE_CSV|FILE_WRITE|FILE_ANSI);
   uint written=FileWriteComplexDouble(file_handle,complex_value);
   Print("written ",written," bytes");
   FileWriteString(file_handle,"\t");
   written=FileWriteComplexFloat(file_handle,complexf_value);
   Print("written ",written," bytes");
   FileWriteString(file_handle,"\n");
   FileClose(file_handle);
   complex  complex_value2;
   complexf complexf_value2;
//--- CSV 파일에서 읽기
   file_handle=FileOpen("complex.csv",FILE_CSV|FILE_READ|FILE_ANSI);
   complex_value2=FileReadComplexDouble(file_handle);
   complexf_value2=FileReadComplexFloat(file_handle);
   FileClose(file_handle);
   Print("complex_value2=",complex_value2);
   Print("complexf_value2=",complexf_value2);
//--- 바이너리 파일에 쓰기
   file_handle=FileOpen("complex.bin",FILE_BIN|FILE_WRITE);
   written=FileWriteComplexDouble(file_handle,complex_value);
   Print("\nwritten ",written," bytes");
   written=FileWriteComplexFloat(file_handle,complexf_value);
   Print("written ",written," bytes");
   FileClose(file_handle);
   complex  complex_value3;
   complexf complexf_value3;
//--- 바이너리 파일에서 읽기
   file_handle=FileOpen("complex.bin",FILE_BIN|FILE_READ);
   complex_value3=FileReadComplexDouble(file_handle);
   complexf_value3=FileReadComplexFloat(file_handle);
   FileClose(file_handle);
   Print("complex_value3=",complex_value3);
   Print("complexf_value3=",complexf_value3);
  }

Experts 저널의 출력

   written 17 bytes
   written 27 bytes
   complex_value2=(1.012345,0.0001)
   complexf_value2=(0.0067799999,0.0049999999)
   
   written 16 bytes
   written 8 bytes
   complex_value3=(1.012345,0.0001)
   complexf_value3=(0.0067799999,0.0049999999)

 

더 보기

복소수 (complex, complexf), 실수 타입 (double, float), FileWriteDouble, FileWriteComplexFloat