SRL Archive - Research & Development Lounge

convert caps


Waddo

2008-08-25 21:50:02

program New;

function ConvertCaps(word:string):string;
var
i:integer;
begin
for i := 1 to high(word) do
if inrange(ord(word[i]),65,90) then
result:=result+chr(ord(word[i])+32)
else
result:=result+word[i];
end;

begin
writeln(convertcaps('Hello'));
end.

input 'Hello'

output 'hello'



program New;

function TrimCaps(word:string):string;
var
i:integer;
begin
for i := 1 to high(word) do
if not inrange(ord(word[i]),65,90) then
result:=result+word[i]
end;

begin
writeln(trimcaps('Hello'));
end.

input 'Hello'

ouput 'ello'

bullzeye95

2008-08-25 22:47:24

For the first one, why not just use lowercase?

Method

2008-08-25 22:49:58

You also use TrimCaps for both instead of ConvertCaps in the first one.

bullzeye95

2008-08-25 22:51:12

From: Method
You also use TrimCaps for both instead of ConvertCaps in the first one.


No you couldn't?

Method

2008-08-25 22:53:52

From: bullzeye95
No you couldn't?


His first post clearly says writeln(trimcaps('Hello')); in the main loop. So yes, he could and yes, he did.

bullzeye95

2008-08-25 23:13:52

That was a copy and paste mistake…

Method

2008-08-25 23:15:52

From: bullzeye95
That was a copy and paste mistake…


Which is why I mentioned that he used one instead of the other.

Da 0wner

2008-08-26 01:49:41

:rolleyes:


function ConvertCaps(s : string) : string;
begin
result := lowercase(s);
end;

randy marsh

2008-08-26 04:01:04

u should be a dev!

Nava2

2008-08-26 09:56:49

For the first, LowerCase is faster because its delphi, and for the second there doesn't seem to be a useful function for that.

All that you do is delete capitals, which would render any string useless. Even for uptext finding you can't use that, you CAN use it if its in a TSA though.

mixster

2008-08-28 06:51:30

Waddo: You stole a mixture of mine and Widget's function for TrimCaps. Thanks for the credit.
Useful for UpText finding based on NPC's full name.