SRL Archive - Reflection Development

Text.simba out of range error/fix


Harry

2011-03-03 00:09:53

I am no expert with this or anything, but I am pretty sure try/except case will stop R_GetUpText from giving out of range errors. It compiled fine and ran fine for 4 hours without issues (albeit the issue not happening frequently to begin with, but frequently enough to be annoying), and I hope it stays that way.

Try it out:
function R_GetUpText: string;
var
MenuOptions: TStringArray;
First: String;
begin
MenuOptions := GetMenuText;
try
First := Trim(MenuOptions[0]);
Result := First;
if (Length(MenuOptions) > 1) and (Result <> '') then
Result := Result+' / '+inttostr(Length(MenuOptions))+' more options';
except
WriteLn('R_GetUptext failed!');
Result := '';
end;
end;

Might be a good commit if it runs well for you – seems to fix the issue for me.

Train

2011-03-03 00:26:46

How is it possible for this function to fail, it'd be GetMenuText.

Harry

2011-03-03 00:28:53

GetMenuText results nothing at all, and then R_GetUpText tries to use [0], which does not exist, which then gives an out of range error. The try-except will fix R_GetUpText from crashing, and will instead result nothing and exit. It's a cleaner fix than making GetMenuText result something, when it really got nothing.

Train

2011-03-03 00:29:21

From: Harry
GetMenuText results nothing at all, and then R_GetUpText tries to use [0], which does not exist, which then gives an out of range error. The try-except will fix R_GetUpText from crashing, and will instead result nothing and exit.


It should re-run the GetMenuText, not just quit.

Harry

2011-03-03 00:32:24

From: Train
It should re-run the GetMenuText, not just quit.

I don't think so; it would cause the procedure to be rerun instantly which is probably not a good idea (it's a pretty bad error if GetMenuText results nothing, which could mean RS has something wrong with it and it SHOULDN'T be rerun instantly). It's rare enough to begin with, and if it happens the script will still run fine. The point of this fix is to make Simba so it doesn't crash, which is exactly what it does :)

Train

2011-03-03 00:34:09

From: Harry
I don't think so; it would cause the procedure to be rerun instantly which is probably not a good idea (it's a pretty bad error if GetMenuText results nothing, which could mean RS has something wrong with it and it SHOULDN'T be rerun instantly). It's rare enough to begin with, and if it happens the script will still run fine. The point of this fix is to make Simba so it doesn't crash, which is exactly what it does :)


I would push it to the repository, but I have yet to gain srl-reflection dev access.

Wizzup?

2011-03-03 07:02:32

From: Train
I would push it to the repository, but I have yet to gain srl-reflection dev access.


If at all, seeing your reputation here smells…

Harry, why don't you send in patch or just wait for someone with access here to commit it? :)

Train

2011-03-03 14:47:35

From: Wizzup?
If at all, seeing your reputation here smells…

Harry, why don't you send in patch or just wait for someone with access here to commit it? :)


Not everyone hates me, and SRL-reflection is at a short-hand of developers. I'm sure a few can vouch for me.

pyroryan

2011-03-03 15:00:32

From: Harry
I am no expert with this or anything, but I am pretty sure try/except case will stop R_GetUpText from giving out of range errors. It compiled fine and ran fine for 4 hours without issues (albeit the issue not happening frequently to begin with, but frequently enough to be annoying), and I hope it stays that way.

Try it out:
function R_GetUpText: string;
var
MenuOptions: TStringArray;
First: String;
begin
MenuOptions := GetMenuText;
try
First := Trim(MenuOptions[0]);
Result := First;
if (Length(MenuOptions) > 1) and (Result <> '') then
Result := Result+' / '+inttostr(Length(MenuOptions))+' more options';
except
WriteLn('R_GetUptext failed!');
Result := '';
end;
end;

Might be a good commit if it runs well for you – seems to fix the issue for me.


Try-catch/except is good practice anyways. I don't see why it should ever have an error (unless I'm missing something), but since you have the issue, I've committed your fix :). Hope it fixes it for anyone else who has it.

Bad Boy JH

2011-03-06 00:01:36

There are ways to make Walk here not appear, such as having the mouse high on the screen, with angle low, and nothing where your mouse is.
Runescape won't register a tile that far away as something it can walk to, and there are no other options resulting in GetMenuText having a length of 0.

Flight

2011-03-06 03:44:48

What ever happened to SRL's "GetUpText"? It works like a charm, so why not forget this reflection and use what we've had all along?

Harry

2011-03-06 04:05:15

From: Flight
What ever happened to SRL's "GetUpText"? It works like a charm

"Lol" is all I have to say. Color GetUpText is far from perfect and this bug has been fixed.