Support Board
Date/Time: Mon, 25 Nov 2024 05:16:00 +0000
Post From: How to read file with sc.ReadFile()?
[2022-01-20 19:12:57] |
Tony - Posts: 518 |
I see, this is what I am doing: above study function, I have: SCString ReadTextFile(SCStudyInterfaceRef sc, SCString FileLocation) { char TextBuffer[320000] = {}; // string size 320k, adjust as needed, int FileHandle = 1; // File Handle cannot be just an integer numbers, has to be defined first, sc.OpenFile requires int& unsigned int *p_BytesRead = new unsigned int(0); // sc.ReadFile() requires unsigned int pointer sc.OpenFile(FileLocation.GetChars(), n_ACSIL::FILE_MODE_OPEN_EXISTING_FOR_SEQUENTIAL_READING, FileHandle); sc.ReadFile(FileHandle, TextBuffer, 320000, p_BytesRead); sc.CloseFile(FileHandle); return TextBuffer; } inside study function, I have: SCSFExport scsf_MyStudy(SCStudyInterfaceRef sc) { // ... other codes static SCString MyInputString(""); // has to be static, otherwise the content will be cleared on very next loop MyInputString.Format(ReadTextFile(sc, "C:\\SierraChart\\Data\\MyData.txt").GetSubString(ReadTextFile(sc, "C:\\SierraChart\\Data\\MyData.txt").GetLength()-1, 0)); // to remove EOF charactor // or MyInputString.Format(ReadTextFile(sc, "C:\\SierraChart\\Data\\MyData.txt"); depend on your OS //... other codes } now you have read the data from MyData.txt to SCString variable MyInputString Date Time Of Last Edit: 2022-05-24 01:18:38
|