Hello,

I have an assignment due tomorrow and getting help by bugging you guys is my last resort... I have tried everything else.

I'm extremely new at programming and taking my first course in Pascal Delphi. I'm using Delphi 6 and my assignment consists of using data within a .txt file and working with that data.

I have spent my whole week on this project and to date, I was only able to import that data into my program and print it to screen in one block. I need to be able to use each piece of data on its own. My text file looks like this :

Name Surname
Difficulty level Dive 1
Note Dive 1 Judge 1
Note Dive 1 Judge 2
Note Dive 1 Judge 3
Note Dive 1 Judge 4
Note Dive 1 Judge 5
Note Dive 1 Judge 6
Note Dive 1 Judge 7
Difficulty level Dive 2
Note Dive 2 Judge 1
...
Note Dive 2 Judge 7
Difficulty level Dive 3
Note Dive 3 Judge 1
...
Note Dive 3 Judge 7

Here is my code so far...  Can anyone put me on the right track to be able to use each piece of data ?  I will need to manipulate it to figure out the divers' scores and I can't do anything until I can use the data.

Thank you very much... here is my code : 

PROGRAM testingtp4ex2;

{$APPTYPE CONSOLE}

CONST
        nomfichier = 'resultat.txt';      // The text file
        maxplongeur = 5;                  // Number of divers

TYPE Competition = RECORD                 // The record I'm using per diver
        Prenom : STRING[20];              // Given name
        Nom : STRING[20];                 // Name
        Diff1 : REAL;                     // Difficulty level dive 1
        Notes1 : ARRAY[1..7] OF REAL;     // Array of notes dive 1
        Diff2 : REAL;                     // Difficulty level dive 2
        Notes2 : ARRAY[1..7] OF REAL;     // Array of notes dive 2
        Diff3 : REAL;                     // Difficulty level dive 3
        Notes3 : ARRAY[1..7] OF REAL;     // Array of notes dive 3
        END;

VAR
        fichier : text;
        lecture : STRING[20];             // This may be the part that needs
        fiche : FILE OF Competition;      // work... it's pulling everything
                                          // at once
PROCEDURE Lire;  // To read the .txt file
BEGIN
        ASSIGN(fichier, nomfichier);
        RESET(fichier);
        REPEAT
                READLN(fichier, lecture);
                WRITELN(lecture);
        UNTIL EoF(fichier);
        CLOSE(fichier);
END;

PROCEDURE Ecrire;     // to use data in the .txt file.
                      // here I'm just trying to read a few things to test it
VAR                   // but it's not working, I get errors.
        i : integer;  // I tried a number of things that won't work for me

BEGIN
        FOR i := 1 TO maxplongeur DO
        READLN(fichier, fiche[i].prenom);
        WRITELN(fichier, fiche[i].Prenom);
END;

BEGIN      // main program
        Lire;
        Ecrire;
        READLN;
END.

Thanks !
Nathalie

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Hello,

I have an assignment due tomorrow and getting help by bugging you guys is my last resort... I have tried everything else.

I'm extremely new at programming and taking my first course in Pascal Delphi. I'm using Delphi 6 and my assignment consists of using data within a .txt file and working with that data.

I have spent my whole week on this project and to date, I was only able to import that data into my program and print it to screen in one block. I need to be able to use each piece of data on its own. My text file looks like this :

Name Surname
Difficulty level Dive 1
Note Dive 1 Judge 1
Note Dive 1 Judge 2
Note Dive 1 Judge 3
Note Dive 1 Judge 4
Note Dive 1 Judge 5
Note Dive 1 Judge 6
Note Dive 1 Judge 7
Difficulty level Dive 2
Note Dive 2 Judge 1
...
Note Dive 2 Judge 7
Difficulty level Dive 3
Note Dive 3 Judge 1
...
Note Dive 3 Judge 7

Here is my code so far... Can anyone put me on the right track to be able to use each piece of data ? I will need to manipulate it to figure out the divers' scores and I can't do anything until I can use the data.

Thank you very much... here is my code :

Thanks !
Nathalie

PROGRAM testingtp4ex2;

{$APPTYPE CONSOLE}

CONST
        nomfichier = 'resultat.txt';      // The text file
        maxplongeur = 5;                  // Number of divers

TYPE Competition = RECORD                 // The record I'm using per diver
        Prenom : STRING[20];              // Given name
        Nom : STRING[20];                 // Name
        Diff1 : REAL;                     // Difficulty level dive 1
        Notes1 : ARRAY[1..7] OF REAL;     // Array of notes dive 1
        Diff2 : REAL;                     // Difficulty level dive 2
        Notes2 : ARRAY[1..7] OF REAL;     // Array of notes dive 2
        Diff3 : REAL;                     // Difficulty level dive 3
        Notes3 : ARRAY[1..7] OF REAL;     // Array of notes dive 3
        END;

VAR
        fichier : text;
        lecture : STRING[20];             // This may be the part that needs
        fiche : FILE OF Competition;      // work... it's pulling everything
                                          // at once
PROCEDURE Lire;  // To read the .txt file
BEGIN
        ASSIGN(fichier, nomfichier);
        RESET(fichier);
        REPEAT
                READLN(fichier, lecture);
                WRITELN(lecture);
        UNTIL EoF(fichier);
        CLOSE(fichier);
END;

PROCEDURE Ecrire;     // to use data in the .txt file.
                      // here I'm just trying to read a few things to test it
VAR                   // but it's not working, I get errors.
        i : integer;  // I tried a number of things that won't work for me

BEGIN
        FOR i := 1 TO maxplongeur DO
        READLN(fichier, fiche[i].prenom);
        WRITELN(fichier, fiche[i].Prenom);
END;

BEGIN      // main program
        Lire;
        Ecrire;
        READLN;
END.
This article has been dead for over six months. Start a new discussion instead.