24 lines
646 B
Plaintext
24 lines
646 B
Plaintext
include c:\cxpl\codes; \intrinsic 'code' declarations
|
|
string 0; \use zero-terminated strings, instead of MSb terminated
|
|
|
|
func StrLen(Str); \Return the number of characters in an ASCIIZ string
|
|
char Str;
|
|
int I;
|
|
for I:= 0 to -1>>1-1 do
|
|
if Str(I) = 0 then return I;
|
|
|
|
func RevStr(S); \Reverse the order of the bytes in a string
|
|
char S;
|
|
int L, I, T;
|
|
[L:= StrLen(S);
|
|
for I:= 0 to L/2-1 do
|
|
[T:= S(I); S(I):= S(L-I-1); S(L-I-1):= T];
|
|
return S;
|
|
];
|
|
|
|
[Text(0, RevStr("a")); CrLf(0);
|
|
Text(0, RevStr("ab")); CrLf(0);
|
|
Text(0, RevStr("abc")); CrLf(0);
|
|
Text(0, RevStr("Able was I ere I saw Elba.")); CrLf(0);
|
|
]
|