Login Page - Create Account

Support Board


Date/Time: Tue, 07 Jan 2025 20:21:05 +0000



Post From: problem : I do not know how do you retrieve the line in a text file.

[2016-06-17 14:27:46]
User210074 - Posts: 63
I test that

But it doesn't work


#include <iostream>
#include <string>
#include <fstream>
#include "sierrachart.h"
#include <stdio.h>
#include <time.h>

using namespace std;
SCDLLName("Test");
SCSFExport scsf_DTNS(SCStudyGraphRef sc) {

if(sc.SetDefaults){
sc.GraphName="Test";
sc.StudyDescription="Test";
sc.FreeDLL = 1;
sc.GraphRegion = 0;
}
ifstream Files("Z:\\SC_Graphique_rithmic\\Data\\Val.txt", ios::in);
if(Files){
//sc.AddMessageToLog("File Open.", 1);
string Lines;
while ( getline(Files, Lines) ) {
              std::stringstream Val(Lines);
              int Data, Value;
              std::string Data;
       if ( std::getline(Val, Data, ',') ) { Value = Data; }
       else { Value = ""; }
}
Files.close();
return;
}//Right
else{
sc.AddMessageToLog("File Not Open.", 1);
return;
}//Wrong

}


Error

-- Starting build of Custom Studies Source files: DTS.cpp. -- 16:18:58

"Z:\SierraChart\CPPCompiler\bin\g++.exe" "Z:\SC_Graphique_rithmic\ACS_Source\DTS.cpp" -march=i686 -mtune=i686 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-exceptions -std=gnu++11 -o "Z:\SC_Graphique_rithmic\Data\DTS.dll"

Z:\SC_Graphique_rithmic\ACS_Source\DTS.cpp: In function 'void scsf_DTNS(SCStudyInterfaceRef)':
Z:\SC_Graphique_rithmic\ACS_Source\DTS.cpp:23:34: error: variable 'std::stringstream ss' has initializer but incomplete type
std::stringstream ss(Lines);
^
Z:\SC_Graphique_rithmic\ACS_Source\DTS.cpp:25:20: error: conflicting declaration 'std::string Data'
std::string Data;
^
Z:\SC_Graphique_rithmic\ACS_Source\DTS.cpp:24:12: note: previous declaration as 'int Data'
int Data, Valeur;
^
Z:\SC_Graphique_rithmic\ACS_Source\DTS.cpp:27:34: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
else { Valeur = ""; }
^
-- End of Build -- 16:19:00