4 function space ( n
:integer):string ;
5 function replicate(ch
:char; n
:integer):string ;{cä®à¬¨à®¢ âì áâபã}
6 function trim (str
:string ):string ;
7 function center (str
:string;n
:integer):string ;
8 function UpSt ( s
:string ):string;
9 function LoSt ( s
:string ):string;
10 function lpad ( s
:string;n
:integer;c
:char):string;
11 function rpad ( s
:string;n
:integer;c
:char):string;
12 function addbackslash(p
: string) : string;{à ¡®â á ¨¬¥¥¬ path}
13 function match (sm
: string; var st
: string) : boolean;
14 function lines (p
, l
, s
: longint) : string;
15 function LoCase (c
: char) : char;
16 function JustPathname(PathName
: string) : string;
17 function JustFileName(PathName
: string) : string;
18 function JustName (PathName
: string) : string;
19 function CRC16 (s
: string) : system
.word;
28 for i
:=1 to n
do tempstr
:=tempstr
+' ';
37 for i
:=1 to n
do tempstr
:=tempstr
+ch
;
45 if length(str
) > 1 then begin
47 while str
[j
] = ' ' do inc(j
);
49 while str
[i
] = ' ' do dec(i
);
50 trim
:= copy(str
, j
, i
- j
+ 1);
57 j
:= n
- length(trim(str
));
58 if j
> 0 then tempstr
:= space(j
- j
div 2) + trim(str
) + space(j
div 2)
59 else tempstr
:= trim(str
);
68 for i
:= 1 to length(s
) do t
:= t
+ UpCase(s
[i
]);
77 for i
:= 1 to length(s
) do t
:= t
+ LoCase(s
[i
]);
83 lpad
:= replicate(c
, n
- length(s
)) + s
;
88 rpad
:= s
+ replicate(c
, n
- length(s
));
91 function addbackslash
;
94 if p
[length(p
)] = '\' then addbackslash
:= p
95 else addbackslash
:= p
+ '\'
96 else addbackslash
:= p
;
99 function match(sm
: string; var st
: string) : boolean;
105 if (length(sm
) > 0) and (length(st
) > 0) then begin
108 while pos(_sm
, _st
) > 0 do begin
111 _st
:= copy(_st
, 1, p
- 1) + copy(_st
, p
+ length(_sm
), 250);
112 st
:= copy( st
, 1, p
- 1) + copy( st
, p
+ length( sm
), 250);
124 n
:= p
* s
* 2 div l
;
125 o
:= replicate('Û', i
);
126 if n
> i
* 2 then o
:= o
+ 'Ý';
127 lines
:= o
+ space(s
- length(o
));
128 end else lines
:= '';
134 if (c
>= 'A') and (c
<= 'Z') then t
:= chr(ord(c
) + 32)
139 function JustPathname(PathName
: string) : string;
140 {-Return just the drive:directory portion of a pathname}
144 I
:= Succ(Word(Length(PathName
)));
147 until (PathName
[I
] in ['\',':',#0]) or (I
= 0);
150 {Had no drive or directory name}
153 {Either the root directory of default drive or invalid pathname}
154 JustPathname
:= PathName
[1]
155 else if (PathName
[I
] = '\') then begin
156 if PathName
[Pred(I
)] = ':' then
157 {Root directory of a drive, leave trailing backslash}
158 JustPathname
:= Copy(PathName
, 1, I
)
160 {Subdirectory, remove the trailing backslash}
161 JustPathname
:= Copy(PathName
, 1, Pred(I
));
163 {Either the default directory of a drive or invalid pathname}
164 JustPathname
:= Copy(PathName
, 1, I
);
167 function JustFilename(PathName
: string) : string;
168 {-Return just the filename of a pathname}
172 I
:= Succ(Word(Length(PathName
)));
175 until (I
= 0) or (PathName
[I
] in ['\', ':', #0]);
176 JustFilename
:= Copy(PathName
, Succ(I
), 64);
179 function JustName(PathName
: string) : string;
180 {-Return just the name (no extension, no path) of a pathname}
184 PathName
:= JustFileName(PathName
);
185 DotPos
:= Pos('.', PathName
);
187 PathName
:= Copy(PathName
, 1, DotPos
-1);
188 JustName
:= PathName
;
192 function CRC16(s
: string) : system
.word; { By Kevin Cooney }
198 for t
:= 1 to length(s
) do
200 crc
:= (crc
xor (ord(s
[t
]) shl 8));
202 if (crc
and $8000)>0 then
203 crc
:= ((crc
shl 1) xor $1021)
207 CRC16
:= (crc
and $FFFF);