Login Page - Create Account

Support Board


Date/Time: Sat, 01 Mar 2025 10:13:22 +0000



Post From: sc.ReadFile doesn't work.

[2021-09-26 17:00:05]
User253985 - Posts: 23
Below is sample code I used to read a file.
It doesn't work.
Can't see what I'm doing wrong.




if (sc.Index == sc.ArraySize - 1)
    {
      
      int FileHandle;
      sc.OpenFile("D:/SierraChart/Data/Lines_EURUSD.csv", n_ACSIL::FILE_MODE_OPEN_EXISTING_FOR_SEQUENTIAL_READING, FileHandle);
      if (sc.OpenFile("D:/SierraChart/Data/Lines_EURUSD.csv", n_ACSIL::FILE_MODE_OPEN_EXISTING_FOR_SEQUENTIAL_READING, FileHandle))
      {
        sc.AddMessageToLog("File Opened", 1);
      }
      char* Buffer;
      unsigned int BytesRead = 0;
      
      sc.ReadFile(FileHandle, Buffer, 250, &BytesRead);
      

      sc.AddMessageToLog(Buffer, 1);
      sc.AddMessageToLog("BytesRead", 1);
      std::string bytes = std::to_string(BytesRead);
      SCString Bytes = bytes.c_str();
      sc.AddMessageToLog(Bytes, 1);


      sc.CloseFile(FileHandle);
    }


MESSAGE LOG
Chart: EURUSD[M] 60 Min #2 | Study: Get Plot Profiles | File Opened | 2021-09-26 17:50:37.936 *
Chart: EURUSD[M] 60 Min #2 | Study: Get Plot Profiles | | 2021-09-26 17:50:37.936 *
Chart: EURUSD[M] 60 Min #2 | Study: Get Plot Profiles | BytesRead | 2021-09-26 17:50:37.936 *
Chart: EURUSD[M] 60 Min #2 | Study: Get Plot Profiles | 0 | 2021-09-26 17:50:37.936 *


I would prefer to use a C++ while loop but that causes a CPU exception.