Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9280637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:55:12+00:00 2026-06-18T17:55:12+00:00

I am reading a text file into a record array. Part of the data

  • 0

I am reading a text file into a record array. Part of the data in the text files are program grades and test grades. Can I declare an array of integers to fold the program or test values as a field in the record? If so, then how do I access the individual program values in the field?
For example, could I declare the record like this? And if so how would I input or access data from say test[3]?

nametype = record
  first : string[10];
  mi : string[3];
  last : string[30];
end;
stype = record
  id : integer;
  name : nametype;
  prog : array[1..10] of integer;
  test : array[1..3] of integer;
  progave, quizave : real;
  average : double;
  grade : char;
end;
sarraytype = array[1..100] of stype;
var
  student : sarraytype;

So I guess where I’m stuck is reading into these arrays. So far for my read I have:

procedure TstudentData.openButtonClick(Sender: TObject);
   begin
     var i : integer;
     if open.execute then
     begin
      assignfile(inf,open.FileName);
      reset(inf);
      i := 1;
      while not eof(inf) do with student[i] do
      begin
         readln(inf, id, name.first, name.mi, name.last);
         i := i + 1;
      end;
   end;
   i:=1;
end;

I have the read for the other data, but I’m at a total loss for how to read into the prog and test arrays.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:55:13+00:00Added an answer on June 18, 2026 at 5:55 pm

    You can. By an example …

    var
      a: sarraytype;
      i, j: integer;
    begin
      for i := low(a) to High(a) do
        for j := low(a[i].test) to High(a[i].test) do
          a[i].test[j] := i * 100 + j;
      for i := low(a) to High(a) do
        for j := low(a[i].test) to High(a[i].test) do
          Memo1.Lines.Add(IntToStr(a[i].test[j]));
    
    end;
    

    as response to your comment

    var
      a,b: sarraytype;
      i, j: integer;
      fs:TFileStream;
    begin
      for i := low(a) to High(a) do
        begin
        for j := low(a[i].test) to High(a[i].test) do
          a[i].test[j] := i * 100 + j;
        a[i].name.first := 'Test' + IntToStr(i);
        end;
    
      fs := TFileStream.Create('C:\temp\test.bin',fmCreate);
      try
      fs.Write(a,sizeOf(a));
      finally
        fs.Free;
      end;
    
      fs := TFileStream.Create('C:\temp\test.bin',fmopenRead);
      try
      fs.Read(b,sizeOf(b));
      finally
        fs.Free;
      end;
    
      for i := low(b) to High(b) do
        begin
        memo1.Lines.Add(b[i].name.first);
        for j := low(b[i].test) to High(b[i].test) do
          Memo1.Lines.Add(IntToStr(b[i].test[j]));
    
        end;
    
    end;
    

    BTW:

    Usual naming would be

    Tnametype = record
      first : string[10];
      mi : string[3];
      last : string[30];
    end;
    Tstype = record
      id : integer;
      name : nametype;
      prog : array[1..10] of integer;
      test : array[1..3] of integer;
      progave, quizave : real;
      average : double;
      grade : char;
    end;
    
    Tsarraytype = array[1..100] of stype;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading in from a text file using StreamReader into a string array
I need some help reading data from a text file into my ArrayList .
I'm having a problem reading data from a text file into ms sql. I
I'm reading a text file line by line, and inserting it into an array.
So I'm having an issue reading a text file into my program. Here is
I am reading a text file into Matlab called 'test.txt' which is structured as
I have a text file which I am reading and storing the data in
I'm reading data out of a binary file into structs in C#. What's the
I am basically reading a text file into a List and I am copying
I am reading text from a file into a string builder, I make a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.