home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
das_buch
/
profiler
/
comp3.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-03
|
2KB
|
60 lines
(* ------------------------------------------------------ *)
(* COMP3.PAS *)
(* (c) 1993 te-wi Verlag, München *)
(* ------------------------------------------------------ *)
PROGRAM Compare_3;
{$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;
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
IF UpCase(s1[sPos]) = UpCase(s2[sPos]) THEN
IF sPos = mPos THEN BEGIN
Compare := Eql;
Exit;
END;
IF UpCase(s1[sPos]) < UpCase(s2[sPos]) THEN BEGIN
Compare := Lss;
Exit;
END ELSE IF UpCase(s1[sPos]) > UpCase(s2[sPos]) 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 COMP3.PAS *)