home *** CD-ROM | disk | FTP | other *** search
- label Menu;
- const
- Changing : Boolean = False;
- Changed : Boolean = False;
- DiskFull : Boolean = False;
- InRange : Boolean = True;
- type
- Entry = record
- First_name : String[20];
- Last_Name : String[20];
- Street_Address : String[25];
- City : String[15];
- State : String[2];
- Zip_Code : String[10];
- Home_Phone : String[17];
- Business_Phone : String[17];
- Occupation : String[25];
- end;
- Name = String[26];
- var
- First_Name,Last_name : String[20];
- Street_Address,Occupation : String[25];
- City : String[15];
- Home_Phone,Business_Phone : String[17];
- Zip_Code : String[10];
- State : String[2];
- Choice : Char;
- DataFile : File of Entry;
- Individual : Entry;
- Search_Type,Search_For : String[30];
-
- { FUNCTION TO CHECK AND SEE IF A FILE EXISTS ON THE LOGGED DISK }
-
- function Exist(FileName : Name) : boolean;
- var
- Fil : File;
- begin
- Assign(Fil,FileName);
- {$I-}
- Reset(Fil);
- {$I+}
- Exist := (IOresult = 0)
- end;
-
- { PROCEDURE TO CHECK LENGTH OF INPUT LINE AND PRINT ERROR MESSAGE }
-
- procedure Check_Length(Line : Name; Max_Len : Integer);
- begin
- GotoXY(1,18); ClrEol;
- if length(Line) > Max_Len then
- begin
- GotoXY(20,18);
- write(^G'Input Line TOO LONG. Maximum length ',Max_Len);
- InRange := False;
- Exit;
- end;
- InRange := True;
- end;
-
- { PROCEDURE TO DIAL NUMBER WITH MODEM. ATDT IS HAYES ATTENTION AND DIAL
- WITH TONE COMMAND. IF MODEM IS NON HAYES, CHANGE TO WHATEVER WORKS FOR
- YOUR MODEM. }
-
- procedure Dial_Number(Home,Business : Name);
- var
- Continue : Char;
- begin
- GotoXY(1,22); ClrEol;
- GotoXY(22,22);
- write('(H)ome Phone (B)usiness Phone');
- read(Kbd,Continue);
- case Continue of
- 'H','h' : writeln(Aux,'ATDT' + Home);
- 'B','b' : writeln(Aux,'ATDT' + Business);
- end;
- Delay(4000);
- GotoXY(1,22); ClrEol;
- GotoXY(23,22);
- write('(ANY KEY) to HANG UP and CONTINUE ');
- read(Kbd,Continue);
- writeln(Aux,'ATH');
- end;
-
- { PROCEDURE TO PRINT NAME, ADDRESS, AND PHONE NUMBERS ON PRINTER. }
-
- procedure Print_Name(First,Last,Address,Cty,St,Zip,HP,BP : Name);
- begin
- writeln(Lst);
- writeln(Lst);
- writeln(Lst,First,' ',Last);
- writeln(Lst,Address);
- writeln(Lst,Cty,', ',St,' ',Zip);
- writeln(Lst);
- writeln(Lst,' Home Phone : ',HP);
- writeln(Lst,'Business Phone : ',BP);
- write;
- end;
-
- { PROCEDURE TO ENTER NAMES AT END OF FILE. FIRST CHECKS TO SEE IF DATA
- FILE EXISTS. THEN CHECKS TO BE SURE THERE IS ROOM ON THE DISK. }
-
- procedure Enter_Names;
- var
- Answer : Char;
- Test_Line : String[30];
- begin
- assign(DataFile,'PHONE.DTA');
- if not Exist('PHONE.DTA') then Rewrite(DataFile);
- Reset(DataFile);
- {$I-} seek(DataFile,FileSize(DataFile)) {$I+};
- DiskFull := (IOresult = $F0);
- if DiskFull then
- begin
- GotoXY(13,20); ClrEol;
- write(^G'DISK FULL. Exit Program And ERASE Unnecessary Files.');
- Exit;
- end;
- with Individual do
- begin
- Repeat
- ClrScr;
- GotoXY(1,1); write('Enter First Name :');
- repeat
- GotoXY(35,1); ClrEol; read(Test_Line);
- Check_Length(Test_Line,20);
- until InRange;
- First_Name := Test_Line;
- GotoXY(1,2); write('Enter Last Name :');
- repeat
- GotoXY(35,2); ClrEol; read(Test_Line);
- Check_Length(Test_Line,20);
- until InRange;
- Last_Name := Test_Line;
- GotoXY(1,3); ClrEol; write('Enter Street Address :');
- repeat
- GotoXY(35,3); ClrEol; read(Test_Line);
- Check_Length(Test_Line,25);
- until InRange;
- Street_Address := Test_Line;
- GotoXY(1,4); write('Enter City :');
- repeat
- GotoXY(35,4); ClrEol; read(Test_Line);
- Check_Length(Test_Line,15);
- until InRange;
- City := Test_Line;
- GotoXY(1,5); write('Enter Two Letter State Code :');
- repeat
- GotoXY(35,5); ClrEol; read(Test_Line);
- Check_Length(Test_Line,2);
- until InRange;
- State := Test_Line;
- State[1] := UpCase(State[1]); State[2] := UpCase(State[2]);
- GotoXY(1,6); write('Enter Zip Code :');
- repeat
- GotoXY(35,6); ClrEol; read(Test_Line);
- Check_Length(Test_Line,10);
- until InRange;
- Zip_Code := Test_Line;
- GotoXY(1,20);
- writeln(^G'Enter Phone Numbers EXACTLY As You Would Dial Them.');
- writeln('Use Punctuation To Make Them More Readable If Desired.');
- write('Examples: 15551212 1-555-1212 1(615)555-1212 1/615/555-1212');
- GotoXY(1,7); write('Enter Home Phone Number :');
- repeat
- GotoXY(35,7); ClrEol; read(Test_Line);
- Check_Length(Test_Line,17);
- until InRange;
- Home_Phone := Test_Line;
- GotoXY(1,8); write('Enter Business Phone Number :');
- repeat
- GotoXY(35,8); ClrEol; read(Test_Line);
- Check_Length(Test_Line,17);
- until InRange;
- Business_phone := Test_Line;
- GotoXY(1,20); ClrEol; GotoXY(1,21); ClrEol;
- GotoXY(1,22); ClrEol;
- GotoXY(1,9); write('Enter Occupation :');
- repeat
- GotoXY(35,9); ClrEol; read(Test_Line);
- Check_Length(Test_Line,25);
- until InRange;
- Occupation := Test_Line;
- writeln; writeln;
- write('Are ALL Entries Correct (Y/N)? ');
- read(Kbd,Answer);
- Until Answer in ['Y','y'];
- write('Yes');
- write(DataFile,Individual);
- Flush(DataFile);
- Close(DataFile);
- end;
- end;
-
- { PROCEDURE TO CHANGE FIELDS IN RECORD. CURSOR STARTS AT THE BEGINNING
- OF EACH FIELD. CHANGES OVERWRITE OLD DATA AND SCREEN IS REFRESHED.
- ENTERING A CARRIAGE RETURN LEAVES FIELD UNCHANGED AND ADVANCES CURSOR
- TO THE START OF THE NEXT FIELD. AFTER EACH CHANGE THE CURSOR RETURNS
- TO THE FIRST FIELD. ENTERING A Q<CR> THERE WILL END CHANGES AND
- REFRESH SCREEN }
-
- procedure Change_Names(FilRec : Integer);
- var
- Update : Name;
- begin
- GotoXY(1,22); ClrEol;
- write(' (RETURN) Leaves Field Unchanged (Q) For Last Name To Quit');
- with Individual do
- begin
- GotoXY(25,7); Read(Update);
- while (Update <> 'Q') and (Update <> 'q') do
- begin
- if Update <> '' then
- begin
- Last_Name := Update; Changed := True;
- Exit;
- end;
- GotoXY((length(Last_Name)+27),7); Read(Update);
- if Update <> '' then
- begin
- First_Name := Update; Changed := True;
- Exit;
- end;
- GotoXY(25,8); Read(Update);
- if Update <> '' then
- begin
- Street_Address := Update; Changed := True;
- Exit;
- end;
- GotoXY(25,9); Read(Update);
- if Update <> '' then
- begin
- City := Update; Changed := True;
- Exit;
- end;
- GotoXY((length(City)+27),9); Read(Update);
- if Update <> '' then
- begin
- State := Update; Changed := True;
- Exit;
- end;
- GotoXY((length(City)+31),9); Read(Update);
- if Update <> '' then
- begin
- Zip_Code := Update; Changed := True;
- Exit;
- end;
- GotoXY(25,11); Read(Update);
- if Update <> '' then
- begin
- Home_Phone := Update; Changed := True;
- Exit;
- end;
- GotoXY(25,12); Read(Update);
- if Update <> '' then
- begin
- Business_Phone := Update; Changed := True;
- Exit;
- end;
- GotoXY(25,14); Read(Update);
- if Update <> '' then
- begin
- Occupation := Update; Changed := True;
- end;
- end;
- Changing := False;
- if Changed then
- begin
- Seek(DataFile,FilRec);
- Write(DataFile,Individual);
- Changed := False;
- end;
- end;
- end;
-
- { PROCEDURE TO SEARCH DATABASE BY INDIVIDUAL FIELD IN RECORD. CHECKS
- TO SEE IF DATABASE EXISTS FIRST. }
-
- procedure Search_Names;
- label Rewrite;
- var
- I,J : Integer;
- Continue : Char;
- Search_Key : String[25];
- begin
- ClrScr; GotoXY(4,12);
- write('Enter ',Search_Type,' : ');
- readln(Search_Key);
- assign(DataFile,'PHONE.DTA');
- if not Exist('PHONE.DTA') then
- begin
- writeln('**'^G' CANNOT FIND DATA FILE **');
- halt;
- end;
- reset(DataFile);
- with Individual do
- begin
- I := 0; ClrScr;
- GotoXY(12,7);
- write('FULL NAME :');
- GotoXY(7,8);
- write('STREET ADDRESS :');
- GotoXY(4,9);
- write('CITY, STATE & ZIP :');
- GotoXY(6,11);
- write('AREA/HOME PHONE :');
- GotoXY(2,12);
- write('AREA/BUSINESS PHONE :');
- GotoXY(11,14);
- write('OCCUPATION :');
- GotoXY(1,21);
- writeln(' ==============================================================================');
- writeln;
- write(' ==============================================================================');
- while not EOF(DataFile) do
- begin
- seek(DataFile,I); read(DataFile,Individual);
- case Choice of
- '1' : Search_For := First_Name;
- '2' : Search_For := Last_Name;
- '3' : Search_For := Street_Address;
- '4' : Search_For := City;
- '5' : Search_For := State;
- '6' : Search_For := Zip_Code;
- '7' : Search_For := Home_Phone;
- '8' : Search_For := Business_Phone;
- '9' : Search_For := Occupation;
- end;
- if(Copy(Search_For,1,Length(Search_Key)))
- = Search_Key then
- begin
- Rewrite: GotoXY(25,7); ClrEol;
- write(Last_Name + ', ' + First_Name);
- GotoXY(25,8); ClrEol;
- write(Street_Address);
- GotoXY(25,9); ClrEol;
- write(City + ', ' + State + ' ' + Zip_Code);
- GotoXY(25,11); ClrEol;
- write(Home_Phone);
- GotoXY(25,12); ClrEol;
- write(Business_Phone);
- GotoXY(25,14); ClrEol;
- write(Occupation);
- if Changing then
- begin
- Change_Names(I);
- Goto Rewrite;
- end;
- GotoXY(1,22); ClrEol;
- GotoXY(15,22);
- write(' (C)hange (D)ial (P)rint (ANY KEY) to CONTINUE ');
- read(Kbd,Continue);
- case Continue of
- 'D','d' : Dial_Number(Home_Phone,
- Business_Phone);
- 'P','p' : Print_Name(First_Name,Last_Name,
- Street_Address,City,State,
- Zip_Code,Home_Phone,
- Business_Phone);
- 'C','c' : begin
- Changing := True;
- Change_Names(I);
- Goto Rewrite;
- end;
- end;
- end;
- I := I + 1
- end;
- Close(DataFile);
- end;
- end;
-
- { ************************************************************************
- * *
- * MAIN PROGRAM *
- * *
- ************************************************************************ }
-
- begin
- Menu: ClrScr;
- writeln; writeln; writeln; writeln;
- writeln(' * What Do You Want To Search By *');
- writeln(' =================================');
- writeln;
- writeln(' 1) First Name');
- writeln(' 2) Last Name');
- writeln(' 3) Street Address');
- writeln(' 4) City');
- writeln(' 5) State');
- writeln(' 6) Zip Code');
- writeln(' 7) Home Phone');
- writeln(' 8) Business Phone');
- writeln(' 9) Occupation');
- GotoXY(1,21);
- writeln(' ==============================================================================');
- writeln(' (1 thru 9) to Search (E)nter Member e(X)it to CP/M');
- write(' ==============================================================================');
- GotoXY(73,22);
- readln(Choice);
- Case Choice of
- '1' : begin
- Search_Type := 'First Name';
- Search_Names;
- end;
- '2' : begin
- Search_Type := 'Last Name';
- Search_Names;
- end;
- '3' : begin
- Search_Type := 'Street Address';
- Search_Names;
- end;
- '4' : begin
- Search_Type := 'City';
- Search_Names;
- end;
- '5' : begin
- Search_Type := 'Two Letter State Code';
- Search_Names;
- end;
- '6' : begin
- Search_Type := 'Zip Code';
- Search_Names;
- end;
- '7' : begin
- Search_Type := 'Home Phone ###/###-####';
- Search_Names;
- end;
- '8' : begin
- Search_Type := 'Business Phone ###/###-####';
- Search_Names;
- end;
- '9' : begin
- Search_Type := 'Occupation';
- Search_Names;
- end;
- 'E','e' : Enter_Names;
- 'X','x' : begin
- ClrScr; GotoXY(1,10);
- write('Exit to CP/M (Y/N)? ');
- read(Kbd,Choice);
- case Choice of
- 'Y','y' : begin
- writeln('Yes');
- writeln; writeln;
- writeln('Program by Joseph Fall');
- writeln('CIS 76555,37');
- writeln('Turbo Pascal ver. 1.0');
- writeln('May 1, 1985');
- Halt;
- end;
- else Goto Menu;
- end;
- end;
- else begin
- write(^G);
- goto Menu;
- end;
- end;
- goto Menu;
- end.
-
- write(^G);
- goto Menu;
-