Support Board
Date/Time: Wed, 25 Jun 2025 11:32:31 +0000
Post From: sc. structure passed by reference as default value to all functions
[2021-03-08 17:17:22] |
User30743 - Posts: 365 |
is there any way to pass sc structure to custom functions by &reference, and having it as a default value? here is what i mean.. For example I have a class like this namespace util{ class Logger { public: static void log(SCStudyInterfaceRef& sc, SCDateTime value, SCString comment = "") { SCString s = sc.FormatDateTime(value).GetChars(); comment += s; sc.AddMessageToLog(comment, 1); } static void log(SCStudyInterfaceRef& sc, const char* value, SCString comment = "") { comment += value; sc.AddMessageToLog(comment, 1); } static void log(SCStudyInterfaceRef& sc, int value, SCString comment = "") { SCString strVal = std::to_string(value).c_str(); comment += strVal; sc.AddMessageToLog(comment, 1); } }; The first argument is of course SCStudyInterfaceRef which I am passing via ref &. then the called needs to pass this argument sc SCSFExport scsf_LogUtilsTest(SCStudyInterfaceRef sc) { SCDateTime TradingDayStartDateTime = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.IndexOfLastVisibleBar]); util::Logger::log(sc, TradingDayStartDateTime); util::Logger::log(sc, 3.23); } But, it is tedious to pass sc all the time everywhere. I would like to make it default in all my custom functions because it is obvious it will be passed there, there is no other option anyway But I did not figure out how to make it work. Any suggestions? Date Time Of Last Edit: 2021-03-08 17:20:28
|