41 lines
1.6 KiB
Plaintext
41 lines
1.6 KiB
Plaintext
include xpllib; \provides StrLen, ToLower, StrCopy, and StrCmp
|
|
|
|
proc StrToLower(A, B);
|
|
char A, B, I;
|
|
for I:= 0 to StrLen(B) do A(I):= ToLower(B(I));
|
|
|
|
proc CompareStrings(A, B, Sens);
|
|
char A, B, Sens, C, D;
|
|
[C:= Reserve(StrLen(A)+1);
|
|
D:= Reserve(StrLen(B)+1);
|
|
Text(0, "Comparing "); Text(0, A); Text(0, " and "); Text(0, B); Text(0, ", ");
|
|
if Sens then
|
|
[Text(0, "case sensitively:^m^j");
|
|
StrCopy(C, A);
|
|
StrCopy(D, B);
|
|
]
|
|
else [Text(0, "case insensitively:^m^j");
|
|
StrToLower(C, A);
|
|
StrToLower(D, B);
|
|
];
|
|
Text(0, " "); Text(0, A); Text(0, " < "); Text(0, B); Text(0, " -> ");
|
|
Text(0, if StrCmp(C, D) < 0 then "true" else "false"); CrLf(0);
|
|
Text(0, " "); Text(0, A); Text(0, " > "); Text(0, B); Text(0, " -> ");
|
|
Text(0, if StrCmp(C, D) > 0 then "true" else "false"); CrLf(0);
|
|
Text(0, " "); Text(0, A); Text(0, " = "); Text(0, B); Text(0, " -> ");
|
|
Text(0, if StrCmp(C, D) = 0 then "true" else "false"); CrLf(0);
|
|
Text(0, " "); Text(0, A); Text(0, " # "); Text(0, B); Text(0, " -> ");
|
|
Text(0, if StrCmp(C, D) # 0 then "true" else "false"); CrLf(0);
|
|
Text(0, " "); Text(0, A); Text(0, " <= "); Text(0, B); Text(0, " -> ");
|
|
Text(0, if StrCmp(C, D) <= 0 then "true" else "false"); CrLf(0);
|
|
Text(0, " "); Text(0, A); Text(0, " >= "); Text(0, B); Text(0, " -> ");
|
|
Text(0, if StrCmp(C, D) >= 0 then "true" else "false"); CrLf(0);
|
|
CrLf(0);
|
|
];
|
|
|
|
[CompareStrings("cat", "dog", true);
|
|
CompareStrings("Rat", "RAT", true);
|
|
CompareStrings("Rat", "RAT", false);
|
|
CompareStrings("1100", "200", true);
|
|
]
|