Login Page - Create Account

Support Board


Date/Time: Wed, 22 Sep 2021 04:48:35 +0000



[User Discussion] - problem with sc.AddMessageToLog

[2016-12-09 01:29:10]
User210074 - Posts: 63

#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <ctime>
#include "sierrachart.h"
using namespace std;
SCDLLName("CalendarEc")
SCSFExport scsf_CalendarEc(SCStudyInterfaceRef sc) {
SCInputRef Date = sc.Input[0];
  if(sc.SetDefaults) {
    sc.GraphName="CalendarEc";
    sc.StudyDescription="Economic Calendar";
    sc.AutoLoop = 1;
    sc.FreeDLL = 1;
    SCString File;
    File.Format("C:\\SierraChart\\Data\\CalendarEc.txt",sc.Symbol.GetSubString(4,0).GetChars());
    Date.SetString(File);
    return;
   }//END default
ifstream File(Date.GetString());
if(File){
string DateEc;
while(getline(File,DateEc)){
sc.AddMessageToLog(DateEc,1);
     //cout << DateEc << endl;
}
}
else{}
}// End Function
Error

-- Starting build of Custom Studies Source files: CalendarEc.cpp. -- 02:20:42

C:\WINDOWS\system32\cmd.exe /C "C:\Dev_SierraChart\ACS_Source\VisualCCompile.Bat"


C:\Dev_SierraChart\ACS_Source>call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
CalendarEc.cpp
C:\Dev_SierraChart\ACS_Source\CalendarEc.cpp(26): error C2664: 'void s_sc::AddMessageToLog(const SCString &,int)': cannot convert argument 1 from 'std::string' to 'const char *'
C:\Dev_SierraChart\ACS_Source\CalendarEc.cpp(26): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
-- End of Build -- 02:20:45
I do not know how to fix the problem with the sc.AddMessageToLog function to display the date in MessageLog
[2016-12-09 01:42:14]
Sierra Chart Engineering - Posts: 97826
You need to do it like this:
sc.AddMessageToLog(DateEc.c_str(),1);

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.

To post a message in this thread, you need to login with your Sierra Chart account:

Login

Login Page - Create Account