2 Star 0 Fork 1

Tomato/ZhiDev_D7_JingYou

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
UnitDM.pas 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
Tomato 提交于 2024-02-01 17:16 . Initial commit
unit UnitDM;
interface
uses
SysUtils, Classes,SyncObjs;
type
TDMLJK = class(TDataModule)
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
private
{ Private declarations }
public
FCsWriteLogFile:TCriticalSection;
exepath:string;
procedure MyAddlog(s:string);
procedure strToList(src: string; var ts: TStringList);
{ Public declarations }
end;
var
DMLJK: TDMLJK;
implementation
{$R *.dfm}
procedure TDMLJK.strToList(src: string; var ts: TStringList);
var
dec: string;
i: integer;
str: string;
begin
dec := ']';
if src = '' then
begin
ts.Add('');
exit;
end;
repeat
i := pos(dec, src);
str := copy(src, 1, i - 1);
if (str = '') and (i > 0) then
begin
delete(src, 1, length(dec));
continue;
end;
if i > 0 then
begin
ts.Add(str);
delete(src, 1, i + length(dec) - 1);
end;
until i <= 0;
if src <> '' then
ts.Add(src);
end;
procedure TDMLJK.MyAddlog(s:string);
var
tFile: TextFile;
filename: string;
b:Boolean;
begin
// if FormatDateTime('yyyyMMdd',now)>'20231230' then
// Abort;
filename:=exepath+'log';
b:=False;
if not(DirectoryExists(filename)) then
begin
try
ForceDirectories(filename);
b:=True;
except
end;
end
else
begin
b:=True;
end;
if b=False then exit;
filename:=filename+'\'+formatdatetime('yyyyMMdd',Now)+'.txt';
FCsWriteLogFile.Enter();
AssignFile(tFile,filename);
try
if FileExists(filename) then
Append(tFile)
else
Rewrite(tFile);
Writeln(tFile,'<'+FormatDateTime('hh:nn:ss', Now)+'>'+s);
except
end;
CloseFile(tFile);
FCsWriteLogFile.Leave;
end;
procedure TDMLJK.DataModuleCreate(Sender: TObject);
begin
exepath:=ExtractFilePath(ParamStr(0));
FCsWriteLogFile:=TCriticalSection.Create;
end;
procedure TDMLJK.DataModuleDestroy(Sender: TObject);
begin
FCsWriteLogFile.free;
end;
end.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Pascal
1
https://gitee.com/wx_fb0d806ee4/ZhiDev_D7_JingYou.git
git@gitee.com:wx_fb0d806ee4/ZhiDev_D7_JingYou.git
wx_fb0d806ee4
ZhiDev_D7_JingYou
ZhiDev_D7_JingYou
master

搜索帮助