Delphi中AssignFile函数
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函数的更多相关文章
- Delphi中的函数指针判断是否为空
delphi函数指针 只有@@p才代表了函数指针本身的地址 assigned(p) 判断是否为空 或者用 @p=nil 来判断函数指针是不是为空 Delphi中的函数指针实际上就是指针,只是在使用 ...
- Delphi中 StrToIntDef函数的用法
Delphi中 StrToIntDef函数的用法:比如我要判断一个文本框里输入的字符串能不能转换为integer类型,如果能,则返回转换后的整型数据,如果不能,则返回整数0,那么我就可以用strtoi ...
- delphi中move函数的正确理解(const和var一样,都是传地址,所以Move是传地址,而恰恰不是传值)太精彩了 good
我们能看到以下代码var pSource,pDest:PChar; len: integer;.......................//一些代码Move(pSource,pDest,l ...
- delphi 中OutputDebugString 函数的妙用(使用DebugView或者Pascal Analyzer软件,在运行过程中就能监视和捕捉日志,而且通过网络就能监视)
原文地址 https://www.peganza.com/delphi-and-outputdebugstring.html 曾经想要实时监控您的Delphi应用程序,并能够查看日志消息吗?当然,您始 ...
- Delphi中文件名函数-路径、名称、子目录、驱动器、扩展名
文件名函数 文件名函数可以对文件的名称.所在子目录.驱动器和扩展名等进行操作.下表列出这些函数及其功能. 函数说明 ExpandFileName() //返回文件的全路径(含驱动器.路径) Extra ...
- Delphi中BitBlt函数实现屏幕对象抓图
uses WinTypes, WinProcs, Forms, Controls, Classes, Graphics; function CaptureScreenRect( ARect: TRec ...
- delphi 中OutputDebugString 函数的妙用(转载)
原文地址 https://www.peganza.com/delphi-and-outputdebugstring.html Ever wanted to monitor your Delphi ap ...
- Delphi中StrToDateTime函数TFormatSettings参数的使用
var FSetting : TFormatSettings; DateTime1: tDateTime; begin FSetting := TFormatSettings.Cr ...
- delphi 中的函数指针 回调函数(传递函数指针,以及它需要的函数参数)
以下代码仅仅是测试代码:delphi XE7 UP1 interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.V ...
随机推荐
- [Beta阶段]发布说明
小小易校园微信小程序发布说明 第二版小小易校园小程序发布啦~ 打开微信,点击右上角➕,选择扫一扫,扫描以下二维码即可进入小程序: 版本功能: 上一版功能请参见[Alpha阶段]发布说明. 当前版本的更 ...
- The Five Qualities You Need in a Partner
The Five Qualities You Need in a Partner Things I Never Considered Before Getting Married (But Shoul ...
- vue-router踩坑日记Unknown custom element router-view
今天笔者在研究vue-router的时候踩到了一个小坑,这个坑是这样的 笔者的具体代码如下:router.js import Home from '@/components/Home.vue'; im ...
- A Survey of Visual Attention Mechanisms in Deep Learning
A Survey of Visual Attention Mechanisms in Deep Learning 2019-12-11 15:51:59 Source: Deep Learning o ...
- Better intuition for information theory
Better intuition for information theory 2019-12-01 21:21:33 Source: https://www.blackhc.net/blog/201 ...
- mysql8.0:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
忽然注意到的情况: 2018/7/19至2018/9/13之间发布的7.1.20.7.1.21.7.1.22和7.2.8.7.2.9.7.2.10这六个版本提供的对caching_sha2_passw ...
- BaiduPCS-Go的安装及使用
BaiduPCS-Go的安装及使用 linux下会提示输入验证码,浏览器打开验证码url,多输入几次 Contents [hide] 一. 软件下载及安装 二. 软件的使用 1. 账号登录与退出 2. ...
- docker使用dnnmmp安装gocron
使用dnnmmp安装mysql和phpmyadmin默认使用dnnmmp_default网络,因为在安装其他依赖mysql的应用时,需指定网络 ,同时需指定mysql名称 原命令: docker ru ...
- 解决:Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceMode
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/Eric_K1m/article/deta ...
- (mysql)找不到请求的.Net Framework Data Provider。可能没有安装
webconfig配置以下节点(注意版本号) 将下面代码放在machine.config中文件,如何Web.config文件没有配置,需要添加 <system.data> <DbPr ...