home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TURBO5.ZIP / LOCASE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-12-26  |  3.1 KB  |  127 lines

  1. Program LowCase(Input, Output);
  2.  
  3. (* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
  4. (*   This program will change all upper case alphabetic characters to       *)
  5. (* its lower case equivilant.                                               *)
  6. (*                                                                          *)
  7. (*   Input for this program is a sequential disk file.  Output can be       *)
  8. (* to the monitor screen, the printer, or a disk file.                      *)
  9. (*                                                                          *)
  10. (*   You will need to get BOX.PAS for this to run, use it as an include     *)
  11. (* file.                                                                    *)
  12. (* Written by Bill Cote - 71256,402                                         *)
  13. (* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *)
  14.  
  15. Type
  16.   String12 = String[12];
  17.   String255 = String[80];
  18.  
  19. Var
  20.   Screen,
  21.   Printer,
  22.   Disk            : Boolean;
  23.   Answer          : Char;
  24.   FileName        : String12;
  25.   LowCaseRec      : String255;
  26.   InputRec,
  27.   OutputRec       : Text;
  28.  
  29. Procedure SetScreen;
  30.   Begin
  31.     TextMode(C80);
  32.     TextColor(White);
  33.     TextBackGround(Blue);
  34.     GraphBackGround(Blue);
  35.     ClrScr
  36.   End;
  37.  
  38. Procedure ChangeCase;
  39. Var
  40.   I,
  41.   X : Integer;
  42.  
  43.   Begin
  44.     For I := 1 To Length(LowCaseRec) Do
  45.       Begin
  46.         If (Ord(LowCaseRec[I]) < 65) Or (Ord(LowCaseRec[I]) > 90) Then
  47.           LowCaseRec[I] := LowCaseRec[I]
  48.         Else
  49.           Begin
  50.             X := Ord(LowCaseRec[I]);
  51.             LowCaseRec[I] := Char(X + $20)
  52.           End;
  53.       End;
  54.   End;
  55.  
  56. (*$I box.pas *)
  57.  
  58. Begin
  59.   SetScreen;
  60.   DrawBox(11,4,62,11);
  61.   Window(12,5,72,14);
  62.   TextBackGround(LightGray);
  63.   ClrScr;
  64.   Screen := False;
  65.   Printer := False;
  66.   Disk := False;
  67.  
  68.   GotoXY(3,2);
  69.   Writeln('Enter the name of the file to be converted to LOWER CASE');
  70.   GotoXY(3,4);
  71.   Readln(FileName);
  72.   Assign(InputRec,FileName);
  73.   {$I-} Reset(InputRec) {$I+};
  74.   If IOresult <> 0 Then
  75.     Begin
  76.       GotoXY(3,6);
  77.       TextColor(Red);
  78.       Writeln('File ''',FileName,''' not found.');
  79.       Halt
  80.     End;
  81.  
  82.   Write;
  83.   GotoXY(18,6);
  84.   Write('Enter ONE of the following');
  85.   GotoXY(18,7);
  86.   Write('1 = Screen Listing');
  87.   GotoXY(18,8);
  88.   Write('2 = Printer Listing');
  89.   GotoXY(18,9);
  90.   Write('3 = Output to disk file');
  91.   GotoXY(18,10);
  92.   Readln(Answer);
  93.  
  94.   If Answer = '1' Then
  95.     Screen := True
  96.   Else
  97.     If Answer = '2' Then
  98.       Printer := True
  99.     Else
  100.       If Answer = '3' Then
  101.         Begin
  102.           Writeln;
  103.           Writeln('Enter the disk file name');
  104.           Readln(FileName);
  105.           Assign(OutputRec,FileName);
  106.           Rewrite(OutputRec);
  107.           Disk := True
  108.         End;
  109.  
  110.   Window(1,1,80,25);
  111.   TextBackGround(Blue);
  112.   ClrScr;
  113.  
  114.   Repeat
  115.     Readln(InputRec,LowCaseRec);
  116.     ChangeCase;
  117.     If Screen Then
  118.       Writeln(LowCaseRec);
  119.     If Printer Then
  120.       Writeln(Lst,LowCaseRec);
  121.     If Disk Then
  122.       Writeln(OutputRec,LowCaseRec);
  123.   Until Eof(InputRec);
  124.  
  125.   Close(OutputRec)
  126.  
  127. End.