Arsip: Konversi Stream


by agusmade in Articles more 17 years ago 6074
jika anda sering bermasalah dalam menggunakan stream, berikut ada beberapa rutin yang biasa saya gunakan untuk mengkonversikan stream.
//Stream Convertion
//agus made k (agusmade@yaoo.com)
{ File to String  }
function filetostring(afilename:string):string;
var fl:TFileStream;
begin
fl:=TFileStream.Create(afilename,fmOpenRead or fmShareCompat);
SetLength(result,fl.Size);
fl.Read(result[1],fl.Size);
fl.Free;
end;
{ String to File  }
procedure stringtofile(acontent,afilename:string);
var fl:TFileStream;
begin
fl:=TFileStream.Create(afilename,fmOpenWrite or fmCreate);
fl.Write(acontent[1],length(acontent));
fl.Free;
end;
{ Stream to String  }
function stringtofile(adata:TStream):string;
var str:TStringStream;
s:string;
begin
str:=TStringStream.Create(s);
str.CopyFrom(adata,adata.size);
result:=str.datastring;
str.free;
end;
{ String to Stream  }
procedure stringtofile(s:String;adata:TStream);
var str:TStringStream;
begin
str:=TStringStream.Create(s);
adata.CopyFrom(str,str.size);
str.free;
result:=str.datastring;
str.free;
end;

Coinfest

Pascal Indonesia is Coinfest Asia 2024's official community partner! 🀝
β˜€οΈ Take part in Asia’s immersive Web3 festival, where innovation meets adoption.
🎟 Get your tickets at www.coinfest.asia and use our special promo code : CA24PASCALINDO to get 10% off!

Why Coinfest Asia?
● Unconventionally Engaging
Our immersive setting and programming leave you with more memory markers than any other event
● Dive into Emerging Markets
Get connected in Southeast Asia; the fastest-growing Web3 region in the world
● Jump straight into Adoption
Foster collaborations directly in Indonesia where there are 437k new crypto users each month

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com