home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
das_buch
/
profiler
/
comp4.pas
< prev
Wrap
Pascal/Delphi Source File
|
1993-05-03
|
2KB
|
63 lines
(* ------------------------------------------------------ *)
(* COMP4.PAS *)
(* (c) 1993 te-wi Verlag, München *)
(* ------------------------------------------------------ *)
PROGRAM Compare_4;
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q+,R+,S+,T-,V+,X+,Y+}
{$M 16384,0,655360}
TYPE
Quality = (Lss, Gtr, Eql);
FUNCTION Compare(s1, s2 : STRING) : Quality;
VAR
sPos : INTEGER;
mPos : INTEGER;
t1, t2 : CHAR;
BEGIN
IF Length(s1) > Length(s2) THEN BEGIN
mPos := Length(s1);
s2 := s2 + #32;
END ELSE BEGIN
mPos := Length(s2);
s1 := s1 + #32;
END;
sPos := 1;
REPEAT
t1 := UpCase(s1[sPos]);
t2 := UpCase(s2[sPos]);
IF t1 = t2 THEN
IF sPos = mPos THEN BEGIN
Compare := Eql;
Exit;
END;
IF t1 < t2 THEN BEGIN
Compare := Lss;
Exit;
END ELSE IF t1 > t2 THEN BEGIN
Compare := Gtr;
Exit;
END;
Inc(sPos);
UNTIL FALSE;
END;
CONST
s1 : STRING = 'begin';
s2 : STRING = 'abs';
s3 : STRING = 'compare';
s4 : STRING = 'zappenduster';
BEGIN
WriteLn(Ord(Compare(s1, s2)));
WriteLn(Ord(Compare(s4, s1)));
WriteLn(Ord(Compare(s4, s4)));
WriteLn(Ord(Compare(s3, s4)));
END.
(* ------------------------------------------------------ *)
(* Ende von COMP4.PAS *)