Board index » delphi » Newbie needs help - TNM Plugin programming

Newbie needs help - TNM Plugin programming

I am doing a course at college (National Diploma in Computer Studies) which
involves programming. Please take into account that I only started the course
in September. However, I've found that the stuff we're doing in class isn't the
kind of thing I need at the moment, so I'm making my own way through.
At the moment, I am working on a program for TNM (the wrestling simulator -
www.tnm7.com) to generate a tag team list. I have written the program, but when
it tries to open the file containing the tag team info, I get Error 100 - a
disk read error.
Can anyone out there help me ? Here are my program and a clip from the file
which I am attempting to read.
NOTE: I did not make TNM, so I don't know what the various fields in it's
generated files mean. I just made assumptions, as I only needed to read one
line of each record.
~Jonathan.

This is the program so far.
teamfile is the file I am trying to read; teamfile2 is the file I want to
output to.

PROGRAM taglist;
uses crt;

TYPE
tag_team = record
                 name:string;
                 line1:string;
                 line2:char;
                 line3:char;
                 line4:char;
                 line5:char;
                 line6:char;
           END;
VAR
teamlist:tag_team;
teamfile:FILE OF tag_team;
teamfile2:Text;

BEGIN
clrscr;
ASSIGN(teamfile2,'C:\teamlist.txt');
REWRITE(teamfile2);
ASSIGN(teamfile,'C:\TNM7\UWF\cardt.pts');
RESET(teamfile);
WHILE (EOF(teamfile)= FALSE) DO
BEGIN
read(teamfile,teamlist);
WITH teamlist DO
BEGIN
write(teamfile2,name);
END;
END;
CLOSE(teamfile);
CLOSE(teamfile2);
END.

This is an excerpt (spelling ?) from the file. The top line is the only one I
need to read.

Jinsei Shinzaki and Hayabusa
2850
3
2
1
0
0

 

Re:Newbie needs help - TNM Plugin programming


On 01 Jan 2001 17:39:02 GMT, jthom10...@aol.com (Jthom10361) wrote:
.........................snip........................

Quote
>NOTE: I did not make TNM, so I don't know what the various fields
>in it's generated files mean. I just made assumptions, as I only
> needed to read one line of each record.
> Jonathan.

I suspect you have declared the fields as the wrong type. I do not
know where you got the record you include as typical, but line1 is
probably an integer and the other lines can either be integers or
bytes. In order to read a record in Pascal, you must have the correct
field type. I have stored your prototype as defined below and made a
dummy file of this same record repeated 10 times in the same directory
and modified your file names accordingly. I'm guessing the string is
no more than 80 chars so I dimensioned that as well.

The rest of the program includes most of yours and it works.}

PROGRAM taglist;
uses crt;

TYPE
tag_team = record (**)
                 name:string[80];
                 line1:Integer;
                 line2:byte;
                 line3:byte;
                 line4:byte;
                 line5:byte;
                 line6:byte;
           END;
VAR
teamlist:tag_team;
teamfile:FILE OF tag_team;
teamfile2:Text;
ct:Byte;  (**)
s:String; (**)

BEGIN
clrscr;
ASSIGN(teamfile2,'teamlist.txt');
REWRITE(teamfile2);
ASSIGN(teamfile,'cardt.pts');
REWRITE(teamfile);  (* <------  To create file  *)

{************* making the fake teamfile ****************}

For ct := 1 to 10 Do   (* file 10 identical records *)
Begin
     With teamlist Do
     begin
          name := 'Jinsei Shinzaki and Hayabusa';
          line1 := 2850;
          line2 := 3;
          line3 := 2;
          line4 := 1;
          line5 := 0;
          line6 := 0;
     end;
     Write(teamfile, teamlist);
End;
(**************************************************)

RESET(teamfile);
WHILE Not EOF(teamfile) DO     (* the usual way *)
BEGIN
     read(teamfile,teamlist);
     Writeln(teamfile2, teamlist.name);
End;
CLOSE(teamfile);

(******* As a check ******)

Reset(teamfile2);
Clrscr;
While not eof(teamfile2) Do
Begin
     readln(teamfile2, s);
     writeln(s);
End;
CLOSE(teamfile2);
readln;
END.

Re:Newbie needs help - TNM Plugin programming


Quote
Jthom10361 <jthom10...@aol.com> wrote:
> it tries to open the file containing the tag team info, I get Error 100 - a
> disk read error.

[snip]

Quote
> TYPE
> tag_team = record
>                  name:string;
>                  line1:string;
>                  line2:char;
>                  line3:char;
>                  line4:char;
>                  line5:char;
>                  line6:char;
>            END;
> VAR
> teamlist:tag_team;
> teamfile:FILE OF tag_team;
> teamfile2:Text;

> BEGIN
> clrscr;
> ASSIGN(teamfile2,'C:\teamlist.txt');
> REWRITE(teamfile2);
> ASSIGN(teamfile,'C:\TNM7\UWF\cardt.pts');
> RESET(teamfile);

[snip]

Quote
> This is an excerpt (spelling ?) from the file. The top line is the only one I
> need to read.

> Jinsei Shinzaki and Hayabusa
> 2850
> 3
> 2
> 1
> 0
> 0

The problem is that you have the wrong file type for teamfile. This is
simply a text file, and you should declare and read it as such. In
other words, you ought to do something like

var teamfile: text;
    i: integer;
[...]
  readln(teamfile, name);
  writeln(teamfile2, name);
  for i := 1 to 6 do
    readln(teamfile);  {skip unwanted lines}

If "file of tag_team" was the correct type, the data file would be
unreadable (although you'd be able to spot the names in there).

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will
   sa...@maths.uwa.edu.au     |    come to ruin." -- Proverbs 13:3
______________________________|_______________________________________

Re:Newbie needs help - TNM Plugin programming


Quote
> At the moment, I am working on a program for TNM (the wrestling simulator -
> www.tnm7.com) to generate a tag team list. I have written the program, but when
> it tries to open the file containing the tag team info, I get Error 100 - a
> disk read error.
> Can anyone out there help me ? Here are my program and a clip from the file
> which I am attempting to read.
> NOTE: I did not make TNM, so I don't know what the various fields in it's
> generated files mean. I just made assumptions, as I only needed to read one
> line of each record.

   Well, the basic problem which was causing the program abort was your
use of a typed file with ASCII text file input.  The reading of a single
element of your record (as a string) caused the entire file to be read
in, and the read procedure wanted even more - because of your data
definition.  In essence, you cannot read a typed file "record" which is
comprised of ASCII Text data records: they're not the same type of data.
   I have modified and checked out your program (and made a few useful
changes and improvements, as well), and it now works.  Basically, I
changed the input file to text and read the individual data lines into
the record variable you had defined.  You could then write the record
variable to a file of that type...and read it in again as a record of
that type.
   Here is the working program:

PROGRAM taglist;
uses CRT;
Const LMax = 6;
TYPE tag_team = record
                  name  : string[80]; { Team Name }
                  line1 : string[20]; { ???? }
                  Lines : array[2..LMax] of Char
                END;
VAR teamlist  : tag_team;
    teamfile  : Text;
    teamfile2 : Text;
    I         : integer;
BEGIN
  ClrScr;
  ASSIGN(teamfile2,'teamlist.txt'); REWRITE(teamfile2);
  ASSIGN(teamfile,'cardt.pts'); RESET(teamfile);
  WHILE not EOF(teamfile) DO with TeamList do
    BEGIN
      Readln(TeamFile,Name);
      ReadLn(TeamFile,Line1);
      for I := 2 to LMax do
        Readln(TeamFile,Lines[I]);
      WriteLn(teamfile2,Name)
    END;
  CLOSE(teamfile); CLOSE(teamfile2)
END.

   This is an excerpt (spelling ?) from the file.  The top line is the
only one I need to read.

Jinsei Shinzaki and Hayabusa
2850
3
2
1
0
0

Re:Newbie needs help - TNM Plugin programming


Quote
> At the moment, I am working on a program for TNM (the wrestling simulator -
> www.tnm7.com) to generate a tag team list. I have written the program, but when
> it tries to open the file containing the tag team info, I get Error 100 - a
> disk read error.
> Can anyone out there help me ? Here are my program and a clip from the file
> which I am attempting to read.
> NOTE: I did not make TNM, so I don't know what the various fields in it's
> generated files mean. I just made assumptions, as I only needed to read one
> line of each record.

   Well, the basic problem which was causing the program abort was your
use of a typed file with ASCII text file input.  The reading of a single
element of your record (as a string) caused the entire file to be read
in, and the read procedure wanted even more - because of your data
definition.  In essence, you cannot read a typed file "record" which is
comprised of ASCII Text data records: they're not the same type of data.
   I have modified and checked out your program (and made a few useful
changes and improvements, as well), and it now works.  Basically, I
changed the input file to text and read the individual data lines into
the record variable you had defined.  You could then write the record
variable to a file of that type...and read it in again as a record of
that type.
   Here is the working program:

PROGRAM taglist;
uses CRT;
Const LMax = 6;
TYPE tag_team = record
                  name  : string[80]; { Team Name }
                  line1 : string[20]; { ???? }
                  Lines : array[2..LMax] of Char
                END;
VAR teamlist  : tag_team;
    teamfile  : Text;
    teamfile2 : Text;
    I         : integer;
BEGIN
  ClrScr;
  ASSIGN(teamfile2,'teamlist.txt'); REWRITE(teamfile2);
  ASSIGN(teamfile,'cardt.pts'); RESET(teamfile);
  WHILE not EOF(teamfile) DO with TeamList do
    BEGIN
      Readln(TeamFile,Name);
      ReadLn(TeamFile,Line1);
      for I := 2 to LMax do
        Readln(TeamFile,Lines[I]);
      WriteLn(teamfile2,Name)
    END;
  CLOSE(teamfile); CLOSE(teamfile2)
END.

   This is an excerpt (spelling ?) from the file.  The top line is the
only one I need to read.

Jinsei Shinzaki and Hayabusa
2850
3
2
1
0
0

Other Threads