Hello All,
i have one requirement where i have to create a new file for logging errors and i have written the code like below:
In the below code it is writing only one line in text file.
Example i have 4 line that needs to be written in ErrorLog file but it is writing only last line.
One more case is that if that errorlog text already exists then it should read that file and at last line it should start inserting the records.
I am not getting how to find the last line of the text file and copy these records
Please suggest.
ErrorFileName:='D:\Custom Clearance\ErrorLog.txt';
//ErrorFileName := 'ErrorLog.txt';
datDateTime:=CURRENTDATETIME;
IF recItem.GET(Item1) THEN BEGIN
IF NOT CustClrInfo.GET(ActivityType,DateofClr,Itemno,variant1) THEN BEGIN
CustClrInfo.INIT;
CustClrInfo."Activity Type" := ActivityType;
CustClrInfo."Date of Customs Clearance":=DateofClr;
CustClrInfo."Item No.":=Item1;
CustClrInfo."Variant Code":=variant1;
CustClrInfo.Quantity:=Qty;
CustClrInfo.INSERT(TRUE);
END;
END ELSE BEGIN
{IF EXISTS(ErrorFileName) THEN BEGIN
ErrorFile.TEXTMODE(TRUE);
ErrorFile.WRITEMODE(FALSE);
ErrorFile.OPEN(ErrorFileName);
REPEAT
ErrorFile.READ(ErrorFileName);
UNTIL ErrorFile.POS=ErrorFile.LEN; //not getting how to find the last line and then insert these errors
FileOutStream.WRITETEXT(Dummy);
FileOutStream.WRITETEXT();
ErrorFile.CLOSE;
//FileOutStream.WRITETEXT(FORMAT(datDateTime));
MESSAGE('1');
END ELSE BEGIN
ErrorFile.CREATE(ErrorFileName);
ErrorFile.CREATEOUTSTREAM(FileOutStream);
FileOutStream.WRITETEXT(Dummy);
FileOutStream.WRITETEXT();
ErrorFile.CLOSE;
//FileOutStream.WRITETEXT(FORMAT(datDateTime));
MESSAGE('Hi');
END;
}END;
*This post is locked for comments