SRL Archive - SRL Bugs

GetChatBoxText


slushpuppy

2012-05-29 10:14:03


Output:

['Fr41m']

Shatterhand

2012-05-29 10:21:08

Wats the problem with this? I guess its not that accurate to detect spaces …

Kyle Undefined

2012-05-29 10:52:51

More information will be helpful.

Sin

2012-05-29 10:53:45

From: Kyle Undefined
More information will be helpful.


More information about giving more information would be helpful ;)

@OP, are you trying to make a caller for SW?

slushpuppy

2012-05-29 11:47:01

From: Shay
More information about giving more information would be helpful ;)

@OP, are you trying to make a caller for SW?


@shay> Yes actually

@Kyle > That's all I can give. Try it out yourself with a test sample


writeln(ChatBoxTextArray(COLOROFFC)));

I noticed that the space fontset is 3x16, whereas the space for fr4 1m is 2x16

slushpuppy

2012-05-29 13:42:06


^^ 32.bmp does not fit inbetween

Brandon

2012-05-29 14:08:48

This isn't that big a bug and it's easily solved. The bitmap for space doesn't fit there. So how to solve it?



{$I SRL/SRL.Simba}

Function IsChatBoxTextEx(RegExpr: String; Colour: Integer): Boolean;
var
I, L: Integer;
TSA: TStringArray;
begin
TSA:= ChatBoxTextArray(Colour);
L:= High(TSA);

For I:= 0 To L Do
if ExecRegExpr(RegExpr, TSA[I]) then
begin
Result:= True;
break;
end;
end;

begin
//DO NOT put spaces in the regex. Spaces are denoted by "\s" Non-white-space is denoted by "\S"
//Brackets aren't allowed unless escaped by a backslash and finally the * means to repeat the previous expression 0 or more times.


writeln(IsChatBoxTextEx('(Fr4(\s)*1m)', clBlack));

//The above Regex is equivalent to '(Fr4 1m)|(Fr41m)|(Fr4 1m)|(Fr4 1m)'... etc.. keeps going for an infinite amount of spaces.
end.

slushpuppy

2012-05-29 23:19:36

From: Brandon
This isn't that big a bug and it's easily solved. The bitmap for space doesn't fit there. So how to solve it?



{$I SRL/SRL.Simba}

Function IsChatBoxTextEx(RegExpr: String; Colour: Integer): Boolean;
var
I, L: Integer;
TSA: TStringArray;
begin
TSA:= ChatBoxTextArray(Colour);
L:= High(TSA);

For I:= 0 To L Do
if ExecRegExpr(RegExpr, TSA[I]) then
begin
Result:= True;
break;
end;
end;

begin
//DO NOT put spaces in the regex. Spaces are denoted by "\s" Non-white-space is denoted by "\S"
//Brackets aren't allowed unless escaped by a backslash and finally the * means to repeat the previous expression 0 or more times.


writeln(IsChatBoxTextEx('(Fr4(\s)*1m)', clBlack));

//The above Regex is equivalent to '(Fr4 1m)|(Fr41m)|(Fr4 1m)|(Fr4 1m)'... etc.. keeps going for an infinite amount of spaces.
end.


The biggest problem with that so called 'solution' is that people have to hardcode every single mismatch that occurs…

Brandon

2012-05-29 23:31:02

From: slushpuppy
The biggest problem with that so called 'solution' is that people have to hardcode every single mismatch that occurs…



A regex is not hardcoding.. The way your going about it is literally hardcoding. The fact that it doesn't find your exact and specific text due to a space in it, is hardcoding.

Regular Expressions are otherwise known as pattern matching. It matches a specified pattern.

For an example of a pattern than matches a TPointArray, see here: http://villavu.com/forum/showpost.php?p=1019210&postcount=3

The function is called STRToTPA. It's not hardcoded because you can enter any TPA and it will work. hardcoding is where the values must be very specific.

What I gave you is the ultimate solution. A Regular Expression to match any pattern you like. Of course you'd write your own expressions.

Some useful ones:

'[A-Za-z0-9_]' // Matches A-z, 0-9 and underscore..
'^[A-Za-z]' // Matches A-z only if at the beginning of a line..
'[0-9]*$' //Matches 0-9 any amount of times AND matches the end of a line aka linefeed.

Those are just some examples. Of course there are as many patterns as the mind can think of.

Perhaps you can describe exactly what you want and I can provide a close if not exact solution..

slushpuppy

2012-05-30 04:58:52

From: Brandon
A regex is not hardcoding.. The way your going about it is literally hardcoding. The fact that it doesn't find your exact and specific text due to a space in it, is hardcoding.

Regular Expressions are otherwise known as pattern matching. It matches a specified pattern.

For an example of a pattern than matches a TPointArray, see here: http://villavu.com/forum/showpost.php?p=1019210&postcount=3

The function is called STRToTPA. It's not hardcoded because you can enter any TPA and it will work. hardcoding is where the values must be very specific.

What I gave you is the ultimate solution. A Regular Expression to match any pattern you like. Of course you'd write your own expressions.

Some useful ones:

'[A-Za-z0-9_]' // Matches A-z, 0-9 and underscore..
'^[A-Za-z]' // Matches A-z only if at the beginning of a line..
'[0-9]*$' //Matches 0-9 any amount of times AND matches the end of a line aka linefeed.

Those are just some examples. Of course there are as many patterns as the mind can think of.

Perhaps you can describe exactly what you want and I can provide a close if not exact solution..


No amount of regex manipulation will work because the input text is wrong.


Essentially I have an access list that contain array of RSNs that grant users permissions to change calls for the team and a fair bit of ranks have rather popular names. Discarding spaces in the names can lead to unexpected access given to wrong people


Due to this problem, RSNs get read wrong because of 1px error ;x

e.g.

fr4 1m becomes fr41m

pvm2 j4ck becomes pvm2j4ck

Sir R. M8gic1an

2012-05-30 08:46:56

If the issue is the spaces, just TrimSpaces() both on what you're looking for and on what the GetText function returns. Voila.

~RM

Dgby714

2012-05-30 08:51:50

From: Sir R. M8gic1an
If the issue is the spaces, just TrimSpaces() both on what you're looking for and on what the GetText function returns. Voila.

~RM


I'm pretty sure what he is looking for is dynamic and he needs to know specifically what was said.

That aside, You could use another delimiter.

slushpuppy

2012-05-30 09:27:42

From: Dgby714
I'm pretty sure what he is looking for is dynamic and he needs to know specifically what was said.

That aside, You could use another delimiter.

I would, unfortunately I am dealing with runescape names here :( -then again it is a still a valid bug report