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. Oracle_PLSQL创建用户表空间

  2. EAccessViolation

    Access Violation(非法访问),General Protection Fault(一般保护性错误)或者Invalid Page Fault(无效页面错误),虽然说法不一样,但本质上总是由 ...

  3. bad ELF interpreter: No such file or directory

    1.在64系统里执行32位程序如果出现/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory,安装下glic即可 yum ...

  4. vs开启,Windows 10磁盘占用100%解决办法

    https://www.cnblogs.com/time-is-life/p/8888441.html 最后把Home Group相关的服务都改成禁用. 注意: 即使这两个服务没有启动也不行, 一定要 ...

  5. jeecg数据库切换至mysql8.0方式

    1.修改pom.xml   mysql版本 <mysql.version>8.0.11</mysql.version> 2.修改dbconfig.properties文件 hi ...

  6. Loadrunner11压测过程问题总结

    1.-27727: 下载资源时步骤下载超时 (120 seconds) 已过期 由于压力大了,下载资源所用时间就长了,可以设置加大超时时间: 运行时设置--Internet 协议--首选项--高级-- ...

  7. odoo开发笔记 -- 还原数据库后,异常:ir_attachment: IOError: [Errno 2] No such file or directory: u'/var/...'

    场景描述: 恢复Odoo数据后,抛出错误导致无法进入页面 -- ::, INFO aeo odoo.addons.base.ir.ir_attachment: _read_file reading / ...

  8. Python3基础 from...import...as 解决局部导入时的函数名重复问题

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  9. vue重置表单数据

    Object.assign(this.$data, this.$options.data()) // 全部重置 Object.assign(this.$data.form, this.$options ...

  10. Playbooks简介

    Playbooks简介 关于Playbooks Playbook简单示例 基本组成 主机和用户 任务列表 Handlers: 配置更改时运行操作 执行Playbook Ansible-Pull Lin ...