home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programming Unleashed
/
Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso
/
misc
/
blobs
/
blobstuf
/
main.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-20
|
2KB
|
88 lines
unit Main;
{ Program copyright (c) 1995 by Charles Calvert }
{ Project Name: BLOBSTUF }
{ Working with BLOBS and streams. This is not an example of working
with a BlobStream object. }
interface
uses
SysUtils, WinTypes, WinProcs,
Messages, Classes, Graphics,
Controls, Forms, Dialogs,
StdCtrls, DBTables, DB,
DBCtrls, Grids, DBGrids;
const
FName = 'foo.dat';
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBMemo1: TDBMemo;
Table1SpeciesNo: TFloatField;
Table1Category: TStringField;
Table1Common_Name: TStringField;
Table1SpeciesName: TStringField;
Table1Lengthcm: TFloatField;
Table1Length_In: TFloatField;
Table1Notes: TMemoField;
Table1Graphic: TGraphicField;
Save: TButton;
ReadStream: TButton;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
procedure SaveClick(Sender: TObject);
procedure ReadStreamClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
StrBox;
{$R *.DFM}
procedure TForm1.SaveClick(Sender: TObject);
var
MyStream: TFileStream;
Dir: string;
begin
Dir := StripLastToken(ParamStr(0), '\');
MyStream := TFileStream.Create(Dir + '\' + FName, fmOpenWrite);
Table1Notes.SaveToStream(MyStream);
MyStream.Free;
ReadStream.Enabled := True;
end;
procedure TForm1.ReadStreamClick(Sender: TObject);
var
MyStream: File;
Dir: string;
S1: PChar;
begin
Dir := StripLastToken(ParamStr(0), '\');
System.Assign(MyStream, Dir + '\' + FName);
Reset(MyStream, 1);
GetMem(S1, FileSize(MyStream) + 1);
BlockRead(MyStream, S1^, FileSize(MyStream));
S1[FileSize(MyStream)] := #0;
Memo1.SetTextBuf(S1);
FreeMem(S1, FileSize(MyStream) + 1);
System.Close(MyStream);
end;
end.