Login Page - Create Account

Support Board


Date/Time: Mon, 13 Jan 2025 17:09:57 +0000



[Programming Help] - Does anyone know how to format the file pathway for exporting to csv file

View Count: 60

[2025-01-10 23:42:15]
User373245 - Posts: 47
I can not get anything method to work. I am using paralles in Mac and have tried a bunch of methods does the file pathway have to be written in a particular manor. I have tried putting it in the data folder/the desktop/ I have given everything permission in all spots as well as used different methods to establish the pathway. As well as writing it a bunch of ways. With the drive letter \\ vs \ I have tried everything and can not get it to work?? As well as different logic in the if statement to trigger it?




#include "sierrachart.h"

// Define the name of the DLL
SCDLLName("Version Export");

SCSFExport scsf_VersionExport(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
// Name of the study as it appears in Sierra Chart
sc.GraphName = "Version Export";
sc.StudyDescription = "Exports OHLC data from the chart to a file on the desktop.";
sc.AutoLoop = 0;
sc.Input[1].SetPathAndFileName("SierraChart\Data\Test.csv");

return;
}

SCString FilePath = sc.Input[1].GetPathAndFileName(); // Get the file path

if (sc.Index == sc.ArraySize - 1) // Check if it's the last bar
{
int FileHandle; // Declare FileHandle for file operations
// Open the file at the specified path in append mode
sc.OpenFile(FilePath, n_ACSIL::FILE_MODE_OPEN_TO_APPEND, FileHandle);

unsigned int BytesWritten = 0;

// Write data to the file
sc.WriteFile(FileHandle, "Test Line\r\n", 11, &BytesWritten);

// Close the file after writing
sc.CloseFile(FileHandle);
}
}

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

Login

Login Page - Create Account