procedure TForm1.SaveLog(sFlag:string;MSG:string);
var
QF1:Textfile;         ----声明文本文件类型
Qfiletmp,sPath:string;
begin
try
sPath :=ExtractFileDir(ParamStr(0))+'\Sajet_Log\';
if not directoryExists(sPath) then
begin
forcedirectories(sPath);
end;
Qfiletmp:=sPath+formatdatetime('yyyy_mm_dd',now)+'.LOG';

if not FileExists(Qfiletmp) then
begin
assignfile(QF1,Qfiletmp);     ----将Qfiletmp文件与变量QF1建立连接,后面可以使用F变量对文件进行操作。
rewrite(QF1);                       ----//Rewrite 过程能创建一个新文件并打开它;使用Reset 打开的文本文件是只读的,使用Rewrite 和Append 打开的文本文件只能写入
closeFile(QF1);                   ----关闭文件
end;
AssignFile(QF1,Qfiletmp);
append(QF1);
if sFlag ='NG' then
writeln(QF1,formatdatetime('yyyy-mm-dd hh:mm:ss',now)+'[ Error ]'+MSG)
else
writeln(QF1,formatdatetime('yyyy-mm-dd hh:mm:ss',now)+'[ ]'+MSG);
closeFile(QF1);
except
end;
end;

Delphi中AssignFile函数的更多相关文章

  1. Delphi中的函数指针判断是否为空

    delphi函数指针 只有@@p才代表了函数指针本身的地址   assigned(p) 判断是否为空 或者用 @p=nil 来判断函数指针是不是为空 Delphi中的函数指针实际上就是指针,只是在使用 ...

  2. Delphi中 StrToIntDef函数的用法

    Delphi中 StrToIntDef函数的用法:比如我要判断一个文本框里输入的字符串能不能转换为integer类型,如果能,则返回转换后的整型数据,如果不能,则返回整数0,那么我就可以用strtoi ...

  3. delphi中move函数的正确理解(const和var一样,都是传地址,所以Move是传地址,而恰恰不是传值)太精彩了 good

    我们能看到以下代码var pSource,pDest:PChar;     len: integer;.......................//一些代码Move(pSource,pDest,l ...

  4. delphi 中OutputDebugString 函数的妙用(使用DebugView或者Pascal Analyzer软件,在运行过程中就能监视和捕捉日志,而且通过网络就能监视)

    原文地址 https://www.peganza.com/delphi-and-outputdebugstring.html 曾经想要实时监控您的Delphi应用程序,并能够查看日志消息吗?当然,您始 ...

  5. Delphi中文件名函数-路径、名称、子目录、驱动器、扩展名

    文件名函数 文件名函数可以对文件的名称.所在子目录.驱动器和扩展名等进行操作.下表列出这些函数及其功能. 函数说明 ExpandFileName() //返回文件的全路径(含驱动器.路径) Extra ...

  6. Delphi中BitBlt函数实现屏幕对象抓图

    uses WinTypes, WinProcs, Forms, Controls, Classes, Graphics; function CaptureScreenRect( ARect: TRec ...

  7. delphi 中OutputDebugString 函数的妙用(转载)

    原文地址 https://www.peganza.com/delphi-and-outputdebugstring.html Ever wanted to monitor your Delphi ap ...

  8. Delphi中StrToDateTime函数TFormatSettings参数的使用

    var    FSetting : TFormatSettings;    DateTime1: tDateTime;  begin    FSetting := TFormatSettings.Cr ...

  9. delphi 中的函数指针 回调函数(传递函数指针,以及它需要的函数参数)

    以下代码仅仅是测试代码:delphi XE7 UP1 interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.V ...

随机推荐

  1. java并发编程(八) CAS & Unsafe & atomic

    参考文档:https://www.cnblogs.com/xrq730/p/4976007.html CAS(Compare and Swap) 一个CAS方法包含三个参数CAS(V,E,N).V表示 ...

  2. Phoenix概述

    Phoenix是Salesforce.com开源的一个项目,可以让开发者在Apache HBase上执行SQL查询. Phoenix查询引擎会将SQL查询转换为一个或多个HBase scan,并编排执 ...

  3. Java-JUC(十五):synchronized执行流程分析

    一.锁对象及 synchronized 的使用 synchronized 通过互斥锁(Mutex Lock)来实现,同一时刻,只有获得锁的线程才可以执行锁内的代码. 锁对象分为两种: 实例对象(一个类 ...

  4. CMake版本低,需要更高版本.

    https://blog.csdn.net/qq_34935373/article/details/90266958 使用cmake命令安装Opencv软件时,报如下错误: CMake Error a ...

  5. PhantomJS笔记,Node.js集成PhantomJS

    PhantomJS笔记,Node.js集成PhantomJS 转 https://www.linchaoqun.com/html/cms/content.jsp?menu=index&id=1 ...

  6. jquery 回车键 调用tab 事件

    $(function(){ $("input").keydown(function(){ == event.keyCode){ var form = $("body&qu ...

  7. 【错误解决】git报错:you are not allowed to push code to protected branches on this project

    场景回忆: 本地修改需要退回到之前的版本,打算强制push本地版本覆盖远程版本,但是在git push --force后出现了以下的错误: Fix GitLab error: "you ar ...

  8. 使用BaGet 搭建私有nuget 服务器

    使用BaGet 搭建私有nuget 服务器 netNugetBaGet 引言 为了增强代码的安全性和企业团队开发的高效性,搭建私有的package 包管理服务器是很有必要的,搭建私有的类库管理服务有以 ...

  9. Java之输入和输出

    输出 在前面的代码中,我们总是用System.out.println()来向屏幕输出一些内容: println是print line的缩写,表示输出并换行.因此,如果输出后不想换行,可以用print( ...

  10. c# .net 4.5.2 asp.net mvc 使用hangfire

    一定要有hangfire数据库,否则hangfire会报错. (obStorage.Current property value has not been initialized. You must ...