I have a program I am trying to write. It is very basic but I'm not sure how to implement this specific function. Basically this is what I WANT my code to look like;

Date Day Availability
1 Monday Free
2 Tuesday Free
3 Wednesday Free
4 Thursday Free
5 Friday Free
6 Saturday Free
7 Sunday Free
...

and so on, up to 31 with the days repeating themselves in order again.

However this is what is currently happening

Date Day Availability
1 Monday Free
2 Monday Free
3 Monday Free
4 Monday Free
5 Monday Free
...

All the way up to 7 which then it gives me a Runtime Error.

This is the related coding;

TYPE
	DAYS = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);

VAR
	Day : ARRAY[1..7] OF DAYS;

{Display all entries}
PROCEDURE ShowList;
BEGIN
	WRITELN('Date', 'Day':10, 'Availability':15);
	FOR i := 1 to 31 DO
		WRITELN (i:4, Day[i]:20, Bookings[i]:30)
END;

I've looked up for where I am going wrong but I've not found any help. Is there someone out there who could give my code a look over and hint me at where I am going wrong?

You output Day[i] which is defined as an array[1..7] , but the loop runs from 1 to 31.

Hi guys!
I've got a problem. I try to write a program, that would sort lines in a text file, but it returns exit code 106 and I don't see a mistake.

program kytary;
uses crt;
type
    RET1 = string[12];
    RET2 = string[15];
    
    KYTARA = record
	vyrobce: RET1;
	model: RET2;
	rokvyr: integer;
	cena: longint;
	krk: integer;
	profil: char;
    end;
    databaze = array[1..255] of KYTARA;

var
   db: databaze;
   pomV: string[12];
   pomM: string[15];
   pomR: integer;
   pomC: longint;
   pomK: integer;
   pomP: char;
   kejtra: KYTARA;

   f: text;
   
   volba1, volba2, i, j, pockytar: byte;

begin
   pockytar:= 0;

   writeln(' ----------------------------------------- ');
   writeln('!                                          !');
   writeln('!         Editor souboru kytary.txt        !');
   writeln('!                                          !');
   writeln(' ----------------------------------------- ');
   writeln('');
   writeln('');

   assign(f, 'c:\SAVE\kytary.txt');
   reset(f);
   while not eof(f) do begin
                         readln(f);
                         pockytar:= pockytar+1;
                       end;
                       close(f);
   for i:=1 to pockytar do begin
                              reset(f);
                              read(f, pomV, pomM, pomR, pomC, pomP, pomK);
                              readln(f);
                              db[i].vyrobce:=pomV;
                              db[i].model:=pomM;
                              db[i].rokvyr:=pomR;
                              db[i].cena:=pomC;
                              db[i].profil:=pomP;
                              db[i].krk:=pomK;
                            end;
   writeln('For sort by price type "1"');
  

   readln(volba1);
   if volba1=1 then
      begin
           writeln('For sort from the lowest type "1"');
           writeln('for sort from the highest "2"');
           readln(volba2);
            if volba2=1 then begin
                                for i:=1 to pockytar-1 do
                                  for j:=1 to pockytar-1 do
                                  begin
                                     if db[j].cena>db[j+1].cena then
			                begin kejtra:= db[j];
               		                   db[j]:=db[j+1];
               		                   db[j+1]:=kejtra;
                                        end;

                                  end;
                              end;
                              close(f);

      end;


end.

PS here's the text file

Gibson      Firebird       1964 55000 C 0
Fender      Stratocaster   1958 60000 D 1
Fender      Telecaster     1953 85000 C 1
Gretsch     Nashville      1961 62000 V 0
Gibson      Les Paul       1954 90000 C 0
Rickenbacker4003           1972 59000 C 0
Fender      Jaguar         1969 48000 D 1

Can someone tell me where am I wrong?
Thanks!

Start a new thread, instead of replying to an existing thread with a different topic please.

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.