SRL Archive - Help and Support

getting name from chat without ":"


XcanadamanX

2007-03-04 11:16:38

im trying to get a person's name from the chat without the ":" this iswhat i tried but i seem to keep getting a type mismatch
  OldLine := TheLine;
Name := lowercase(trim(GetTextAtEx(20, 415, 45, SmallChars, False, False, 0, 2, 0, 40, True, tr_NormalChars)));
NameL := Length(Name)
writeln(inttostr(namel))
//TheName := Delete(Name,(NameL-1),NameL)
TheLine := lowercase(trim(GetTextAtEx(20, 415, 45, SmallChars, False, False, 0, 2, 16711680, 40, False, tr_NormalChars)));
NewLine := TheLine;
//writeln(TheName)

here is the command im using to delete the :
procedure delete(var s: string; ifrom, icount: Longint): string; - delete part of string.

any ideas? i see that it says procedure instead of function but it says it returns a string:confused:

Yakman

2007-03-04 11:55:00

i think thats the scar manual is wrong,
Delete doesnt return anything, it changes the acctual string you give it

XcanadamanX

2007-03-04 12:30:08

do you know a command that i could use to delete the :? or do i have to make my own? i really dont feel like making my own.

edit: would something like

TheName:= (copy(Name,1,(NameL-1)))
work?
NameL is the length of the name.

edit: tried that but i repeated it and these are my results:
a aheimfan4
12
a aheimfan4
12
anaheim an4

real name: anaheimfan4

Junior

2007-03-04 12:56:56

try this.
thename := copy(name, 1, length(name) - 1);

XcanadamanX

2007-03-04 13:00:16

this is what im going to try:
Function DeleteC(text:string):string;
var
i: Integer;
Begin
for i := 1 to Length(Text) do
begin
if (Copy(Text,i,1)=':') then break;
end;
result:=(copy(text,1,(i-1)))
end;

ill try yours if mine doesnt work.

edit: mines working good. im going to try your to see if its better.

Junior

2007-03-04 13:02:08

Mine delets the last character of the string, isnt that what you want? I think your making it too complicating making another whole function for it.

bullzeye95

2007-03-04 13:03:03

function GetName(Name: String): String;
begin
if(copy(Name, Length(Name), 1) <> ':')then
begin
Result:= Name;
exit;
end;
Name:= copy(Name, 0, Length(Name) - 1);
Result:= Name;
end;

EDIT: Man, you guys beat me :p

XcanadamanX

2007-03-04 13:21:20

i dont think im making it complicated. im just making it more complicated then your doing…lol. ya thats what i want it to do.

bullzeye95

2007-03-04 13:28:20

Mine's the best
/arrogant

Sumilion

2007-03-04 13:40:16

teh pownage!

  Name:='Sumilion:';
Delete(Name, Pos(':', Name), 1);
Writeln(Name);

No one beats a dev, muhahahaha

Wizzup?

2007-03-04 14:04:56

Okay guys, this is the fastest and more simple way.

If FindColor the blue color then
Function GetName: String;
Begin
Result := Trim(GetTextAtEx(20, 415, 0, SmallChars, False,
False, 0, 1, 0, 80, False, tr_AllChars));
Delete(Result, Length(Result), 1);
End;

Sumilion

2007-03-04 14:08:12

Showoff… mine works too.

XcanadamanX

2007-03-04 14:17:06

thanks guys!;)

Wizzup?

2007-03-04 14:23:29

From: Sumilion
Showoff… mine works too.


No one beats an admin.

Sumilions can be used for ohter stuff to, however, this one is more clean. :p

~ Wizzup?

Sumilion

2007-03-04 14:24:43

Pttssss, it was just an example, it was pretty clear he knew how to get the name.

XcanadamanX

2007-03-04 18:28:01

thanks again. using wizzup?'s right now…works great. maybe next time sumillion lol.;)

Wizzup?

2007-03-05 03:12:29

From: XcanadamanX
thanks again. using wizzup?'s right now…works great. maybe next time sumillion lol.;)


Just remember to make sure there is actually someone chatting. ;)
(If you don't it will take something like, you swing you pick at the roc (without K)
Anyway, I indeed think it's clear now. :)

TOB

2007-03-06 14:43:11

{*******************************************************************************
function LastChatter(var name: String): Boolean;
By: masquerader
Description:
*******************************************************************************}

function LastChatter(var name: string): Boolean;
var
i: Integer;
begin
name := LowerCase(Trim(GetTextAtEx(21, 415, 0, SmallChars, False, False, 0, 0,
0, 50, False, tr_allChars)))
i := Pos(':', name)
if (i <> 0) then
begin
Delete(name, i, i);
Result := True;
end;
end;

That also checks to make sure it was a chat message because of

    i := Pos(':', name)
if (i <> 0) then


checks to make sure a colon is in the message.

The manual helps. ;)