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. v-model和 .sync

    1.v-model的双向数据绑定其实是一个语法糖,类似于,给子组件传入一个value值,并且监听子组件的input事件,在这个事件里将子组件传过来的新值赋值给父组件的value <Input v ...

  2. yum安装python3.6的方法

    # centos7 # 换成阿里云的yum源 yum -y install epel-release yum repolist yum -y install python36 测试 [root@loc ...

  3. kotlin基础 字符串模板

    ${变量名} var tmp="字符串模板” print("今天学习${tmp}这个知识点")

  4. Android Studio + opencv开发配置

    1 下载Android Studio https://developer.android.com/studio/archive?hl=zh-cn 2 安装Android Studio 安装完成,下载S ...

  5. 《Effective Java》第2章 对所有对象都通用的方法

    第10条:覆盖equals时,请遵守通用约定 1.使用==来比较两个对象的时候,比较的是两个对象在内存中的地址是否相同(两个引用指向的是否为同一个对象):Object中定义的equals方法也是这样比 ...

  6. a simple machine learning system demo, for ML study.

    Machine Learning System introduction This project is a full stack Django/React/Redux app that uses t ...

  7. python - logging.basicConfig format参数无效

    有这么一段python代码 import threading import time import requests from decimal import Decimal, ROUND_DOWN i ...

  8. Airflow使用指南

    1.只执行单个任务 将downstream和recursive按钮的点击状态取消,然后点击clear,最后点击run

  9. Nginx学习之入门

    1. 概念   (1) 什么是nginx?    Nginx (engine x) 是一款轻量级的Web 服务器 .反向代理服务器及电子邮件(IMAP/POP3)代理服务器.   (2) 什么是反向代 ...

  10. 【翻译】FlinkCEP-Flink的复杂事件处理

    本文翻译自官网:FlinkCEP - Complex event processing for Flink FlinkCEP是在Flink之上实现的复杂事件处理(CEP)库. 它使您可以检测无穷无尽的 ...