Hi guys,

the date program I was working on is up and running and doing what I want it to do...ina nut shell anyway.

Tajes a date in 6 digit format, error checks days in months etc and then outputs as month name, day no and prefix and year in four digits.

Can anyone suggest any improvements? It was mentioned that I shoudl use functions but I've still not been successful in getting them to work.

Code:
program EX10DATEVALIDATIONSG(input,output);
uses    crt;
const   Title:string = '                              EX10 DATE VALIDATION          ';
        By:string =    '                                 By Steve Green     ';

var     dayNo,monthNo,yearNo:integer;   //global
        maxdayNo:integer;               //within case & global

        month:string;
        monthnames: array[1..12] of string = ('January','February','March','April',
        'May','June','July','August','September','October','November','December');

procedure menu;
begin
        ClrScr;
        textcolor(red);
         writeln(Title);
         writeln;
         writeln(by);
         writeln;
          textcolor(green);
           writeln;
           writeln('Hello, My name is Menu.');
           writeln('I will try and validate any date that you type in.');
           writeln(' ');
           writeln('The range of years is between 1913 and 2012.');
           writeln;
           writeln;
end;

procedure cont;
begin
        writeln;
        writeln;
        writeln;
         textcolor(red);
          writeln ('Press <Return> to continue');
        readln ();
end;

procedure monthMaxDay;
begin
      case monthNo of                        {This section gives the}
         4,6,9,11: maxdayNo := 30;           {months their correct lengths}
         1,3,5,7,8,10,12: maxdayNo := 31;
         2: if yearNo mod 4=0 then maxdayNo :=29
         else maxdayNo := 28;                {leap yr validation}
      end;
end;

procedure dayPrefix;
begin
      case dayNo of
         1,21,31: write (' ',dayNo,'st,');   {sets prefix for day}
         2,22: write (' ',dayNo,'nd,');
         3,23: write (' ',dayNo,'rd,');
         4..20: write (' ',dayNo,'th,');
         24..30: write (' ',dayNo,'th,');
      end;
end;

begin {main program}

//REPEAT IS NEEDED!!!!!

  //BEGIN MENU,INSTRUCTIONS AND USER INPUT
      menu;
       write('Please enter the date to continue, enter in this format, DD MM YY.');
        writeln;
         readln(dayNo,monthNo,yearNo);
  //END OF USER INPUT

  //ERROR HANDLING FOR MONTHS
      if (monthNo <=0) or (monthNo >12) then
        begin
          repeat
         writeln('Sorry, There are only 12 months in a year!');
         writeln('Please enter the month again in MM format');
         read(monthNo);
          until (monthNo <=12) and (monthNo >0)
        end;
      if (monthNo > 0) and (monthNo <= 12) then
            monthMaxDay;
             { write(monthnames[monthNo]); }
  // END OF MONTH CHECKING


  //BEGIN ERROR HANDLING FOR DAYS WITHIN A MONTH
      if (dayNo> maxdayNo) or (dayNo <=0) then
        begin
         repeat
         writeln(monthnames[monthNo],' : There are only  ',maxdayNo, ' of days in this month!');
         writeln('Please select a valid day');
           read(dayNo);
           until (dayNo <= maxdayNo) and (dayNo >0);
        end;
        write(monthnames[monthNo]);
        dayPrefix;
  //END OF DAY CHECKING

//YEAR CHECKING MAY NOT BE NEEDED AS RANGE WLL BE STIPULATED IN MENU.

  //YEAR CHECKING
      if (yearNo <=99) and(yearNo >12) then
        write(' 19',yearNo);
      if (yearNo <=09) and (yearNo >=00) then
        write(' 200',yearNo);
      if (yearNo >=10) and (yearNo <=12) then
        write(' 20',yearNo);
  //END OF YEAR CHECKING

      writeln;
      writeln;
      cont;
end.
Also, I was trying to get the whole thing to repeat but it woudln't. so, instead of it running once, it woudl display the date and then prompt for another. any help here would be good.

thanks.