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的更多相关文章

  1. Oracle记录类型(record)和%rowtype

    Oracle中的记录类型(record)和使用%rowtype定义的数据类型都是一种单行多列的数据结构,可以理解为一个具有多个属性的对象.其中属性名即为列名. 记录类型(record) 记录类型是一种 ...

  2. delphi中无类型文件读写

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  3. Delphi 中记录类型 给记录指针赋值。

    PPersion=^TPersion;  TPersion=packed record     Name:string;     Sex:string;     Clasee:string;  end ...

  4. Delphi 中记录类型 给记录指针赋值

    PPersion=^TPersion; TPersion=packed record Name:string; Sex:string; Clasee:string; end; var persion: ...

  5. delphi 文本 记录 流式 读写文件

    unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...

  6. oracle学习之路(二)------数组类型/记录类型的使用

    Oracle记录类型介绍 RECORD:用户自己定义数据类型,由单行多列的标量构成的复合数据类型.它将一个或多个标量封装成一个对象进行操作记录不能够总体拿来比較也不能够总体推断为空.能够总体拿来赋值. ...

  7. Delphi 实现最近打开文件记录菜单

    unit UntOpenMenu; //download by http://wwww.NewXing.com interface uses Windows, Messages, SysUtils, ...

  8. Delphi如何处理不同类型的文件

    参考:http://www.cnblogs.com/railgunman/articles/1800318.html 程序设计当中,我们时常遇到需要处理文件.目录及驱动器的情况,这里将对如何处理不同类 ...

  9. Delphi关于记录文件的操作

    http://www.cnblogs.com/railgunman/archive/2010/08/16/1801004.html Delphi关于记录文件的操作   本例子几个变量的说明TFileR ...

随机推荐

  1. paper 167:GPU的使用Theano之tutorial

    Theano之使用GPU 英文版本:http://deeplearning.net/software/theano/tutorial/using_gpu.html          using the ...

  2. E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarly unavailable)

    1. 问题详细提示如下: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarly unava ...

  3. vue数据渲染、条件判断及列表循环

    1.数据渲染  {{msg}} <template> <div id="app"> {{msg}} </div> </template&g ...

  4. CSS布局浮动和定位属性的区别

    float: left|right; 可以自动排列自动折行, 但需要clear来配合清除浮动;display: inline-block 有些时候可以替代float实现相同的效果. position: ...

  5. python中join()函数的用法

    join()函数 语法:  'sep'.join(s) 参数说明 sep:分隔符.可以为空 s:要连接的元素序列.字符串.元组.字典 上面的语法即:以sep作为分隔符,将s所有的元素合并成一个新的字符 ...

  6. AtCoder Grand Contest 012 A - AtCoder Group Contest(贪心)

    Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There are 3N participa ...

  7. Workflow:Workflow 百科

    ylbtech-Workflow:Workflow 百科 工作流(Workflow),指“业务过程的部分或整体在计算机应用环境下的自动化”.是对工作流程及其各操作步骤之间业务规则的抽象.概括描述.在计 ...

  8. write(byte[] b, int off, int len)

    write(byte[] b, int off, int len)就是将数组 b 中的 len 个字节按顺序写入输出流. 所以如果 b 为 null,则抛出 NullPointerException. ...

  9. vue搭建项目步骤(二)

    上篇是搭建Vue项目的基本,接下来是继续对做项目的记录.顺序并不一定. 五.对页面入口文件的修改: 众所周知,main.js 程序入口文件,加载各种公共组件,App.Vue为 页面入口文件.但是有时候 ...

  10. Linux崩溃时启动脚本获取进程相关信息

    编写test.cpp #include <stdlib.h> #include <stdio.h> #include <exception> #include &l ...