我做了一个数据处理的程序,可是在处理大文件数据时会因为内存不足而停止,有人告诉我可以用内存映射来处理,我是新手,跪求哪位大哥大姐,兄弟姐妹帮我一把,程序如下:unit zhcx;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IniFiles;type
TForm1 = class(TForm)
Button1: TButton;
LB1: TListBox;
GroupBox1: TGroupBox;
CB1: TCheckBox;
CB2: TCheckBox;
CB3: TCheckBox;
CB4: TCheckBox;
CB5: TCheckBox;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
t,temp,t1:TStringList;
ASource,Alien,s:TstringList;
i:Integer;
AppIni: TIniFile;
str1:string;
str2:string;
begin
AppIni := TInifile.Create('.\config.ini');
// HYF process
if FileExists('.\teldata\ffy_info_hff.txt') and
CB1.Checked then
begin
str1:=AppIni.ReadString('pos','HYF','');
t:= TStringList.Create;
t1 := TStringList.Create;
temp:=TStringList.Create;
temp.Delimiter:=';';
t.LoadFromFile('.\teldata\ffy_info_hff.txt');
// showmessage(str1);
for i := 0 to t.Count - 1 do
begin
temp.DelimitedText:=t.Strings[i];
t1.Add(Format('%20s;',[temp[3]])+
Format('%20s;',[temp[5]])+' ;'+' HYF;'+
Format('%15d;',[StrToInt(temp[1])* StrToInt(str1)div 100])+' ;'
+Format('%20s;',[temp[6]])+' ;');
end;
t1.SaveToFile('.\teldata\deal\ffy_info_hff.txt');
t.Free;
t1.Free;
temp.Free;
// showMessage('HYF deal!');
end;
// CL-YFF process
if FileExists('.\teldata\cai_ling_info_yff.txt') and
CB2.Checked then
begin
str1:=AppIni.ReadString('pre','CL','');
str2:=AppIni.ReadString('rate','CL','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\cai_ling_info_yff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[0]])+
Format('%10s;',[ALien.Strings[8]])+' Y;'+' CL;'+
Format('%15d;',[StrToInt(ALien.Strings[7])*StrToInt(str1)*StrToInt(str2) div 10000])
+' ;'+Format('%20s;',[ALien.Strings[6]])+' ;');
end;
s.SaveToFile('.\teldata\deal\cai_ling_info_yff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('CL-YFF deal!');
end; //CL-HFF process
if FileExists('.\teldata\cai_ling_info_hff.txt') and
CB3.Checked then
begin
str1:=AppIni.ReadString('pos','CL','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\cai_ling_info_hff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[0]])+
Format('%10s;',[ALien.Strings[8]])+' H;'+' CL;'+
Format('%15d;',[StrToInt(ALien.Strings[7])*StrToInt(str1)div 100])+' ;'+
Format('%20s;',[ALien.Strings[6]])+' ;');
end;
s.SaveToFile('.\teldata\deal\cai_ling_info_hff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('CL-HFF deal!');
end;
//SPDX-YFF
if FileExists('.\teldata\phs_sms_info_down_yff.txt') and
CB4.Checked then
begin
str1:=AppIni.ReadString('pre','DX','');
str2:=AppIni.ReadString('rate','DX','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\phs_sms_info_down_yff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[4]])+
Format('%10s;',[ALien.Strings[5]])+' Y;'+' SPDX;'+
Format('%15d;',[StrToInt(ALien.Strings[10])*StrToInt(str1)*StrToInt(str2) div 10000])+' ;'+
Format('%20s;',[ALien.Strings[15]])+' ;');
end;
s.SaveToFile('.\teldata\deal\phs_sms_info_down_yff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('SPDX-YFF deal!');
end;
//SPDX-HFF
if FileExists('.\teldata\phs_sms_info_down_hff.txt')and
CB5.Checked then
begin
str1:=AppIni.ReadString('pos','DX','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\phs_sms_info_down_hff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[4]])+
Format('%10s;',[ALien.Strings[5]])+' H;'+' SPDX;'+
Format('%15d;',[StrToInt(ALien.Strings[10])*StrToInt(str1) div 100])+' ;'+
Format('%20s;',[ALien.Strings[15]])+' ;');
end;
s.SaveToFile('.\teldata\deal\phs_sms_info_down_hff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('SPDX-HFF deal!');
end;
end;
end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IniFiles;type
TForm1 = class(TForm)
Button1: TButton;
LB1: TListBox;
GroupBox1: TGroupBox;
CB1: TCheckBox;
CB2: TCheckBox;
CB3: TCheckBox;
CB4: TCheckBox;
CB5: TCheckBox;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
t,temp,t1:TStringList;
ASource,Alien,s:TstringList;
i:Integer;
AppIni: TIniFile;
str1:string;
str2:string;
begin
AppIni := TInifile.Create('.\config.ini');
// HYF process
if FileExists('.\teldata\ffy_info_hff.txt') and
CB1.Checked then
begin
str1:=AppIni.ReadString('pos','HYF','');
t:= TStringList.Create;
t1 := TStringList.Create;
temp:=TStringList.Create;
temp.Delimiter:=';';
t.LoadFromFile('.\teldata\ffy_info_hff.txt');
// showmessage(str1);
for i := 0 to t.Count - 1 do
begin
temp.DelimitedText:=t.Strings[i];
t1.Add(Format('%20s;',[temp[3]])+
Format('%20s;',[temp[5]])+' ;'+' HYF;'+
Format('%15d;',[StrToInt(temp[1])* StrToInt(str1)div 100])+' ;'
+Format('%20s;',[temp[6]])+' ;');
end;
t1.SaveToFile('.\teldata\deal\ffy_info_hff.txt');
t.Free;
t1.Free;
temp.Free;
// showMessage('HYF deal!');
end;
// CL-YFF process
if FileExists('.\teldata\cai_ling_info_yff.txt') and
CB2.Checked then
begin
str1:=AppIni.ReadString('pre','CL','');
str2:=AppIni.ReadString('rate','CL','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\cai_ling_info_yff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[0]])+
Format('%10s;',[ALien.Strings[8]])+' Y;'+' CL;'+
Format('%15d;',[StrToInt(ALien.Strings[7])*StrToInt(str1)*StrToInt(str2) div 10000])
+' ;'+Format('%20s;',[ALien.Strings[6]])+' ;');
end;
s.SaveToFile('.\teldata\deal\cai_ling_info_yff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('CL-YFF deal!');
end; //CL-HFF process
if FileExists('.\teldata\cai_ling_info_hff.txt') and
CB3.Checked then
begin
str1:=AppIni.ReadString('pos','CL','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\cai_ling_info_hff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[0]])+
Format('%10s;',[ALien.Strings[8]])+' H;'+' CL;'+
Format('%15d;',[StrToInt(ALien.Strings[7])*StrToInt(str1)div 100])+' ;'+
Format('%20s;',[ALien.Strings[6]])+' ;');
end;
s.SaveToFile('.\teldata\deal\cai_ling_info_hff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('CL-HFF deal!');
end;
//SPDX-YFF
if FileExists('.\teldata\phs_sms_info_down_yff.txt') and
CB4.Checked then
begin
str1:=AppIni.ReadString('pre','DX','');
str2:=AppIni.ReadString('rate','DX','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\phs_sms_info_down_yff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[4]])+
Format('%10s;',[ALien.Strings[5]])+' Y;'+' SPDX;'+
Format('%15d;',[StrToInt(ALien.Strings[10])*StrToInt(str1)*StrToInt(str2) div 10000])+' ;'+
Format('%20s;',[ALien.Strings[15]])+' ;');
end;
s.SaveToFile('.\teldata\deal\phs_sms_info_down_yff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('SPDX-YFF deal!');
end;
//SPDX-HFF
if FileExists('.\teldata\phs_sms_info_down_hff.txt')and
CB5.Checked then
begin
str1:=AppIni.ReadString('pos','DX','');
ASource := TStringList.Create;
ALien := TStringList.Create;
s:=TStringList.Create;
ASource.LoadFromFile('.\teldata\phs_sms_info_down_hff.txt');
for i := 0 to ASource.Count - 1 do
begin
alien.clear;
ExtractStrings([' '], [],pchar(ASource.Strings[i]) , ALien);
s.Add(Format('%20s;',[ALien.Strings[4]])+
Format('%10s;',[ALien.Strings[5]])+' H;'+' SPDX;'+
Format('%15d;',[StrToInt(ALien.Strings[10])*StrToInt(str1) div 100])+' ;'+
Format('%20s;',[ALien.Strings[15]])+' ;');
end;
s.SaveToFile('.\teldata\deal\phs_sms_info_down_hff.txt');
Asource.Free;
Alien.Free;
s.Free;
// showMessage('SPDX-HFF deal!');
end;
end;
end.
解决方案 »
- 大侠请进:谁能控制MT4的图表显示
- cxGrid1DBTableView1.datacontroller.column[1].value:='dfsdf'可以吗
- clientSocket和serverSocket是基于什么协议工作的?
- Delphi中做网页的问题
- 请教 IntraWeb中的TMS的DBAdvWebGrid如何用ctNode实现明细行
- 【 Delphi6 为何无法添加 F1Book6.1】错误 N 多,
- indy控件使用问题
- 哪里有大富翁离線BBS(delphibbs.chm文件)下載?怎麼從WWW.DELPHIBBS.COM上下載281M的大富翁离線BBS不能使用!!!
- 大家帮忙。怎样控制系统声音的主音量。(我是新手)谢谢。来者有分:)
- 在MDI 程序设计中,如果要在MDIFORM 中加背景图片怎么办?
- ******超级猛料2006在线版******
- delphi中怎样解决字符串数据右截位的问题???急----急---
unit zhcx;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IniFiles;type
TForm1 = class(TForm)
Button1: TButton;
LB1: TListBox;
GroupBox1: TGroupBox;
CB1: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
t,temp,t1:TStringList;
i:Integer;
AppIni: TIniFile;
str1:string;
str2:string;
begin
AppIni := TInifile.Create('.\config.ini');
// HYF process
if FileExists('.\teldata\ffy_info_hff.txt') and
CB1.Checked then
begin
str1:=AppIni.ReadString('pos','HYF','');
t:= TStringList.Create;
t1 := TStringList.Create;
temp:=TStringList.Create;
temp.Delimiter:=';';
t.LoadFromFile('.\teldata\ffy_info_hff.txt');
// showmessage(str1);
for i := 0 to t.Count - 1 do
begin
temp.DelimitedText:=t.Strings[i];
t1.Add(Format('%20s;',[temp[3]])+
Format('%20s;',[temp[5]])+' ;'+' HYF;'+
Format('%15d;',[StrToInt(temp[1])* StrToInt(str1)div 100])+' ;'
+Format('%20s;',[temp[6]])+' ;');
end;
t1.SaveToFile('.\teldata\deal\ffy_info_hff.txt');
t.Free;
t1.Free;
temp.Free;
// showMessage('HYF deal!');
end;
end.
你会觉得快的好多好多。