Dear ALL,

Could you tell me what is wrong of my program? The problem is the following wording are often restart: "PLEASE RUN THIS PROGRAM IN A MAXIMUM WINDOW..., TONY YEUNG PRESENT...

How can I add some music for it? How can I change the colour of the font and display into screen?

Program yeungkt2;
{$APPTYPE CONSOLE}
{
    IT113 Assignment - Who wants to be a student millionaire.
    Author:  Tony Yeung
    Date: 16 October 2009
    Version 2.03
}
uses
  SysUtils,OurCrt;
Type
   hotSeat_record=record
   lastname  :string[12];
   firstname :string[12];
   address   :string[25];
End;

//*****************  USED VARIABLES   ******************************************
Var User_Choice    :Integer;  //global variable
    hotSeat_file  :file of hotSeat_record;
    hotSeat       :array[1..100]of hotSeat_record;
    numberRecords  :integer;
    numbers        :array[1..6] of integer;
    generate       :boolean;
    ONE            :hotSeat_record;
//********************  PROCEDURE LOAD  ****************************************
Procedure load;
Var
   count:integer;
begin
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln('                  PLEASE RUN THIS PROGRAM IN A MAXIMIZED WINDOW');
  writeln;
  writeln('                            PRESS <ENTER> TO CONTINUE');
  readln;
  clrscr;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln;
  writeln('                  T');
  sleep(200);
  clrscr;
  writeln('                  TO');
  sleep(200);
  clrscr;
  writeln('                  TON');
  sleep(200);
  clrscr;
  writeln('                  TONY');
  sleep(200);
  clrscr;
  writeln('                  TONY ');
  sleep(200);
  clrscr;
  writeln('                  TONY Y');
  sleep(200);
  clrscr;
  writeln('                  TONY YE');
  sleep(200);
  clrscr;
  writeln('                  TONY YEU');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUN');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG ');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG P');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PR');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRE');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRES');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRESE');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRESEN');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRESENT');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRESENT .');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRESENT ..');
  sleep(200);
  clrscr;
  writeln('                  TONY YEUNG PRESENT ...');
  sleep(200);
  clrscr;


    assign(hotSeat_file,'hotSeat.dat');
    reset(hotSeat_file);
    numberRecords:= filesize(hotSeat_file);
  for count:=  1 to numberRecords do
  Begin
    read(hotSeat_file,hotSeat[count]);
  end;
end;
//*********************  PROCEDURE CONTESTANTSLIST  ****************************
Procedure ContestantsList;
Var
   count:integer;
Begin
  numberRecords:= filesize(hotSeat_file);
  WriteLn('...LAST NAME..FIRST NAME..................ADDRESS......');
  WriteLn;
  for count:=  1 to (filesize(hotSeat_file)) do
  Begin
  WriteLn(hotSeat[count].firstname:12,hotSeat[count].lastname:12,hotSeat[count].address:25);
  sleep(100);
  End;
  readln;
end;
//*************************  PROCEDURE GENERATE10FINALISTS  ********************
Procedure Generate6finalists;
var
  count,temp:integer;
begin
  writeln('Here are the 6 finalist''s numbers');
  randomize;
  for count:= 1 to 6 do
  begin
    temp:=random(numberRecords)+1;
    while(temp=numbers[1])
       or (temp=numbers[2])
         or (temp=numbers[3])
           or (temp=numbers[4])
             or (temp=numbers[5])
               or (temp=numbers[6]) do

    begin
      temp:=random(numberRecords)+1;
    end;
    numbers[count]:=temp;
    generate := true;
  end;
  for count := 1 to 6 do
    begin
      writeln;
      writeln('     ***<$$$$$>****  ' ,(numbers[count]), '  ****<$$$$>****');
      writeln;
      sleep(100);
    end;
    writeln('              GOOD LUCK !!!!!!!');
    readln;
    //clrscr;
end;
//************************  PROCEDURE SHOWFINALISTS  ***************************
Procedure ShowFinalists;
  var
  count: integer;
  Begin
  if (generate = true)  then
  begin
    WriteLn('3 pressed,finding and listing the finalists...');
    WriteLn('...LAST NAME..FIRST NAME..................ADDRESS......');
    for count:=1 to 6 do
    begin
      writeln(hotSeat[numbers[count]].firstname:12, hotSeat[numbers[count]].lastname:12, hotSeat[numbers[count]].address:20);
      writeln;
      sleep(200);
    end
  end
  else
      writeln('Please generate finalist number first!');
    readln;
  End;
//***************************  PROCEDURE SAVE  *********************************
Procedure save;
  var
  count: integer;
  Begin
    reset(hotSeat_file);
    for count:=1 to filesize(hotSeat_file) do
      begin
       write(hotSeat_file,hotSeat[count]);
      end;
  end;
//************************  PROCEDURE CHANGEDETAILS  ***************************
Procedure ChangeDetails;
  var
  count: integer;
  first,last,address: string;
  name: boolean;

  Begin
    name:=false;
        WriteLn('4 pressed,changing the address a friend details...');

        WriteLn('Please enter your first name.');
        readln(first);
        WriteLn('Please enter your last name.');
        readln(last);
        for count:=1 to filesize(hotSeat_file) do
        begin
         if (hotSeat[count].firstname=first) and(hotSeat[count].lastname=last) then
        begin
        writeln('Well. We''ve found your records.');
        writeln('Please enter your new address');
        readln(address);
        hotSeat[count].address:=address;
        name:=true
        end;
        end;
        if name=false then
        begin
        writeln('Sorry!  We do not have your records from your database.');
        end;
        writeln;
        write('Press <ENTER> to save changes and return to the main menu.');
        save;
        readln;
        end;
//***********************  PROCEDURE ENROLCONTESTANTS  *************************
Procedure EnrolContestant;
  var
        INDEX_:INTEGER;
        count :integer;
        name  :boolean;
  Begin
    name:=false;
    write('Please enter your first name - if you''re new: ');
    readln(ONE.FIRSTNAME);
    write('Please enter your last name: ');
    readln(ONE.LASTNAME);
    write('Lastly, please enter your address: ');
    readln(ONE.ADDRESS);
    write('Please press <ENTER> for checking these data..');
    READLN;//*
    for count:=1 to filesize(hotSeat_file) do
    begin
    if (hotSeat[count].lastname=ONE.FIRSTNAME) and (hotSeat[count].firstname=ONE.LASTNAME) then
    begin
        name:=true;
        writeln('You''re a contestant already.');
    end;
    end;
    if (name = false) then
    begin
        CLOSE(HOTSEAT_FILE);
        WRITELN('Checking is over,everything went fine.');
        writeln('Please press <ENTER> again to save your details and return to main menu.');
        readln;
        INDEX_:=0;
        RESET(HOTSEAT_FILE);
        WHILE (EOF(HOTSEAT_FILE)=FALSE)DO BEGIN
           READ(HOTSEAT_FILE,HOTSEAT[INDEX_]);
           INC(INDEX_,1);
           IF (EOF(HOTSEAT_FILE)=TRUE) THEN BEGIN
              FILEMODE:=2;
              SEEK(HOTSEAT_FILE,FILESIZE(HOTSEAT_FILE));//JUMP THE END OF THE FILE
              WRITE(HOTSEAT_FILE,ONE); //AND WRITE THE ENROLED GUY
           END;
        END;
    end;
  end;
//*****************************  PROCEDURE GETOUTOFHERE  ***********************
Procedure GetOutOfHere;
  Begin
    WriteLn('0 pressed,exiting...');
    Sleep(1000);
    //clrscr;
  End;
//*******************************  PROCEDURE MENU  *****************************
 Procedure Menu;
Begin
      LOAD;
      Writeln('               M E N U');
      WriteLn('Please enter an integer in the range 1...5');
      WriteLn;
      WriteLn('  1 List all the contestants');
      WriteLn('  2 Generate the 6 finalist''s numbers');
      WriteLn('  3 Find and list the finalists');
      WriteLn('  4 Change the address a friend details');
      WriteLn('  5 Enrol a new contestant');
      WriteLn('  0 Exit');

      Readln(User_Choice);
      Case (User_Choice) of
         1:ContestantsList;
         2:Generate6finalists;
         3:ShowFinalists;
         4:ChangeDetails;
         5:EnrolContestant;
         0:GetOutOfHere;
        end;
end;
//***************************  THE MAIN PROGRAM  *******************************
begin //main body
//Load;
repeat
menu;              {Shows the Menu on the screen}
until User_Choice = 0;  {Allows program user to Exit program}
CLOSE(HOTSEAT_FILE);//*
end.

Recommended Answers

All 2 Replies

assign(hotSeat_file,'hotSeat.dat');{error here!!!}
{need the whole path like 'C:\hotseat.dat'}

to color your texts in the screen look at this page
http://rvelthuis.de/programs/console.html
here you can download a console unit it is contains the textcolor rutin too..
and there is some commad to beep the speaker....

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.