Horse Racing Forum - PaceAdvantage.Com - Horse Racing Message Board

Go Back   Horse Racing Forum - PaceAdvantage.Com - Horse Racing Message Board > Off Topic > Off Topic - Computers


Reply
 
Thread Tools Rate Thread
Old 07-29-2015, 07:06 PM   #1
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Range check error

I've recently written a program that uses the BRIS comma delimited Single File. It works but about 3% of the time the program crashes with a "range check error." I've traced the problem to fields 846 .. 855 "BRIS Speed Rating." In my program this variable is an untyped integer. Using LibreOffice I've examined the data that causes the crashes. It seems to be caused because the BRIS Speed Rating goes negative. So I changed the variable to a signed integer. That should have cured the problem. It did not.

I've gotten around the problem by turning automatic range checking off. But the problem still bugs me (no pun intended). So does anyone have any ideas of how this problem might defy a cure. I've over and over my code and can find no reason that the problem should exist.
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 07-29-2015, 08:57 PM   #2
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Quote:
Originally Posted by Actor
I've recently written a program that uses the BRIS comma delimited Single File. It works but about 3% of the time the program crashes with a "range check error." I've traced the problem to fields 846 .. 855 "BRIS Speed Rating." In my program this variable is an untyped integer. Using LibreOffice I've examined the data that causes the crashes. It seems to be caused because the BRIS Speed Rating goes negative. So I changed the variable to a signed integer. That should have cured the problem. It did not.

I've gotten around the problem by turning automatic range checking off. But the problem still bugs me (no pun intended). So does anyone have any ideas of how this problem might defy a cure. I've over and over my code and can find no reason that the problem should exist.
Could be several things. For one thing, brisnet does in fact have errors on occasion, just so you know. DRF Formulator has even more errors.

In any case, post your code.
__________________
http://www.HandicapperPlus.com
TonyMLake is offline   Reply With Quote Reply
Old 07-29-2015, 11:39 PM   #3
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by TonyMLake
Could be several things. For one thing, brisnet does in fact have errors on occasion, just so you know. DRF Formulator has even more errors.

In any case, post your code.
It's hundreds of lines but ...
Code:
846 .. 855 : past[i - 845].speed := abs(get_int(f)) ;	// the offending line
Code:
function get_int (var f : text) : longint ; // read longint from comma delimited file
CONST
	COMMA	=	',' ;
var
	ch	:	char ;
	err	:	word ;
	i	:	longint ;
	str	:	string ;
begin //  get_int
	str := '' ;
	repeat
		read(f,ch) ;
		if ch <> COMMA then
			str := str + ch
	until ch = COMMA ;
	val(str, i, err) ;
	if err = 0 then
		get_int := i
	else
		get_int := 0
end ; //  get_int
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 07-30-2015, 12:14 PM   #4
DLigett
Registered User
 
DLigett's Avatar
 
Join Date: Aug 2014
Posts: 34
Not sure if you're using Delphi or some other version of Pascal. My versions of Delphi want 'err' to be an integer.
DLigett is online now   Reply With Quote Reply
Old 07-30-2015, 01:11 PM   #5
ebcorde
Veteran
 
Join Date: Feb 2009
Posts: 1,950
I've never seen that problem

Currently I'm using Java, used to use C++. I looked at my code, if it's happening I would have a zero, because I check for a value 0 or less and move on. I could be wrong took me 2 days to write.

Their file is horrendous. Like some kid's software generated the BRIS file.

why would it be a negative number?

A few months ago I noticed their Stud fee's are incorrect. I verified it by comparing the PP generator to my putput and has the same result. If you choose a race where the horses have the same sire. example Empire Maker, he'll have a stud fee for one horse and a stud fee of zero for the other. I called them pointed it out 3 months ago.. NO FIX.
ebcorde is offline   Reply With Quote Reply
Old 07-30-2015, 01:27 PM   #6
ebcorde
Veteran
 
Join Date: Feb 2009
Posts: 1,950
abs()

yes, it is possible to have a negative , I have seen it, but I roll it to 0. I dont think it's hurting me. usually I think it means the horse did not finish the race, Jockey fell off .

abs() if you have a -9 you make it a 9.

I guess a negative number means he was that bad? Still do not understand why they go below 0. In your case abs() on a -78 gives you a 78?

Also I believe their Jockey/Trainer combo at the meet and elsewhere are inaccurate, I've compared it to equibase and noticed it does not match up.
They probably have different rules. Equibase will start new stats. Example Mountaineer takes 2 months off and they zero the stats out. WTF
But I have not looked at that in a few years, so who knows maybe it's me.
ebcorde is offline   Reply With Quote Reply
Old 07-30-2015, 02:50 PM   #7
DLigett
Registered User
 
DLigett's Avatar
 
Join Date: Aug 2014
Posts: 34
Other things to check:

1) How is '.speed' defined -- can it accept values over 100?

2) How is past[] defined -- subscripts 1..10 or 0..9 or ???

3) What is i when the statement is executed?

4) If the file is a total mess, with 65535 characters before a comma, then 'str' can grow to be over 65535 characters -- and 'err' can't contain a number that large.

5) If the file is a total mess, what happens if you get to the end-of-file without finding a single comma?

What compiler are you using? Do you have a decent debugger?
DLigett is online now   Reply With Quote Reply
Old 07-30-2015, 04:21 PM   #8
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Well, the first problem I MIGHT see is that the file is only looking for COMMA, but not looking out for double quotes.

Remember, the comma character does not ALWAYS indicate a new field... when a comma is inside double quotes it doesn't indicate a new field, and thus your field count would be off on the times that there was a sentence like "First time Lasix, under 121 add 2" (any text with a comma in it) preceding your target field because the comma inside the quotation marks... HOWEVER, this may not be a problem. It depends on how you're calling get_int.

Please post the line that calls "get_int".


Thanks
__________________
http://www.HandicapperPlus.com
TonyMLake is offline   Reply With Quote Reply
Old 07-30-2015, 04:37 PM   #9
ebcorde
Veteran
 
Join Date: Feb 2009
Posts: 1,950
I have no idea what language your using

but it's most likely your off by a comma thereby the data set has what appears to be much larger numbers.


I've never seen comma within a string yet, else my program would not be working, it works 99.9% of the time I wrote it 4 years ago. Too lazy to track Bris's mess ups.

when I did write it, they did not fill in data so your file WILL look like this ,,,,,,,, at various points.
there's no terminating character or 0 where a numeric is concerned so you have to check for a NULL after capturing data between the commas. Don't assume there's data there. You probably are already aware of that.

I don't know what language your using , if it's a PHP type language print out the contents of each field say after count 840 to see the contents.
ebcorde is offline   Reply With Quote Reply
Old 07-30-2015, 07:53 PM   #10
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by DLigett
Not sure if you're using Delphi or some other version of Pascal. My versions of Delphi want 'err' to be an integer.
It's Free Pascal. Err is supposed to be type word, i.e., unsigned integer.
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 07-30-2015, 08:14 PM   #11
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by ebcorde
yes, it is possible to have a negative , I have seen it, but I roll it to 0. I dont think it's hurting me. usually I think it means the horse did not finish the race, Jockey fell off .

abs() if you have a -9 you make it a 9.

I guess a negative number means he was that bad? Still do not understand why they go below 0. In your case abs() on a -78 gives you a 78?
-78 is bad. +78 may not be very bad depending on the company he's running with. That's why I'd rather use max(speed,0)
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 07-30-2015, 08:31 PM   #12
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
It's likely that it's not looking at the correct field based on the code you posted above. There are literally probably dozens of fields that could have a comma in them on occasion. At one quick glance I see fields 10, 162, 240 - 248, 396-405, and probably lots more wherein a comma MAY not mean a new field, and this is probably the issue.

There's a small possibility you're looking at the correct field when the error occurs and it really is a parsing problem, but that seems less likely... parsers are pretty good if it's "close enough" to a number.

But then, we don't know, so we should check by simply

remember to
Code:
uses 
  Dialogs;

then add
Code:
ShowMessage(str);
in your get_int function

So your code would look like


Code:
uses 
  Dialogs;

function get_int (var f : text) : longint ; // read longint from comma delimited file
CONST
	COMMA	=	',' ;
var
	ch	:	char ;
	err	:	word ;
	i	:	longint ;
	str	:	string ;
begin //  get_int
	str := '' ;
	repeat
		read(f,ch) ;
		if ch <> COMMA then
			str := str + ch
	until ch = COMMA ;
	val(str, i, err) ;
	if err = 0 then
		get_int := i
	else
		get_int := 0
        ShowMessage(str)
end ; //  get_int

Insert that, then run the app with a known BAD DRF file. Check to make sure what it displays does in fact look like the field you had in mind... I'm betting it's gonna be a blank field, or a text field, or somehow pointing at the wrong field - but even if I'm wrong we'll be able to take a look at what it's choking on.

Run that and let us know what happens....
__________________
http://www.HandicapperPlus.com

Last edited by TonyMLake; 07-30-2015 at 08:34 PM.
TonyMLake is offline   Reply With Quote Reply
Old 07-30-2015, 08:34 PM   #13
ebcorde
Veteran
 
Join Date: Feb 2009
Posts: 1,950
oh I see old old Pascal

function get_int (var f : text) : longint ; // read longint from comma delimited file
CONST
COMMA = ',' ;
var
ch : char ;
err : word ;
i : longint ;
str : string ;
begin // get_int
str := '' ;
repeat
read(f,ch) ;

/****************************************
should only be ch 0-9 ans COMMA only if get_int
WHAT HAPPENS IF YOU PULL A COMMA IN WITHOUT LOADING STR?
*****************************/
if ch <> COMMA then
str := str + ch
until ch = COMMA ;
val(str, i, err) ;
if err = 0 then
get_int := i
else
get_int := 0
end ; // get_int


lots of ways to skin this cat
been years since I looked at pascal, but I see nothing wrong, BRIS file does inform you the maxmumn of each field , you could pass it in, in this cas field size max is 3. still think your somehow miscounting comma or some unseen control characters are in the file




this is how I did it in Java. before parsing the field. it's the same as what you did.

// DataBaseModule myDatabaseModule = new DataBaseModule("test","root","hollywood"," ");
//read comma separated file line by line
while( (strLine = br.readLine()) != null)
{
String[] tokens = strLine.split(","); // comma is the separator.
// System.out.println( java.util.Arrays.toString(tokens));
lineNumber++;
st = new StringTokenizer(java.util.Arrays.toString(tokens), ",", false);

while(st.hasMoreTokens())
{
tokenNumber++;
//System.out.println(tokenNumber + " " + lineNumber +" " + st.nextToken());
dc.fill(tokenNumber,lineNumber,st.nextToken());
}
tokenNumber = 0;
}

Last edited by ebcorde; 07-30-2015 at 08:43 PM.
ebcorde is offline   Reply With Quote Reply
Old 07-30-2015, 08:38 PM   #14
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by DLigett
Other things to check:

1) How is '.speed' defined -- can it accept values over 100?
Code:
type performance = record
     date   : string[8] ;
     race   : byte ;
     speed : integer ;
     // etc, etc
end ;
It's a signed integer -32768 .. 32767

Quote:
Originally Posted by DLigett
2) How is past[] defined -- subscripts 1..10 or 0..9 or ???
0 .. 10. 0 corresponds to today's race. Past[0].speed is always zero since it's not part of the file.

Quote:
Originally Posted by DLigett
3) What is i when the statement is executed?
846 .. 855

Quote:
Originally Posted by DLigett
4) If the file is a total mess, with 65535 characters before a comma, then 'str' can grow to be over 65535 characters -- and 'err' can't contain a number that large.
The string can only grow to a length of 255. Any attempt to make it larger is truncated. A string that large would cause err to be greater than zero and the error handling routine would cause get_int to return 0.

Quote:
Originally Posted by DLigett
5) If the file is a total mess, what happens if you get to the end-of-file without finding a single comma?
It's not happening. I once had a routine that would return a comma should eoln or eof be encountered but eventually decided it was not worth the trouble.

Quote:
Originally Posted by DLigett
What compiler are you using? Do you have a decent debugger?
Free Pascal. No.
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 07-30-2015, 08:44 PM   #15
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Actor, we're just going to have to know the contents of "str" before the function returns.

See my snippet above.

EDIT: Oh.. and if it's choking BEFORE it returns, put the ShowMessage call before the parsing statement in get_int.

Like

Code:
 until ch = COMMA ;
        ShowMessage(str);
	val(str, i, err) ;
	if err = 0 then
		get_int := i
	else
		get_int := 0
__________________
http://www.HandicapperPlus.com

Last edited by TonyMLake; 07-30-2015 at 08:53 PM.
TonyMLake is offline   Reply With Quote Reply
Reply




Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

» Advertisement
Powered by vBadvanced CMPS v3.2.3

All times are GMT -4. The time now is 09:29 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 1999 - 2023 -- PaceAdvantage.Com -- All Rights Reserved
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program
designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.