Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 15:18:18 +0000



Post From: Study write to file problem with SC 996

[2013-07-13 21:00:12]
ChrisH - Posts: 10
I've written studies that send results to a text file.

These studies work fine with SC 912 using Whatcom compiler. With SC 996 using MinGW/G++ they no longer work. A basic sample with comments is below:


#include "sierrachart.h"
#include <iostream> //Appears to have been already included with MinGW & generates errors
#include <fstream> //Appears to have been already included with MinGW & generates errors

using namespace std;

SCDLLName("KAI TEST")

SCSFExport scsf_KAI_TEST(SCStudyGraphRef sc) {
  SCString Buffer;
  ofstream DataFile; //If I remove the iostream/fstream includes, this fails as not defined
  
  if (sc.SetDefaults) {
    sc.GraphName = "KAI Test Study";
    sc.StudyDescription = "KAI Test Study";
    sc.GraphRegion = 0;
    sc.AutoLoop = 1;
    sc.FreeDLL = 0;

    return;
  }

  DataFile.open ("C:\\KAI_TEST.TXT", ios::out | ios::app);
  Buffer.Format("%s,%f\n",sc.Symbol.GetChars(), sc.Close[sc.Index]);
  DataFile << Buffer.GetChars();
  DataFile.close();
  }
}