home *** CD-ROM | disk | FTP | other *** search
- program bbtotext; {convert to text file}
-
- (****************************************************************)
- (* *)
- (* LITTLE BLACK BOOK *)
- (* *)
- (* Black book to Text file conversion *)
- (* *)
- (* Copyright (C) 1986 by *)
- (* MARTIN C. BEATTIE *)
- (* *)
- (****************************************************************)
-
- {$v-}
-
- TYPE
- Str80 = STRING [80];
- Buffer = STRING [255];
- Rectype = (S, P);
- Bbrectype =
- RECORD
- CASE Rectype OF
- P: (
- RecStatus : integer; (* Record Status *)
- LastName : string[20]; (* last name *)
- FirstName : string[15]; (* first name *)
- address1 : string[30]; (* Address 1 *)
- address2 : string[30]; (* Address 2 *)
- Phone : string[14]; (* Phone number *)
- Note : string[25] (* remarks 1 *)
- );
- S: ( Int1, Int2, Int3, NumRecs: integer);
- end;
-
- VAR
- Infile: FILE OF Bbrectype;
- Outfile: Text;
- Returnfile: FILE;
- Infilename, Outfilename: STRING [20];
- Bbrec: Bbrectype;
- Lastrec, I, X, Y: Integer;
- Ch: Char;
- Ok: Boolean;
-
- (* Convert does the job *)
-
-
- PROCEDURE Convert;
- BEGIN
- Writeln('Creating ', Outfilename, ' file from BLKBOOK.DAT');
- Write('Working....');
- Read(Infile, Bbrec); {get turbo access status record}
- Lastrec := Bbrec.Numrecs;
- FOR I := 1 TO Lastrec - 1 DO
- BEGIN
- Read(Infile, Bbrec);
- WITH Bbrec DO
- IF Recstatus = 0 THEN
- Writeln(Outfile, Lastname, '': 20 - Length(Lastname), Firstname, '':
- 15 - Length(Firstname), Address1, '': 30 - Length(Address1),
- Address2, '': 30 - Length(Address2), Phone, '': 14 - Length(Phone),
- Note, '': 25 - Length(Note));
-
- END;
- Writeln('Done.');
- Write(Outfile, Chr($1A)); {mark end of file}
- END;
-
- BEGIN
- Writeln('Type in name of text file to be created (<filename>.TXT): ');
- Writeln('Maximum of 8 characters, the filetype TXT will be added.');
- Write('> ');
- X := Wherex;
- Y := Wherey;
- REPEAT
- Gotoxy(X, Y);
- Clreol;
- Readln(Outfilename);
- UNTIL Length(Outfilename) <= 8;
- Outfilename := Outfilename + '.TXT';
- Infilename := 'blkbook.dat';
- Assign(Infile, Infilename);
- Assign(Outfile, Outfilename);
- {$i-}
- Reset(Infile);
- Ok := (Ioresult = 0);
- IF Ok THEN
- BEGIN
- Rewrite(Outfile);
- Ok := (Ioresult = 0);
- IF Ok THEN
- BEGIN
- Convert;
- Close(Infile);
- END
- ELSE Writeln(' Bad output file name');
- Close(Outfile);
- END
- ELSE Writeln('BlkBook.DAT file not found');
- IF Ok THEN
- BEGIN
- Writeln;
- Writeln('You now have a Text file named ', Outfilename, '. Each Record');
- Writeln('is on a separate line 160 characters wide. You may examine it');
- Writeln('with a text editor such as WordStar (in the NonDocument mode),');
- Writeln('TurboPascals editor, SideKick, or EDLIN. The individual fields');
- Writeln('are separated only by their field length and must be maintained');
- Writeln('in order for it to load back into Blaque Book properly.');
- END;
- Writeln;
- Writeln('Type "Q" to quit, any other key will return to utility menu.');
- Read(Kbd, Ch);
- Assign(Returnfile, 'BBUTIL.COM');
- IF Upcase(Ch) <> 'Q' THEN Execute(Returnfile);
- END.
-