一个简单的问题(0分)

  • 主题发起人 主题发起人 yepp
  • 开始时间 开始时间
Y

yepp

Unregistered / Unconfirmed
GUEST, unregistred user!
一个简单的问题,我想用Memo将读取的文本文件(英文)中的单词每行显示一个单词,
用什么函数,区分单词的依据是空格或标点符号,谢谢。
 
memo1.loadfromfile(....);
aa:=Tstinglist.Create;
aa.CommaText:=memo1.text;
memo1.clear;
for i:=0 to aa.count-1 do
memo1.lines.add(aa.strings);
aa.free

你看可以不可以,我估计得写的
 
function FileSeek(Handle, Offset, Origin: Integer): Integer
overload;
function FileSeek(Handle: Integer
const Offset: Int64
Origin: Integer): Int64
overload;

Description

Use FileSeek to reposition the read/write point in a file that was opened with FileOpen or FileCreate. Handle is the file handle that was returned by FileOpen or FileCreate.

Offset specifies the number of bytes from Origin where the file pointer should be positioned. Origin is a code with three possible values, denoting the beginning of the file, the end of the file, and the current position of the file pointer.

Origin Action

0 The file pointer is positioned Offset bytes from the beginning of the file.
1 The file pointer is positioned Offset bytes from its current position.
2 The file pointer is positioned Offset bytes from the end of the file.
利用fileseek ,fileread,一个一个字节读,然后判断,这是比较苯的办法,主要是不知道你的文件的具体格式
如果能用readln 更好
 
while NOT Eof(fp) do
begin
mybuf:='';
Readln(fp,mybuf);
strbuf:='';
for i:=1 to Length(mybuf) do
begin
if NOT (mybuf in ['a'..'z']) OR NOT (mybuf in ['A'..'Z']) then
strbuf:=strbuf+#13 //回车,忘了是多少
else strbuf:=strbuf+Copy(mybuf,i,1);
end;
memo1.lines.add(strbuf);
end;
这样,strbuf里面就是你想要的东西
 
谢谢,谢谢
 
后退
顶部