Міністерство освіти та науки України
Національний технічний університет України
«Київський політехнічний інститут»
Факультет прикладної математики
Кафедра спеціалізованих комп’ютерних систем
РОЗРАХУНКОВА РОБОТА
з дисципліни «Організація баз даних»
V семестр
Київ 2011
Клієнт – Main.pas:
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 = class(TForm)
PORTEDIT: TEdit;
LOGBOX: TMemo;
EXITBUTTON: TButton;
PORTLABEL: TLabel;
LOGLABEL: TLabel;
CONNECTBUTTON: TButton;
SERVERLABEL: TLabel;
SERVEREDIT: TEdit;
ClientSocket: TClientSocket;
QUERYLABEL: TLabel;
MSGBOX: TMemo;
SENDBUTTON: TButton;
CLEARBUTTON: TButton;
BUFFER: TListBox;
procedure EXITBUTTONClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CONNECTBUTTONClick(Sender: TObject);
procedure SENDBUTTONClick(Sender: TObject);
procedure ClientSocketConnect(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSocketRead(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSocketDisconnect(Sender: TObject; Socket: TCustomWinSocket);
procedure CLEARBUTTONClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1 : TForm1;
query : TStringList;
implementation
{$R *.dfm}
procedure TForm1.EXITBUTTONClick( Sender: TObject );
begin
if CONNECTBUTTON.Tag = 1 then
CONNECTBUTTON.Click;
halt( 0 );
end;
procedure TForm1.FormCreate( Sender: TObject );
begin
PORTEDIT.Text := '777';
SERVEREDIT.Text := '127.0.0.1';
end;
procedure TForm1.SENDBUTTONClick( Sender: TObject );
begin
if MSGBOX.Text <> '' then
begin
query := TStringList.Create;
query.Text := StringReplace( MSGBOX.Text, ' ' , #13#10, [ rfReplaceAll ] );
ClientSocket.Socket.SendText( query.Text );
LOGBOX.Lines.Add( '[' + TimeToStr( Time ) + '] Client: ' + MSGBOX.Text );
end
else
ShowMessage('Please, ented a valid query!');
end;
procedure TForm1.CLEARBUTTONClick(Sender: TObject);
begin
LOGBOX.Clear;
end;
procedure TForm1.ClientSocketConnect( Sender: TObject; Socket: TCustomWinSocket );
begin
LOGBOX.Lines.Add( '[' + TimeToStr( Time ) + '] Connecting to server.' );
end;
procedure TForm1.ClientSocketDisconnect( Sender: TObject;
Socket: TCustomWinSocket );
begin
LOGBOX.Lines.Add( '[' + TimeToStr( Time ) + '] Connection has been closed.' );
if CONNECTBUTTON.Tag = 1 then
CONNECTBUTTON.Click;
end;
procedure TForm1.ClientSocketRead( Sender: TObject; Socket: TCustomWinSocket );
var
i : integer;
begin
BUFFER.Items.Clear;
BUFFER.Items.Text := Socket.ReceiveText;
for i := 0 to BUFFER.Items.Count - 1 do
LOGBOX.Lines.Add(BUFFER.Items[i]);
end;
procedure TForm1.CONNECTBUTTONClick( Sender: TObject );
begin
if CONNECTBUTTON.Tag = 0 then
begin
SERVEREDIT.Enabled := False;
PORTEDIT.Enabled := False;
ClientSocket.Port := StrToInt( PORTEDIT.Text );
ClientSocket.Host := SERVEREDIT.Text;
ClientSocket.Address := SERVEREDIT.Text;
ClientSocket.Active := True;
CONNECTBUTTON.Tag := 1;
CONNECTBUTTON.Caption := 'Disconnect';
end
else
begin
SERVEREDIT.Enabled := True;
PORTEDIT.Enabled := True;
ClientSocket.Active := False;
CONNECTBUTTON.Tag := 0;
CONNECTBUTTON.Caption := 'Connect';
end;
end;
end.
Сервер – Main.pas:
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TLexem = record
elements : array of string;
count : byte;
need : boolean;
end;
TArr = array of TLexem;
TForm1 = class(TForm)
PORTEDIT: TEdit;
LOGBOX: TMemo;
EXITBUTTON: TButton;
PORTLABEL: TLabel;
LOGLABEL: TLabel;
STARTBUTTON: TButton;
ServerSocket: TServerSocket;
BUFFER: TListBox;
TMPBOX: TListBox;
procedure EXITBUTTONClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure STARTBUTTONClick(Sender: TObject);
procedure ServerSocketClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocketClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocketClientRead(Sender: TObject; Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1 : TForm1;
Source : TArr;
sourceSize : word;
dbIn : TextFile;
dbfile, s : string;
implementation
{$R *.dfm}
procedure ProcessLine( s : string );
var i : byte;
Row : TLexem;
begin
i := 1;
Row.count := 0;
while i <= length( s ) do
begin
while s[ i ] in [ #9, ' ' ] do
inc( i );
if s[ i ] in [ '@', 'a'..'z', 'A'..'Z', '0'..'9', '_', '/' ] then
begin
inc( Row.count );
SetLength( Row.elements, Row.count + 1 );
end;
while s[ i ] in [ '@', 'a'..'z', 'A'..'Z', '0'..'9', '_', '/', ']', '[', ',', '+', '-', '*', ':', '(', ')', '.', '?', #39, '#' ] do
begin
Row.elements[ Row.count ] := Row.elements[ Row.count ] + s[ i ];
inc( i );
end;
if s[ i ] = ';' then
inc( i );
end;
Row.need := true;
inc( sourceSize );
SetLength( Source, sourceSize + 1 );
Source[ sourceSize ] := Row;
end;
procedure TForm1.EXITBUTTONClick( Sender: TObject );
begin
if STARTBUTTON.Tag = 1 then
STARTBUTTON.Click;
halt( 0 );
end;
procedure TForm1.FormCreate( Sender: TObject );
begin
PORTEDIT.Text := '777';
end;
procedure TForm1.ServerSocketClientConnect( Sender: TObject;
Socket: TCustomWinSocket );
begin
LOGBOX.Lines.Add( '[' + TimeToStr( Time ) + '] Client connected.' );
end;
procedure TForm1.ServerSocketClientDisconnect( Sender: TObject;
Socket: TCustomWinSocket );
begin
LOGBOX.Lines.Add( '[' + TimeToStr( Time ) + '] Client disconnected.' );
end;
procedure TForm1.ServerSocketClientRead( Sender: TObject;
Socket: TCustomWinSocket );
var
query : TStringList;
i, index, counter : integer;
Row : TLexem;
j: Integer;
found : boolean;
CurrentDay: String;
Dt: TDateTime;
begin
query := TStringList.Create;
query.Text := Socket.ReceiveText();
LOGBOX.Lines.Add( '[' + TimeToStr( Time ) + '] Client: ' + query.Strings[ 0 ] );
if UpperCase( query.Strings[ 0 ] ) = 'SHOW' then
begin
for i := 1 to sourceSize do
begin
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
end
else
if UpperCase( query.Strings[ 0 ] ) = 'ADD' then
begin
Row.count := 9;
SetLength( Row.elements, Row.count + 1 );
for i := 1 to 9 do
Row.elements[ i ] := query.Strings[ i ];
Row.need := true;
inc( sourceSize );
SetLength( Source, sourceSize + 1 );
Source[ sourceSize ] := Row;
end
else
if UpperCase( query.Strings[ 0 ] ) = 'DEL' then
begin
for i := 1 to sourceSize do
if ( Source[ i ].elements[ 1 ] = query.Strings[ 1 ] ) and
( Source[ i ].elements[ 2 ] = query.Strings[ 2 ] ) and
( Source[ i ].elements[ 3 ] = query.Strings[ 3 ] ) and
( Source[ i ].elements[ 4 ] = query.Strings[ 4 ] ) and
( Source[ i ].elements[ 5 ] = query.Strings[ 5 ] ) and
( Source[ i ].elements[ 6 ] = query.Strings[ 6 ] ) and
( Source[ i ].elements[ 7 ] = query.Strings[ 7 ] ) and
( Source[ i ].elements[ 8 ] = query.Strings[ 8 ] ) and
( Source[ i ].elements[ 9 ] = query.Strings[ 9 ] ) then
break;
index := i;
if index > High( Source ) then
exit;
if index < Low( Source ) then
exit;
if index = High( Source ) then
begin
SetLength( Source, Length( Source ) - 1 );
sourceSize := sourceSize - 1;
exit;
end;
Finalize( Source[ index ] );
System.Move( Source[ index + 1 ], Source[ index ], ( Length( Source ) - index - 1 ) * SizeOf( Source[ index ] ) + 1 );
SetLength( Source, Length( Source ) - 1 );
sourceSize := sourceSize - 1;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SAVE' then
begin
if FileExists( dbfile ) then
begin
AssignFile( dbIn, dbfile );
Rewrite( dbIn );
for i := 1 to sourceSize do
begin
for j := 1 to 8 do
begin
write( dbIn, Source[ i ].elements[ j ] + ';' )
end;
write( dbIn, Source[ i ].elements[ j ] );
if i <> sourceSize then
writeln( dbIn );
end;
CloseFile( dbIn );
end
end;
if UpperCase( query.Strings[ 0 ] ) = 'REINDEX' then
begin
dbfile := 'db.dbfile';
if FileExists( dbfile ) then
begin
AssignFile( dbIn, dbfile );
Reset( dbIn );
setLength( Source, 1 );
sourceSize := 0;
while not eof( dbIn ) do
begin
readln( dbIn, s );
ProcessLine( s );
end;
CloseFile( dbIn );
end
else
begin
writeln( 'Error: db file does not exist!' );
readln;
exit;
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SEARCHD' then
begin
for i := 1 to sourceSize do
begin
if Source[ i ].elements[ 3 ] = query.Strings[ 1 ] then
begin
found := TRUE;
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
end;
if not found then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( 'Nothing found!' );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SEARCHA' then
begin
for i := 1 to sourceSize do
begin
if Source[ i ].elements[ 1 ] = query.Strings[ 1 ] then
begin
found := TRUE;
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
end;
if not found then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( 'Nothing found!' );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SEARCHN' then
begin
for i := 1 to sourceSize do
begin
if Source[ i ].elements[ 2 ] = query.Strings[ 1 ] then
begin
found := TRUE;
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
end;
if not found then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( 'Nothing found!' );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SHOWP' then
begin
for i := 1 to sourceSize do
begin
if Source[ i ].elements[ 9 ] = 'y' then
begin
found := TRUE;
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
end;
if not found then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( 'Nothing found!' );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SHOWA' then
begin
for i := 1 to sourceSize do
begin
if ( Source[ i ].elements[ 9 ] = 'n' ) and ( Source[ i ].elements[ 5 ] = query.Strings[ 1 ] ) then
begin
found := TRUE;
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
end;
if not found then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( 'Nothing found!' );
ServerSocket.Socket.Connections[ 0 ].SendText(BUFFER.Items.Text);
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'EDIT' then
begin
for i := 1 to sourceSize do
if ( Source[ i ].elements[ 1 ] = query.Strings[ 1 ] ) and
( Source[ i ].elements[ 2 ] = query.Strings[ 2 ] ) and
( Source[ i ].elements[ 3 ] = query.Strings[ 3 ] ) and
( Source[ i ].elements[ 4 ] = query.Strings[ 4 ] ) and
( Source[ i ].elements[ 5 ] = query.Strings[ 5 ] ) and
( Source[ i ].elements[ 6 ] = query.Strings[ 6 ] ) and
( Source[ i ].elements[ 7 ] = query.Strings[ 7 ] ) and
( Source[ i ].elements[ 8 ] = query.Strings[ 8 ] ) and
( Source[ i ].elements[ 9 ] = query.Strings[ 9 ] ) then
break;
Source[ i ].elements[ 1 ] := query.Strings[ 11 ];
Source[ i ].elements[ 2 ] := query.Strings[ 12 ];
Source[ i ].elements[ 3 ] := query.Strings[ 13 ];
Source[ i ].elements[ 4 ] := query.Strings[ 14 ];
Source[ i ].elements[ 5 ] := query.Strings[ 15 ];
Source[ i ].elements[ 6 ] := query.Strings[ 16 ];
Source[ i ].elements[ 7 ] := query.Strings[ 17 ];
Source[ i ].elements[ 8 ] := query.Strings[ 18 ];
Source[ i ].elements[ 9 ] := query.Strings[ 19 ];
end;
if UpperCase( query.Strings[ 0 ] ) = 'LASTADD' then
begin
//Get current day
Dt := Now;
CurrentDay:= FormatDateTime('yyyy-mm-dd', Dt);
for i := 1 to sourceSize do
begin
if Source[ i ].elements[ 4 ] = CurrentDay then
begin
found := TRUE;
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ i ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ i ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ i ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ i ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ i ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ i ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ i ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ i ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ i ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText( BUFFER.Items.Text );
end;
end;
end;
if not found then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( 'Nothing found!' );
ServerSocket.Socket.Connections[ 0 ].SendText( BUFFER.Items.Text );
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SORTTITLE' then
begin
TMPBOX.Clear;
for i := 1 to sourceSize do
begin
TMPBOX.Items.Add( Source[ i ].elements[ 2 ] );
end;
TMPBOX.Sorted := TRUE;
for i := 0 to TMPBOX.Count - 1 do
for j := 1 to sourceSize do
begin
if Source[ j ].elements[ 2 ] = TMPBOX.Items[ i ] then
begin
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i + 1 ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ j ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ j ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ j ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ j ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ j ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ j ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ j ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ j ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ j ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText( BUFFER.Items.Text );
end;
end;
end;
end;
if UpperCase( query.Strings[ 0 ] ) = 'SORTID' then
begin
TMPBOX.Clear;
for i := 1 to sourceSize do
begin
TMPBOX.Items.Add( Source[ i ].elements[ 3 ] );
end;
TMPBOX.Sorted := TRUE;
for i := 0 to TMPBOX.Count - 1 do
for j := 1 to sourceSize do
begin
if Source[ j ].elements[ 3 ] = TMPBOX.Items[ i ] then
begin
ServerSocket.Socket.Connections[ 0 ].SendText( 'Entry #' + IntToStr( i + 1 ) + ': ' + #13 + #10 );
if ServerSocket.Active = True then
begin
BUFFER.Items.Clear;
BUFFER.Items.Add( #9 + 'Author: ' + Source[ j ].elements[ 1 ] );
BUFFER.Items.Add( #9 + 'Title: ' + Source[ j ].elements[ 2 ] );
BUFFER.Items.Add( #9 + 'ID: ' + Source[ j ].elements[ 3 ] );
BUFFER.Items.Add( #9 + 'Acc. date: ' + Source[ j ].elements[ 4 ] );
BUFFER.Items.Add( #9 + 'Type: ' + Source[ j ].elements[ 5 ] );
BUFFER.Items.Add( #9 + 'Pub. date: ' + Source[ j ].elements[ 6 ] );
BUFFER.Items.Add( #9 + 'Last view: ' + Source[ j ].elements[ 7 ] );
BUFFER.Items.Add( #9 + 'Views: ' + Source[ j ].elements[ 8 ] );
BUFFER.Items.Add( #9 + 'Presence: ' + Source[ j ].elements[ 9 ] );
ServerSocket.Socket.Connections[ 0 ].SendText( BUFFER.Items.Text );
end;
end;
end;