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-30-2015, 08:51 PM   #16
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by TonyMLake
Well, the first problem I MIGHT see is that the file is only looking for COMMA, but not looking out for double quotes.
If that were the problem then val() would return a value of err that is greater than 0. Err would be the position of the double quote, an illegal character, in the string. The function would than return 0 which is not out of range.

Quote:
Originally Posted by TonyMLake
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
Code:
846 .. 855 : past[i - 845].speed := abs(get_int(f)) ;	// the offending line
__________________
Sapere aude

Last edited by Actor; 07-30-2015 at 08:52 PM.
Actor is offline   Reply With Quote Reply
Old 07-30-2015, 08:57 PM   #17
DLigett
Registered User
 
DLigett's Avatar
 
Join Date: Aug 2014
Posts: 34
So if a comma or two is missing from the file, get_int() might return 999999 (longint) and try to stuff it into a simple integer?

I don't know the size of a longint in Free Pascal.

In get_int() you could test for size 32767 and squawk. Try on a known bad file.
DLigett is online now   Reply With Quote Reply
Old 07-30-2015, 09:06 PM   #18
vegasone
Registered User
 
Join Date: Aug 2007
Posts: 531
One of the tracks, either EMD or EVD (I think) keeps coming up with a funky speed rating something like 1781 which may be causing your problem. I would have to run into it again to know for sure but it is consistently one track.
vegasone is offline   Reply With Quote Reply
Old 07-30-2015, 09:26 PM   #19
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Quote:
Originally Posted by Actor
If that were the problem then val() would return a value of err that is greater than 0. Err would be the position of the double quote, an illegal character, in the string. The function would than return 0 which is not out of range.


Code:
846 .. 855 : past[i - 845].speed := abs(get_int(f)) ;	// the offending line

What does this display?

Code:
until ch = COMMA ;
        ShowMessage(str);
	val(str, i, err) ;
__________________
http://www.HandicapperPlus.com
TonyMLake is offline   Reply With Quote Reply
Old 07-30-2015, 09:44 PM   #20
DLigett
Registered User
 
DLigett's Avatar
 
Join Date: Aug 2014
Posts: 34
Quote:
Originally Posted by TonyMLake
What does this display?

Code:
until ch = COMMA ;
        ShowMessage(str);
	val(str, i, err) ;
I vote for...

if i > 32767 then ShowMessage(str + ' will break our caller');
DLigett is online now   Reply With Quote Reply
Old 07-30-2015, 11:04 PM   #21
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Quote:
Originally Posted by DLigett
I vote for...

if i > 32767 then ShowMessage(str + ' will break our caller');
Good point, and if that parser throws something "weird" based on it being a garbage input, that could happen.

THEREFORE, call the "ShowMessage" right before the val(str, i, err) ; statement, like the last snippet, up above.
__________________
http://www.HandicapperPlus.com
TonyMLake is offline   Reply With Quote Reply
Old 07-30-2015, 11:04 PM   #22
headhawg
crusty old guy
 
headhawg's Avatar
 
Join Date: Aug 2003
Location: Snarkytown USA
Posts: 3,914
Quote:
Originally Posted by ebcorde
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.
Bris had in embedded commas in the field that had foreign race comments. (I can't recall the field number.) They would be in some of the Cali track files. I don't know if that's been fixed as it's been years since I looked at it. I think I have also seen them in owner's name or the race name fields as well (can't remember which). It drove me nuts. Wrote a routine to count the number of commas so I knew which files had extras.
headhawg is offline   Reply With Quote Reply
Old 07-30-2015, 11:09 PM   #23
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Quote:
Originally Posted by headhawg
Bris had in embedded commas in the field that had foreign race comments. (I can't recall the field number.) They would be in some of the Cali track files. I don't know if that's been fixed as it's been years since I looked at it. I think I have also seen them in owner's name or the race name fields as well (can't remember which). It drove me nuts. Wrote a routine to count the number of commas so I knew which files had extras.
That's not actually an error (although you're right that Brisnet has a few errors but not as many as Formulator). Commas are legitimate input in .csv files, which is why you need a secondary text delimiter, hence text is enclosed in double quotes to tell applications (or application developers) to ignore the commas within the first and second double quote.

Of course, it doesn't have to be commas, and it doesn't have to be double quotes, but those are common delimiters.

This is common:

32, 45, T, F, "All American Race", 45, 92.3, 0,,,,"First Race Ever, Tired Old Cows", "Scott Stephens", n,,"", *,2

Note the comma in the text field between the double quotes. That's the only way to tell the app it's not a new field, so, it was designed that way.
__________________
http://www.HandicapperPlus.com

Last edited by TonyMLake; 07-30-2015 at 11:12 PM.
TonyMLake is offline   Reply With Quote Reply
Old 08-04-2015, 10:40 PM   #24
TonyMLake
Registered User
 
TonyMLake's Avatar
 
Join Date: Jul 2014
Location: Tucson, AZ
Posts: 187
Whatever became of this, Actor?
__________________
http://www.HandicapperPlus.com
TonyMLake is offline   Reply With Quote Reply
Old 08-05-2015, 03:35 AM   #25
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by TonyMLake
Whatever became of this, Actor?
Sorry if I seem to have dropped out of sight.

I've been forced to put it on hold for a while. The tenant of one of my rental houses has moved out and left the place a mess. You would not believe how much of a mess he left. I've been working trying to clean up the place enough so that I can go to work with a mop and broom, plus repair some damage.

I do appreciate everyone's input.
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 08-06-2015, 03:38 PM   #26
DJofSD
Screw PC
 
Join Date: Jun 2003
Posts: 15,728
Here's some code excerpts from an old, old program I wrote years ago using Delphi V1. It reads single file BRIS files. It treats all data tokens as strings and anything that is converted to numeric values is done elsewhere in the app. It has never failed to correctly parse a BRIS data file.

Code:
var
  Form1: TForm1;
  SrcFile: System.Text;   {regular ascii text file}
  F, revF: String;
  s0: string; {initial input string}
  ss: array[1..1436] of String; {input string broken out into substrings}
.....

const
  NULL: String = ''; // match what BASIC produces
  MAXTOKENS: Integer = 1435;
  MAXBRISPPRACES: Integer = 10; // BRIS has 10 pace lines per horse
  DOT: String = '.';
  BLANK: String = ' ';
.....

procedure TForm1.sparser2;
// destructive - modifies string s0
var
  sstoken, fchar, endquote, nextcomma: Integer;
  ls, lt: Integer;
const
  QUOTE: String = #34; { a double quotation mark '"' -- deer track}
  COMMA: String = #44;
  TERM: String = #34#44; { an end of a string '",' }
begin
  fchar := 1;
  for sstoken := 1 to MAXTOKENS do begin
    ls := Length(s0);
    if Copy(s0, 1, 1) = QUOTE then {this token is a BASIC string}
      begin
      endquote := Pos(TERM, s0); {find matching '",'}
      if sstoken = MAXTOKENS then {endquote should be zero}
        begin
        ss[sstoken] := Copy(s0, 2, ls - 2);
        Inc(currentlinetokens);
        break; {leave the for loop, clean up and return}
        end
      else
        begin
        if endquote - fchar > 1 then {more than just '"",', i.e. not a null}
          begin
          ss[sstoken] := Copy(s0, 2, endquote - 2);
          Inc(currentlinetokens);
          {remove token from s0 from '"' to '",' inclusive}
          Delete(s0, 1, endquote + 1);
          end
        else {nothing inbetween, just '"",', assign null }
          begin
          ss[sstoken] := NULL; // 'NULL STRING ' + IntToStr(sstoken);
          Inc(currentlinetokens);
          Delete(s0, 1, 3);
          end
        end
     end
    else {this token not a BASIC string (no '"' as 1st char);
           could be numeric (keep as characters) or null string,
           i.e. just a comma}
      begin
        nextcomma := Pos(COMMA, s0);
        lt := nextcomma - 1;
        if lt > 0 then
          ss[sstoken] := Copy(s0, 1, nextcomma - 1)
        else
          ss[sstoken] := NULL; // 'NULL TOKEN ' + IntToStr(sstoken);
        Inc(currentlinetokens);
        Delete(s0, 1, nextcomma);
      end
  end;
end; // end proc sparser2

procedure TForm1.getallBRISdata;
// read input .DRF file, parse records and insert into StringGrid1 (ALL DATA)
var
  icol, j: Integer;
begin
  TotalRaces := 0; // before any lines read, no races
  while not eof(SrcFile) do begin
    Inc(passes); { count the number of times through the loop }
    Readln(SrcFile, s0); {read a line}
    Inc(TotalBytes, Length(s0)); { count total number of bytes read }
    currentlinetokens := 0;
    sparser2;
.....
__________________
Truth sounds like hate to those who hate truth.
DJofSD is offline   Reply With Quote Reply
Old 08-07-2015, 02:34 PM   #27
Red Knave
dGnr8
 
Red Knave's Avatar
 
Join Date: Aug 2003
Location: Niagara, Ontario
Posts: 3,023
Quote:
Originally Posted by Actor
So I changed the variable to a signed integer. That should have cured the problem. It did not.
Not knowing much about this language (although I'm knocked out that it is free with all the bells and whistles it has) is "signed integer" the same as "longint"?
It seems pretty obvious that it is the assignment of the result of the get_int function that is throwing the error so are you sure you changed the type of right var?
__________________
.
The great menace to progress is not ignorance but the illusion of knowledge - Daniel J. Boorstin

The takers get the honey, the givers sing the blues - Robin Trower, Too Rolling Stoned - 1974
Red Knave is offline   Reply With Quote Reply
Old 08-07-2015, 09:44 PM   #28
Actor
Librocubicularist
 
Join Date: Jun 2010
Location: Ohio
Posts: 10,466
Quote:
Originally Posted by Red Knave
Not knowing much about this language (although I'm knocked out that it is free with all the bells and whistles it has) is "signed integer" the same as "longint"?
  • Signed integer is 16 bits denoting the range -32768 .. 32767. The language uses integer.
  • Unsigned integer is 16 bits denoting the range 0 .. 65535. The language uses word.
  • longint is 32 bits denoting the range -2147483648 .. 2147483647
Quote:
Originally Posted by Red Knave
It seems pretty obvious that it is the assignment of the result of the get_int function that is throwing the error so are you sure you changed the type of right var?
Yes.
__________________
Sapere aude
Actor is offline   Reply With Quote Reply
Old 08-07-2015, 11:12 PM   #29
DLigett
Registered User
 
DLigett's Avatar
 
Join Date: Aug 2014
Posts: 34
Quote:
Originally Posted by Actor
  • Signed integer is 16 bits denoting the range -32768 .. 32767. The language uses integer.
  • Unsigned integer is 16 bits denoting the range 0 .. 65535. The language uses word.
  • longint is 32 bits denoting the range -2147483648 .. 2147483647
Yes.
Right, the function returns a longint, and stuffs it into the integer '.speed' which will fail once in a while.
DLigett is online now   Reply With Quote Reply
Old 08-08-2015, 10:44 AM   #30
Red Knave
dGnr8
 
Red Knave's Avatar
 
Join Date: Aug 2003
Location: Niagara, Ontario
Posts: 3,023
Quote:
Originally Posted by Actor

  • longint is 32 bits denoting the range -2147483648 .. 2147483647
Can you change the .speed type to longint, turn on range checking, retry with a 'bad' data file and display the results so you can see the offending value?
__________________
.
The great menace to progress is not ignorance but the illusion of knowledge - Daniel J. Boorstin

The takers get the honey, the givers sing the blues - Robin Trower, Too Rolling Stoned - 1974
Red Knave 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
» Current Polls
Wh deserves to be the favorite? (last 4 figures)
Powered by vBadvanced CMPS v3.2.3

All times are GMT -4. The time now is 09:47 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.