在Delphi中,如何打开一个TXT文件?是用OpenFile函数吗?请各位大侠指点。
打开文件之后,又该如何将文件的内容取出来呢?谢谢各位了!!!
打开文件之后,又该如何将文件的内容取出来呢?谢谢各位了!!!
解决方案 »
- clientdataset 三层如何传中文参数?
- 装了XPmenu 放到form上运行不起来,请问各位大虾是什么原因!
- 问题两个(有点难)
- 急找深圳 delphi 7 数据库开发高手.兼责做上几天10月21日前
- 我在我的DLL中,有一函数参数使用了TstringList类变量,传指针(var),出奇怪问题,高手解答?
- 文点愚笨的问题
- 在C中的这样的语句在Pascal中怎么写????
- ==如何用QuickRpt打印这样的图表?===
- (((((((( SoS ))))))如何使 EXCEL 的关闭按钮“X”和 “文件”中的"退出"操作 失效
- E-mail程序开发小问题.
- 如何勇ADOConnection连接远程(通过Internet)SQL 2000数据库?
- udp的连接过程(需要一点代码提示),送50分
Dir:string;
SpotID:string;
SCom1,Scom2:string;Dir:='SellSpot_ID.txt'; //SellSpot_ID.txt文件是程序中用来存放操作站点号、通信串口的
AssignFile(F, Dir);
Reset(F);
Readln(F,SpotID); //得到登录地点
Readln(F,Scom1); //有线通信串口
Readln(F,Scom2); //无线通信串口
CloseFile(F);
s:string;
begin
AssignFile(f,'c:\a.txt');
Reset(f); 还有rewrite append等
readln(f,s) 读取一行
closefile(f);
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
Rec1=Record
str1:string[10];
x:Integer;
y:Integer;
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
a:array[1..5,1..2] of Integer;
rc:Rec1;
i,j:Integer;
file1,file2:Textfile;
str1:string;
begin
assignfile(file1,'ftest1.dat');
assignfile(file2,'ftest2.dat');
Rewrite(file1);
Rewrite(file2);
randomize;
for i:=1 to 5 do
begin
for j:=1 to 2 do
begin
a[i,j]:=random(10000);
write(file1,a[i,j],' ');
if j=2 then
begin
rc.x:=a[i,j-1];
rc.y:=a[i,j];
rc.str1:='record1:'+IntToStr(i);
//writeln(file2,rc);
writeln(file2,rc.str1,' ',rc.x,' ',rc.y);
end;
end;
writeln(file1);
end;
Reset(file1);
Reset(file2);
for i:=1 to 5 do
begin
str1:='';
for j:=1 to 2 do
begin
read(file1,a[i,j]);
str1:=str1+inttostr(a[i,j])+' ';
end;
readln(file1);
//ShowMessage('show1.'+inttostr(i)+':'+str1);
ListBox1.Items.Add('show1.'+inttostr(i)+':'+str1);
end;
for i:=1 to 5 do
begin
//readln(file2,rc);
//readln(file2,b[i]);
readln(file2,rc.str1,rc.x,rc.y);
str1:=rc.str1+inttostr(rc.x)+' '+inttostr(rc.y);
//showmessage('show3.'+str1);
ListBox2.Items.Add('show3.'+str1);
end;
closefile(file1);
closefile(file2);
//close;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;end.