I have a menu system which can allows me to list all the contestants. The following is my menu system:

Program Student_millionaire;

{$APPTYPE CONSOLE}

uses
  SysUtils, OurCrt;

Var User_Choice:Integer;

Procedure ContestantsList;
  Begin
    WriteLn('1 pressed,listing all the contestants...');
    ReadLn;
  End;

Procedure Generate10finalists;
  Begin
    WriteLn('2 pressed,generating the 10 finalist''s numbers...');
    ReadLn;
  End;

Procedure UpdateFinalists;
  Begin
    WriteLn('3 pressed,finding and listing the finalists...');
    ReadLn;
  End;

Procedure ChangeDetails;
  Begin
    WriteLn('4 pressed,changing the phone a friend details...');
    ReadLn;
  End;

Procedure EnrolContestant;
  Begin
    WriteLn('5 pressed,enroling a new contestant...');
    ReadLn;
  End;

Procedure GetOutOfHere;
  Begin
    WriteLn('6 pressed,exiting...');
    Sleep(1000);

  End;

Begin
   User_Choice:=0;
   While User_Choice <> 6 Do Begin
      ClrScr;
      WriteLn('Please enter an integer in the range 1...6');
      WriteLn;
      WriteLn('  1 List all the contestants');
      WriteLn('  2 Generate the 10 finalist''s numbers');
      WriteLn('  3 Find and list the finalists');
      WriteLn('  4 Change the phone a friend details');
      WriteLn('  5 Enrol a new contestant');
      WriteLn('  6 Exit');
      WriteLn;

      ReadLn(User_Choice);

      Case (User_Choice) of
         1:ContestantsList;
         2:Generate10finalists;
         3:UpdateFinalists;
         4:ChangeDetails;
         5:EnrolContestant;
         6:GetOutOfHere;
      Else
        Begin
             WriteLn('Wrong Number..');
             WriteLn('Exiting...');
         End;
      End;
    End;
End.

To fulfill the listing of the contestant:

  1. May I want to declare a file of records?
  2. May I want to prepare a file for output with the assign and rewrite statements?
  3. May I want to store records in a file with write?
  4. May I want to write files with multiple records?
  5. Close a file.

And I have written the following programming, but it doesn't work:

program Project2;

{$APPTYPE CONSOLE}

type
        Millionaire_record=record
                first_name: String[12];
                last_name: String[12];
                address: String[25];
        end;

var
        Person: Millionaire_Record;
        Person: array[1..40] of Millionaire_Record;

begin
        WriteLn('Enter the first name of person >> ');
        ReadLn('person.first name');

end.

May I need to combine this program together with the first program? How can I do?

Before worrying about putting it all together, work on the parts of the program. For instance, you have identified the record to store your data, but how are you loading user input into the record array? Solve this as you would eat an elephant, one bite at a time.

In order to manage the record array you need to keep track of which records are already filled and where to insert new data, so you need a counter. You may also want to ask the user for data for more than one record at a time so you need a loop such as while or Repeat/ until. you also need a way to get out of the loop and continue with your program or exit.

My suggestion si to start with a small operating program and continue to add features, testing it often. Let us know how it progresses for you.

You're right 'jsosnowski',big eating :).But do not worry 'turbomen'...
First thing that you have to do is thinking of the algorithm of the main program,a bit more than you did it last time.And what do you want?To write these data to a text file,and read these data back to an array?Or just fill an array with these data?(Person:Array[1..40]of Millionaire_Record)?
And for your question the answer is you can.Put your second program in a procedure,and itegrate it in the main program.Take apart the second program a bit.Add the record type to the main program...

{just for help....}
Program MainProgram;

{$APPTYPE CONSOLE}

Type Millionaire_Record=Record
                          first_name: String[12];
                          last_name: String[12];
                          address: String[25];
                        End;

Var Person: array[1..40] of Millionaire_Record;
    OnePerson:Millionaire_Record;


//this is now living
Procedure EnrolContestant;
   Begin
      Write('First name: ');
      ReadLn(OnePerson.first_name);
      Write('Last name: ');
      ReadLn(OnePerson.last_name);
      Write('Her/His address: ');
      ReadLn(OnePerson.address);
      WriteLn;
      WriteLn('Checking data...');//this just to verify data
      Write('First name: ');
      WriteLn(OnePerson.first_name);
      Write('Last name: ');
      WriteLn(OnePerson.last_name);
      Write('Her/His address: ');
      WriteLn(OnePerson.address);
   End;


Begin //main
   EnrolContestant; //call our procedure

   ReadLn;
End.


{
If you want to continue your project then send a sign to us ,we can help to you

With respect:FlamingClaw
}

Or if you just fill the array then look at my solution,just example but working try it.

Program MainProgram;

{$APPTYPE CONSOLE}

Type Millionaire_Record=Record
                          first_name: String[12];
                          last_name: String[12];
                          address: String[25];
                        End;

Var Person: array[1..3] of Millionaire_Record;
    OnePerson:Millionaire_Record;
    i:Byte;

//this is now living
Procedure EnrolContestant(x:Byte);
   Begin
      Write(x,' First name: ');
      ReadLn(OnePerson.first_name);
      Write('  Last name: ');
      ReadLn(OnePerson.last_name);
      Write('  Her/His address: ');
      ReadLn(OnePerson.address);
   End;


Begin //main

   For i:=1 To 3 Do Begin
      EnrolContestant(i); //call our procedure
      //fill 3 person data,and put them in the array
      Person[i]:=OnePerson;
   End;

   //get back the data from the array
   For i:=1 To 3 Do Begin
      Write(i,'. ',Person[i].first_name,' ');
      Write(Person[i].last_name,' ');
      WriteLn(Person[i].address);
   End;
   ReadLn;
End.
commented: He help me to solve this problem. +1

//

{
When you create a new file it is placed to the c:\ drive
Like c:\something.txt.And when you asked that give a name
without extension and path add only name like:something

}
Program MainProgram;

{$APPTYPE CONSOLE}

Type Millionaire_Record=Record
                          first_name: String[12];
                          last_name: String[12];
                          address: String[25];
                        End;
Const N=100;
      NewFilePath='C:\';
      NewFileExtension='.Txt';

Var Person: array[1..N] of Millionaire_Record;
    OnePerson:Millionaire_Record;
    i:Byte;  //0..255
    User:Byte;

 { -= The Procedures =- }
//-= for reading a file =-
Procedure ReadingContestant;
Var F:text; //this will our *.text file
    F1:String; //this for lines
    F2:String;//file name
Begin
    Write('Give me the file name,that located in c:\ drive: ');
    ReadLn(F2);
    Assign(F,NewFilePath+F2+NewFileExtension);//file rendering to variable
    {$I-}  //IO check off
    Reset(F);   //while try to open that file for reading
    {$I+}  //IO check on
    If IoResult <> 0 Then Begin //if there was error then alert
       WriteLn('Error when try to read this file');
       ReadLn;  //waiting for enter button
       Halt;  //exit the main program
    End;
    i:=1;
    While Not(EoF(F))Do Begin //while not end of file
       ReadLn(F,F1);  //read F,F1=lines
       WriteLn(i,'.',F1);   //write only lines
       Inc(i);
    End;
    Close(F);   //close the opened file
End;
//*****************************************************
//-= enrolling =-
Procedure EnrolContestant;
Var EnCo:Byte;
    EnCo2:String;
    EnCo3:Text;
Begin
   Write('How many contestants do you want to enrol? : ');
   ReadLn(EnCo);
   For i:=1 To EnCo Do Begin
      Write(i,' First name: ');
      ReadLn(OnePerson.first_name);
      Write('  Last name: ');
      ReadLn(OnePerson.last_name);
      Write('  Her/His address: ');
      ReadLn(OnePerson.address);
      Person[i]:=OnePerson;
   End;
   WriteLn;
   Write('Give me the file name without extension and path: ');
   ReadLn(EnCo2);
   If (EnCo2 = '') Then Begin
      Write('Missing Data');
      ReadLn;
      Halt;
   End
   Else Begin
      Assign(EnCo3,NewFilePath+EnCo2+NewFileExtension);
      {$I-}
      Append(EnCo3);
      {$I+}
      If (IoResult<>0) Then Begin
         Write('Missing Data');
         ReadLn;
         Halt;
      End;
      For i:=1 To EnCo Do Begin
         Write(EnCo3,Person[i].first_name,' ');
         Write(EnCo3,Person[i].last_name,' ');
         WriteLn(EnCo3,Person[i].address);
      End;
   Close(EnCo3);
   WriteLn('Process succesful');
   Write('Press Enter to quit');
   ReadLn;
   Halt;
   End;
End;
//******************************************************
//-= exiting =-
Procedure Exiting;
Begin
   Write('Press enter to quit...');
   ReadLn;
   Halt;
End;

//******************************************************
//-=creating a new file for list=-
Procedure NewList;
Var NewFile:Text;
    NewFileName:String;
Begin
   Write('Give me the new file name without extension and path: ');
   ReadLn(NewFileName);
   If (NewFileName = '') Then Begin
      Write('Missing data,press enter to quit.');
      ReadLn;
      Halt;
   End
   Else Begin
      Assign(NewFile,NewFilePath+NewFileName+NewFileExtension);
      {$I-}
      Reset(NewFile);
      {$I+}
      If (IoResult<>0) Then Begin
         {$I-}
         Rewrite(NewFile);
         Close(NewFile);
         {$I+}
         If (IoResult=0)Then Begin
            WriteLn(NewFilePath+NewFileName+NewFileExtension,' is ready to use.');
            Write('When you press the enter button,the program will exit');
            ReadLn;
            Halt;
         End
         Else Begin
            Write('Error when trying to create a new file.');
            ReadLn;
            Halt;
         End;
      End;
   End;
End;
//********************************************************
//-= Modifying phone number =-
Procedure Modify_Phone;
Begin //not ready yet....
   Write('Under construction');
   ReadLn;
   Halt;
End;
//********************************************************
//-=First ten finalist=-
Procedure FirstTen;
Begin //not ready yet....
   Write('Under construction');
   ReadLn;
   Halt;
End;
//********************************************************
//-= Selecting an option =-
Procedure SelectOption;
Begin
   WriteLn('What do you want to do:');
   WriteLn;
   WriteLn('1.Open file for reading.List all the contestants.');
   WriteLn;
   WriteLn('2.Create a new file.Create a new list.');
   Writeln;
   WriteLn('3.Modifying contestant/s data.Phone number modifiying.');
   Writeln;
   WriteLn('4.Show 10 finalist.');
   Writeln;
   WriteLn('5.Add new contestant/s.');
   WriteLn;
   WriteLn('6.Exit the main program.');
   Writeln;
   {$I-}
   ReadLn(User);
   {$I+}
   If (IoResult<>0) Then Begin
      Write('Wrong data entered,press enter to quit.');
      ReadLn;
      Halt;
   End
   Else Begin
      Case (User) Of
         1:ReadingContestant;
         2:NewList;
         3:Modify_Phone;//not ready yet
         4:FirstTen;   //not ready yet
         5:EnrolContestant;
         6:Exiting;
      End;
   End;
End;
//*************-=End Of Procedures=-*************************


Begin//main program
   SelectOption;
   ReadLn;
End.//of main program

{
-= Note By FlamingClaw =-

All programs created by me are written and tested
in Dev Pascal and/or Turbo Pascal 7.0
Of course working!And working in Delphi 7 too.
-= Created By FlamingClaw =-
-=2009.04.15=-
}

//
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.