home *** CD-ROM | disk | FTP | other *** search
- -- DAT2TXT.ADA Ver. 1.00 25-MAR-1988
- -- Copyright 1988 John J. Herro
- -- Software Innovations Technology
- -- 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706 (407)951-0233
- --
- -- Run this program on a PC before installing ADA-TUTR on another computer.
- -- It translates ADA-TUTR.DAT to TUTOR.TXT, a text file that can be easily
- -- transferred to other computers. Then compile and run TXT2DAT.ADA on the
- -- other machine to create ADA-TUTR.DAT from TUTOR.TXT.
- --
- --
- with DIRECT_IO, TEXT_IO;
- procedure DAT2TXT is
- subtype BLOCK_SUBTYPE is STRING(1 .. 64);
- package RANDOM_IO is new DIRECT_IO(BLOCK_SUBTYPE);
- DATA_FILE : RANDOM_IO.FILE_TYPE; -- The input file.
- TEXT_FILE : TEXT_IO.FILE_TYPE; -- The output file.
- BLOCK : BLOCK_SUBTYPE; -- A block of 64 bytes being copied.
- OK : BOOLEAN := TRUE; -- True when both files open successfully.
- LEGAL_NOTE : constant STRING(1 .. 30) := " Copyright 1988 John J. Herro ";
- -- LEGAL_NOTE isn't used by the program, but it causes
- -- the compiler to place this string in the .EXE file.
- begin
- begin
- RANDOM_IO.OPEN(DATA_FILE, RANDOM_IO.IN_FILE, NAME => "ADA-TUTR.DAT");
- exception
- when RANDOM_IO.NAME_ERROR =>
- TEXT_IO.PUT_LINE(
- "I'm sorry. The file ADA-TUTR.DAT seems to be missing.");
- OK := FALSE;
- end;
- begin
- TEXT_IO.CREATE(TEXT_FILE, NAME => "TUTOR.TXT");
- exception
- when others =>
- TEXT_IO.PUT_LINE("I'm sorry. I can't seem to create TUTOR.TXT.");
- TEXT_IO.PUT_LINE("Perhaps that file already exists?");
- OK := FALSE;
- end;
- if OK then
- while not RANDOM_IO.END_OF_FILE(DATA_FILE) loop
- RANDOM_IO.READ(DATA_FILE, ITEM => BLOCK);
- for I in BLOCK'RANGE loop
- if BLOCK(I) = ASCII.CR then
- BLOCK(I) := '~';
- elsif BLOCK(I) = ASCII.LF then
- BLOCK(I) := '^';
- end if;
- end loop;
- TEXT_IO.PUT_LINE(FILE => TEXT_FILE, ITEM => BLOCK);
- end loop;
- end if;
- TEXT_IO.PUT_LINE("TUTOR.TXT created.");
- end DAT2TXT;
-
-