{write log function}
inputs:
FolderPath(StringSimple),
Messagetext(StringSimple);
vars : Now(0),
MsgText(""),
Millisecond(""),
TimeText(""),
DateText(""),
FileName("");
{Format Date and Time}
Now = computerdatetime;
Millisecond = NumToStr(MillisecondsFromDateTime(Now), 0);
if StrLen(Millisecond) = 1 then Millisecond = "00" + Millisecond
else if StrLen(Millisecond) = 2 then Millisecond = "0" + Millisecond;
{Log format}
DateText = FormatDate("yyyy-MM-dd", Now);
TimeText = FormatTime("HH:mm:ss", Now) + "." + Millisecond;
MsgText = DateText + " " + TimeText + " " + Messagetext + NewLine;
{File name}
DateText = FormatDate("yyyyMMdd", Now);
FileName = FolderPath + "_" + DateText + "_log.txt";
FileAppend(FileName, MsgText);
第27行:檔名,讀者可自行修改我是Amin,喜好整合軟體之間的應用至數據分析,如Excel VBA、Python、C/C++、C#、JavaScript、Google Apps Script、Batch、MultiCharts的相互應用,歡迎各領域同好相互討論,創造人生精采的火花
2017年3月6日 星期一
MultiCharts 寫Log 函數
開發 MultiCharts 策略,Debug是一個必經的過程,但如果想在PLE中輸出檔案或記錄某些內容,就需要再PLE中寫記錄Log的函數,筆者這裡分享一下有在使用的Log函數。