[Update] @Karl-Heinz: BoxQuote geputzt :-)

10/11/2008 - 11:28 von Hermann Hippen | Report spam
Moin Moin :-),

http://kh-rademacher.de/4d/Boxquote_Include-1.html

Komplett entsorgt wurden die beiden Funktionen:
StringReplaceM() & RepeatChar() und der Code wurde etwas optmiert (With ..)

Das um 76 kompletten Zeilen plus etlichen anderen überflüssigen Bytes
beraubte Script: :-)

8<--[ Code ]-->8
// program BoxQuote - Date: 2004/11/05 - Marcus Mönnig, Thomas Barghahn
// Erweiterung für Code-Box - Date: 2008/09/17 - Dietmar Vollmeier
//
Procedure Init_Boxquote ( var StartLine_close_box : String;
var StartLine_open_box : String;
var StartLine_code_box : String;
var Separator : char;
var bq1a : char;
var bq1b : char;
var bq1c : char;
var bq2a : char;
var bq2c : char;
var bq3a : char;
var bq3b : char;
var bq3c : char;
var LineWidthTop : integer;
var LineWidthBottom : integer;
var s_no_bq : integer;
var s_bq_title : integer;
var s_bq_content : integer;
var bq_title_code : String
);

begin

// --
// Configuration settings
// --

StartLine_close_box := 'Box:'; // geschlossener Rahmen
StartLine_open_box := 'Zitat:'; // offener Rahmen
StartLine_code_box := 'Code:'; // Code-Box
Separator := '-';

// --
// End of configuration settings
// --

// //
// - No user maintainable parts below this line -- //
// //

bq1a := ',';
bq1b := '-';
bq1c := '.';
bq2a := 'Š';
bq2c := 'Š';
bq3a := '`';
bq3b := '-';
bq3c := 'Ž';

LineWidthTop := 2;
LineWidthBottom := 4;

s_no_bq := 0;
s_bq_title := 1;
s_bq_content := 2;

bq_title_code := 'Code';

end;
Function S_Delete(S:String;P,L:Integer):String;
Begin
delete( S, p, l );
Result := S;
End;
function CountChars(s : String; c : Char) : Integer;
var
i : Integer;
begin
result := 0;
for i := 1 to Length( s ) do if s[i] = c then result := result + 1;
end; // function CountChars()

procedure BoxQuote( var Message : TStringlist);
var
i, j, k : Integer;
state : Word;
bq_startline : Integer;
bq_title : String;
bq_content : String;
maxwidth : Integer;
sl : Tstringlist;
CloseBox : Boolean;
CodeBox : Boolean;
StartLine_close_box : String;
StartLine_open_box : String;
StartLine_code_box : String;
Separator : Char;

bq1a : char;
bq1b : char;
bq1c : char;
bq2a : char;
bq2c : char;
bq3a : char;
bq3b : char;
bq3c : char;

LineWidthTop : integer;
LineWidthBottom : integer;

s_no_bq : integer;
s_bq_title : integer;
s_bq_content : integer;

bq_title_code : String;

begin
Init_Boxquote ( StartLine_close_box, StartLine_open_box, StartLine_code_box, Separator, bq1a,
bq1b, bq1c, bq2a, bq2c, bq3a, bq3b, bq3c, LineWidthTop, LineWidthBottom,
s_no_bq, s_bq_title, s_bq_content, bq_title_code );
state := s_no_bq;
i := 0;
bq_startline := -1;
With Message do Begin
while i <= count-1 do begin
case state of
s_no_bq: begin
if (strings[i] = StartLine_close_box)
or (strings[i] = StartLine_open_box)
or (strings[i] = StartLine_code_box)
then begin
if strings[i] = StartLine_close_box
then CloseBox := true
else CloseBox := false;
if strings[i] = StartLine_code_box
then CodeBox := true
else CodeBox := false;
bq_startline := i;
bq_title := '';
bq_content := '';
maxwidth := 1;
state := s_bq_title;
end
end;
s_bq_title: begin
if strings[i] = Separator
then begin
if CodeBox and (bq_title = '')
then bq_title := bq_title_code;
state := s_bq_content;
end
else bq_title := trim( bq_title + ' ' + strings[i] );
end;
s_bq_content: begin
if strings[i] = Separator then begin
state:=s_no_bq;
if Length( '[ ' + bq_title + ' ]' ) > maxwidth
then maxwidth := Length( '[ ' + bq_title + ' ]' ) + 6;
// delete the raw BoxQuote
for j := bq_startline to i do delete( bq_startline );
// middle part
if not CodeBox then begin
bq_content := #13#10 + bq2a + ' ' + stringreplace (bq_content, #13#10, #13#10 + bq2a + ' ',[rfReplaceAll]);
bq_content := S_Delete ( bq_content, 1, 2 );
end;
// first line
if (bq_title <> '') and not CodeBox
then bq_content := bq1a
+ StringOfChar( bq1b, LineWidthTop )
+ '[ ' + bq_title + ' ]'
+ #13#10
+ bq_content
else if (bq_title = '') and not CodeBox
then bq_content := bq1a
+ StringOfChar( bq1b, LineWidthTop )
+ #13#10
+ bq_content
else if (bq_title <> '') and CodeBox
then bq_content := '8<'
+ StringOfChar( bq1b, LineWidthTop )
+ '[ ' + bq_title + ' ]'
+ #13#10
+ bq_content
else if (bq_title = '') and CodeBox
then bq_content := '8<'
+ StringOfChar( bq1b, LineWidthTop )
+ #13#10
+ bq_content;
// last line
if Codebox
then bq_content := bq_content + #13#10 + '8<' + StringOfChar( bq3b, LineWidthBottom )
else bq_content := bq_content + #13#10 + bq3a + StringOfChar( bq3b, LineWidthBottom );
sl := Tstringlist.create;
try
sl.text := bq_content;
// close the box
if CloseBox or CodeBox then begin
for j := 0 to sl.count-1 do begin
k := maxwidth - length( sl.strings[j] );
if j = 0 then
if CodeBox
then sl.strings[j] := sl.strings[j] + StringOfChar( bq1b, k ) + '>8'
else sl.strings[j] := sl.strings[j] + StringOfChar( bq1b, k+3 ) + bq1c
else if j = sl.count-1 then
if CodeBox
then sl.strings[j] := sl.strings[j] + StringOfChar( bq3b, k ) + '>8'
else sl.strings[j] := sl.strings[j] + StringOfChar( bq3b, k+3 ) + bq3c
else if not CodeBox
then sl.strings[j] := sl.strings[j] + StringOfChar(' ', k+3) + bq2c;
end;
end;
insert( bq_startline, trim(sl.text) );
i := bq_startline;
finally
sl.free;
end;
end
else begin
if bq_content = ''
then bq_content := strings[i]
else bq_content := bq_content + #13#10 + strings[i];
if Length( strings[i] ) > maxwidth
then maxwidth := length( strings[i] );
end;
end;
end; // case
i := i + 1;
end;
end; // with Message
end; // procedure BoxQuote()
8<>8




Cu,
Hermann Hippen.
ž' š°º€ø?žžžžž?ø€º°š 'ž
ø€º° '<http://4ds.siteboard.eu>' °º€ø
'ž '40tude-Dialog Scriptwerkstatt' ž'
ø€º°' ž ž ø€º°ššššššš°º€øšž ž '°º€ø
 

Lesen sie die antworten

#1 Karl-Heinz Rademacher
10/11/2008 - 13:00 | Warnen spam
Hallo Hermann,

Hermann Hippen schrieb:
http://kh-rademacher.de/4d/Boxquote_Include-1.html

Komplett entsorgt wurden die beiden Funktionen:
StringReplaceM() & RepeatChar() und der Code wurde etwas optmiert (With ..)

Das um 76 kompletten Zeilen plus etlichen anderen überflüssigen Bytes
beraubte Script: :-)



Aha und wenn ich das nur richtig deute, dann sollte das /ganze/ Skript
auf der Seite durch

8<--[ Code ]-->8
// program BoxQuote - Date: 2004/11/05 - Marcus Mönnig, Thomas Barghahn
// Erweiterung für Code-Box - Date: 2008/09/17 - Dietmar Vollmeier



dieses hier (neu) ausgetauscht werden?


Gruß,
Karl-Heinz
,--[ Die 40tude Dialog - Seiten! ]
Š http://kh-rademacher.de/4d
Š http://kh-rademacher.de/face
`-

Ähnliche fragen