delphi 读写记录类型文件Record
type personInfo=Record //定义Record
Name:String[10]; Age:integer; end; //写记录包括新键与添加记录 procedure WriteRec; var NewRec:PersonInfo; //声明Rec变量 F:File of PersonInfo; //Rec型文件变量 RecFileName:ShortString; //保存Rec的文件全名 RecCount:integer; //Rec数量 begin NewRec.Name:=NameEdit.Text; //从界面上取数据 NewRec.Age:=StrToInt(AgeEdit.Text); RecFileName:='C:\PersonInfo.Rec'; AssignFile(F,RecFileName); if FileExists(RecFileName)<>True then //判断文件是否存在 begin Rewrite(F); //不存在则新增文件 Write(F,NewRec); end else begin FileMode:=1; //设置成WriteOnly模式 Reset(F); //存在则添加Rec入文件 RecCount:=FileSize(F); //取Rec数量 Seek(F,RecCount); //设置Pointer位置 Write(F,NewRec); end; CloseFile(F); //关闭文件 end; //读取记录 procedure ReadRec; var GetRec:PersonInfo; F:File of PersonInfo; RecFileName:ShortString; //保存Rec的文件名称 RecCount:Integer; //用户想要读取的Rec位置 RecMax:integer; //Rec的最大值 begin RecFileName:='C:\PersonInfo.Rec'; RecCount:=StrToInt(CountEdit.Text)-1; //用户要提取第一个就输入1,类推 AssignFile(F,RecFileName); if FileExists(RecFileName)<>True then exit; FileMode:=0; Reset(F); RecMax:=FileSize(F); if RecCount>RecMax-1 then Exit; //超过Rec最大值则跳出 Seek(F,RecCount); //设置读取Rec的Pointer位置 Read(F,GetRec); Showmessage(GetRec.Name+InttoStr(GetRec.Age)); end;
delphi 读写记录类型文件Record的更多相关文章
- Oracle记录类型(record)和%rowtype
Oracle中的记录类型(record)和使用%rowtype定义的数据类型都是一种单行多列的数据结构,可以理解为一个具有多个属性的对象.其中属性名即为列名. 记录类型(record) 记录类型是一种 ...
- delphi中无类型文件读写
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- Delphi 中记录类型 给记录指针赋值。
PPersion=^TPersion; TPersion=packed record Name:string; Sex:string; Clasee:string; end ...
- Delphi 中记录类型 给记录指针赋值
PPersion=^TPersion; TPersion=packed record Name:string; Sex:string; Clasee:string; end; var persion: ...
- delphi 文本 记录 流式 读写文件
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...
- oracle学习之路(二)------数组类型/记录类型的使用
Oracle记录类型介绍 RECORD:用户自己定义数据类型,由单行多列的标量构成的复合数据类型.它将一个或多个标量封装成一个对象进行操作记录不能够总体拿来比較也不能够总体推断为空.能够总体拿来赋值. ...
- Delphi 实现最近打开文件记录菜单
unit UntOpenMenu; //download by http://wwww.NewXing.com interface uses Windows, Messages, SysUtils, ...
- Delphi如何处理不同类型的文件
参考:http://www.cnblogs.com/railgunman/articles/1800318.html 程序设计当中,我们时常遇到需要处理文件.目录及驱动器的情况,这里将对如何处理不同类 ...
- Delphi关于记录文件的操作
http://www.cnblogs.com/railgunman/archive/2010/08/16/1801004.html Delphi关于记录文件的操作 本例子几个变量的说明TFileR ...
随机推荐
- AngularJS ng-model 指令
AngularJS ng-model 指令 ng-model 指令用于绑定应用程序数据到 HTML 控制器(input, select, textarea)的值. 代码示例如下: <!DOCTY ...
- JAVA中STL使用
Vector:和c++的vector使用方法类似. Vector<Integer> vec=new Vector<> (); ArrayList:Java.util.Array ...
- CSS-给Font Awesome拓展Base64编码的图标
和 fa 一样设置到::before中就行了,不过 fa 是直接设置内容,这里用的背景图 .fa-science-garden::before { content: ""; dis ...
- Jmeter中动态获取jsessionid来登录
Jmeter中很多请求的url里会包含jsessionid,如 http://www.xxx.com/xxx_app;jsessionid=xxxxxxxxxx?a=x&b=x.jsessio ...
- MVC和WebApi 使用get和post 传递参数。 转载https://blog.csdn.net/qq373591361/article/details/51508806
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq373591361/article/details/51508806我们总结一下用js请求服务器的 ...
- std::sort的详细用法
#include <algorithm> #include <functional> #include <array> #include <iostream& ...
- apache 安装配置 (centos)
1. 使用yum包安装Apache软件 [root@Apache ~]# yum -y install httpd* [root@Apache ~]# rpm -qa | grep httpd --查 ...
- MySQL-mysql_config_editor安全登录工具
mysql_config_editor出现在mysql5.6.6以后的版本,可以给指定的连接和密码生成一个加密文件.mylogin.cnf,默认位于当前用户家目录下.通过该文件可以使用mysql.my ...
- Codeforces 492E Vanya and Field
E. Vanya and Field time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Moco 框架以及其在 Web 集成测试的应用
转自:https://www.ibm.com/developerworks/cn/web/1405_liugang_mocowebtest/ Moco 框架以及其在 Web 集成测试的应用 我们往往将 ...