BUG: String.Contains and long Strings (FIXED)

Started by monkey0506, Sun 25/06/2006 19:50:13

Previous topic - Next topic

monkey0506

While trying to make a demo for my latest module, LineBreak, I encountered some strange feedback that I thought was some crazy bug in my module.

However, I have done extensive testing with Display checking things out as they are run, and the problem is actually with String.Contains.Ã,  I have even taken the problem String away from all module functions and checked the results, and finding the same problem.

I have the following code in game_start:

Code: ags
String Text = "The lines read as follows:\\LineBreak: R\\This is just some \\LineBreak: R\\example text for the \\LineBreak: R\\LineBreak module demo,\\LineBreak: R\\set up to flood the line \\LineBreak: R\\and show how the module\\LineBreak: R\\can be utilized.";
Display("Contains: %d", Text.Contains("\\LineBreak: H\\"));


There is a reason why I'm testing for "\\LineBreak: H\\" (which clearly isn't in the String) and not "\\LineBreak: R\\" (which is). The number displayed is 212.

This has caused a lot of problems with my module because it's very confused and there's some other crazy crap happening because of it.

The String I searched clearly didn't contain the String I was searching for. So why is String.Contains saying it does?Ã,  My only guess is that it has to do with the length of the String...?

[EDIT:]

Quote from: Pumaman on Sat 14/01/2006 22:47:30* Fixed String.Contains not working properly with strings >200 characters.

Fixed as of AGS 2.72 Final. Thanks Chris! ;D

Pumaman

#1
Well spotted, String.Contains doesn't work properly with strings longer than 200 characters. I'll get it fixed.

Edit by strazer:

AGS v2.72 Final:
* Fixed String.Contains not working properly with strings >200 characters.

monkey0506

#2
Ahh...thanks CJ.  This was driving me insane at first because I was trying to figure out why my module hated me. Then I realized one of my functions was returning impossible values (based upon the invalid results given due to this bug). :=

Thanks again for everything you do.

[EDIT:]

On a possibly related note the same function (as was returning impossible values which called String.Contains) crashed the game when passing a String of 344 characters with the following error message:

Code: ags
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x5C5C5220 ; program pointer is +6, ACI version 2.72.915, gtags (0,2)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.

in LineBreak (line 8)
from LineBreak (line 15)
from LineBreak (line 188)
from Room 1 script (line 15)


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.
---------------------------
OK   
---------------------------


As line 8 only contained a call to String.Contains I presume this will be fixed.  Just thought I'd let you know.

SMF spam blocked by CleanTalk