Program Code Program DVD_Program; Uses Menuunit, CRT, dos; {Declaration of constants in program}

Authors Avatar
Program Code

Program DVD_Program;

Uses Menuunit, CRT, dos;

{Declaration of constants in program}

CONST

Never= False;

mem_mainfile= 'c:\ripmid.rec';

vid_mainfile= 'c:\ripvid.rec';

rentalfile= 'c:\ripren.rec';

yesno: array [boolean] of string = ('No', 'Yes');

{Declaration of data type}

TYPE

mem_rec= record

mid: longint:

mname: string;

address: string;

phone: string;

end;

mem_file= file of mem_rec;

video_rec=record

vid: longint;

vname: string;

actor: string;

genre: string;

cost: real;

stock_number: integer;

end;

video_file= file of video_rec;

rental_rec= record

mid: longint;

vid: longint;

datedue: string;

dateborrowed: datetime;

days: longint;

returned: boolean;

{--------------------------------------------------------------------}

{Declaration of variables}

VAR

member: mem_file;

one_rec: mem_rec;

found: Boolean;

epos: integer;

password: text;

video: video_file;

two_rec: video_rec;

foundb: Boolean;

eposb: integer;

{--------------------------------------------------------------------}

{Ensures that the member names input by users are

valid i.e. all characters are letters}

Function validatemname (mname: string): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (mname); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (mname[j] in ['A'..'Z','a'..'z','-',' ']) then

valid:= j;

End;

validatemname:= valid;

If (valid<> 0) then

Begin

textcolor (red);

gotoxy (12,19);

Write( 'SORRY INVALID NAME ');

delay (800);

textcolor(blue);

gotoxy (37,13);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{--------------------------------------------------------------------}

{Ensures that the video name input by users are

valid i.e. characters, numbers, spaces and dashes only}

Function validatevname (vname: string) : integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (vname); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (vname[j] in ['A'..'Z','a'..'z','-',' ','0'..'9']) then

valid:= j;

End;

validatevname:= valid;

If (valid<> 0) then

Begin

textcolor (red);

gotoxy (12,19);

Write( 'SORRY INVALID NAME ');

delay (800);

textcolor(blue);

gotoxy (37,13);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{--------------------------------------------------------------------}

{Ensures that the address entered by the user

is acceptable or valid i.e. containing only letters and numbers.}

Function validateaddress (address: string): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (address); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (address[j] in ['A'..'Z','a'..'z'..,'#','0'..'9']) then

valid:= j;

End;

validateaddress:= valid;

if ( valid<> 0) then

Begin

textcolor(red);

gotoxy(12,19);

Write( 'SORRY INVALID ADDRESS ');

delay(800);

gotoxy(12,19);

Write (' ');

textcolor(blue);

gotoxy(37,13);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{--------------------------------------------------------------------}

{Ensures that the phone # entered by the user is

valid i.e. contains only numbers, spaces or dashes.}

Function validatephone (phone: string): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (phone); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (phone[j] in['0'..'9','-']) then

valid:= j;

End;

validatephone:= valid;

if ( valid<> 0) then

Begin

textcolor(red);

gotoxy(12,19);

Write( 'SORRY INVALID PHONE NUMBER ');

delay(800);

gotoxy(12,19);

Write (' ');

textcolor(blue);

gotoxy(37,13);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{------------------------------------------------------------------}

{Validates the actor name entered by the user.}

Function validateactor ( actor: string): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (actor); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (actor[j] in ['A'..'Z','a'..'z','-',' ']) then

valid:= j;

End;

validateactor:= valid;

If (valid<> 0) then

Begin

textcolor (red);

gotoxy (12,19);

Write( 'SORRY INVALID NAME ');

delay (800);

textcolor(blue);

gotoxy (37,13);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{------------------------------------------------------------------}

{Validates the genre entered by the user.}

Function validategenre ( genre: string): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (genre); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (genre[j] in ['A'..'Z','a'..'z','-',' ']) then

valid:= j;

End;

validategenre:= valid;

If (valid<> 0) then

Begin

textcolor (red);

gotoxy (12,19);

Write( 'SORRY INVALID GENRE ');

delay (800);

textcolor(blue);

gotoxy (37,13);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{------------------------------------------------------------------}

{Validates the cost of a video when it is added to database.}

Function validatecost (cost: real): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (cost); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (cost[j] in['1','2','3','4','5','6','7','8','9','0',' ','.''-']) then

valid:= j;

End;

validatecost:= valid;

if ( valid<> 0) then

Begin

textcolor(red);

gotoxy(12,19);

Write( 'SORRY INVALID COST ');

delay(800);

gotoxy(12,19);

Write (' ');

textcolor(blue);

gotoxy(37,15);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{--------------------------------------------------------------------}

{Used to validate the stock number entered by user.}

Function validatestock_number (number2:string): integer;

VAR

j, l: integer;

valid: integer;

number_2 : integer;

Begin

l:= length (number2); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (number2[j] in['1','2','3','4','5','6','7','8','9','0']) then

valid:= j;

Else stock:= 1

End;

validatestock_number:= valid;

if ( valid<> 0) then

Begin

textcolor(red);

gotoxy(12,19);

Write( 'SORRY INVALID NUMBER ');

delay(800);

gotoxy(12,19);

Write (' ');

textcolor(blue);

gotoxy(37,15);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{------------------------------------------------------------------}

{Validates the date entered by the user.}

Function validatedate (date: string): integer;

VAR

j, l: integer;

c: char;

valid: integer;

Begin

l:= length (date); valid:= 0;

FOR j:= 1 to 1 DO

Begin

If not (date[j] in['1','2','3','4','5','6','7','8','9','0','/']) then

valid:= j;

End;

validatedate:= valid;

if ( valid<> 0) then

Begin

textcolor(red);

gotoxy(12,19);

Write( 'SORRY INVALID DATE ');

delay(800);

gotoxy(12,19);

Write (' ');

textcolor(blue);

gotoxy(37,15);

For j:= 1 to 1+1 Do

Write (' ');

End;

End;

{--------------------------------------------------------------------}

{This procedure is used to initialise the screen for use.}

Procedure Init_Screen;

Begin

TextMode (co80);

HideCursor;

TextBackGround (1);

ClrScr;

End;

{--------------------------------------------------------------------}

{This procedure is used to initialise the menu for use.}

Procedure Init_Menus;

Begin

Reset_Menu; {Clears any menu values}

{Declaration of menu}

Add_Menu ('File', 1, 1);

Add_Menu ('Initialise File', 1, 2);

Add_Menu ('-', 1, 3);

Add_Menu ('Add a member record', 1, 4);
Join now!


Add_Menu ('Add a video record', 1, 5);

Add_Menu ('-', 1, 6);

Add_Menu ('Locate member record', 1, 7);

Add_Menu ('Locate video record', 1, 8);

Add_Menu ('-', 1, 9);

Add_Menu('View all member records', 1, 10);

Add_Menu('View all video records', 1, 11);

Add_Menu ('Edit', 2, 1);

Add_Menu ('Edit a member record', 2, 2);

Add_Menu ('Edit a video record', 2, 3);

Add_Menu ('-', 2, 4);

Add_Menu ('Delete a member record', 2, 5);

Add_Menu ('Delete a video record', 2, 6);

Add_Menu ('Rental Record', 3, 1);

Add_Menu ('Do borrow', ...

This is a preview of the whole essay