skyzoframe[hun] 4 Posted May 31, 2021 Hi, I need examples for error handling strategies. Does anyone have any advice? (Log every success and failed procedure or function.) Share this post Link to post
skyzoframe[hun] 4 Posted June 1, 2021 (edited) Maybe create a TMemo and save here every log information. And before the program closed, save it out to file. {$IFDEF MSWINDOWS} procedure Form1.Log(uiMessage: String); var TimeStamp : TDateTime; begin TimeStamp := Now; Memo1.lines.add('--'+DateTimeToStr(TimeStamp)+sLineBreak +uiMessage); end; procedure Form1.FormDestroy(Sender: TObject); var BOM: WideChar; FS: TFileStream; WS: WideString; I: Integer; begin FS := TFileStream.Create('.\ini\Log.txt', fmCreate); try BOM := WideChar($FEFF); FS.WriteBuffer(BOM, SizeOf(BOM)); For I := 0 to Memo1.Lines.Count-1 do begin WS := WideString( Memo1.Lines[I] + sLineBreak); FS.WriteBuffer(PWideChar(WS)^, Length(WS) * SizeOf(WideChar)); end; finally FS.DisposeOf; end; end; {$ENDIF} How to do it on Android? Edited June 1, 2021 by skyzoframe[hun] Share this post Link to post
Doug Rudd 2 Posted June 25, 2021 You use the same code for Android, except you can only write the file to certain places. 1 Share this post Link to post