home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / IOFUNC.ZIP / YPRNT.LIB < prev    next >
Encoding:
Text File  |  1986-04-12  |  4.1 KB  |  101 lines

  1. {           ╔═══╦══════════════════════════════════════════════╦═══╗
  2.             ║   ║         Pascal Library by Scott Wade         ║   ║
  3.             ║   ║           715 FM 1959      Apt 310           ║   ║
  4.             ║   ║           Houston, TX 77034                  ║   ║
  5.      ┌──────╨───╨──────────────────────────────────────────────╨───╨──────┐
  6.      │  This  group of routines is contributed to public domain,  and no  │
  7.      │  one can possibly get any commercial value out of them since they  │
  8.      │  must be used in other programs. I require that if these are used  │
  9.      │  as is in  any  program,  that this banner remain with the source  │
  10.      │  code of the program.  I would appreciate any comments or sugges-  │
  11.      │  tions on improvements, & am curious to hear how these are used.   │
  12.      │  You can leave a message for me on these BBS's:                    │
  13.      │          Ziggy's  821-1391         ScoreBoard  583-7848            │
  14.      │          TBL-COMM 661-9040         Test-Mode   660-9252            │
  15.      └────────────────────────────────────────────────────────────────────┘
  16. YPRNT.LIB v1.0   CRT display library.
  17.  v1.0: 11/18/85 : Original. Prints the sentence on the CRT. If longer than 80
  18.        chars, will break at last space before 80. Will print the next sentence
  19. *****  after this one, not on next line down. wX is globally passed, so caller
  20. *****  cannot update it without massively trashing the visual effect on CRT.
  21. *****  This will hang if the line given to it has a string of characters with-
  22. *****  out spaces longer than 79 characters. Maybe someday I'll fix it.
  23.        But then again, maybe I won't.
  24.  v1.1: 12/13/85 : yCaps added. This will capitalize the first letter, and then
  25.        add a period, then call yPrnt with the sentence. If OutLin ends in ^,
  26.        this will insert the . right before it,so the RET is unaffected.
  27.  v1.2: 2 /22/86 : yPrntI added. This will yPrnt an integer number in Just
  28.        spaces.        }
  29.  
  30. Procedure yPrnt( var wX : Integer; var OutLin : Buffer );                {}
  31. var
  32.    CRFlag,    CRAfter  :  Boolean ;
  33.               LineLng  :  Integer ;
  34.               PartLin  :  Buffer  ;
  35.  
  36.    Procedure yBreakit( var PartLin : Buffer );                           {}
  37.    var
  38.       BreakAt, Loop :  Integer ;
  39.    begin
  40.       BreakAt := 0;
  41.       For Loop :=  1 to (LineLng - wX) do
  42.          If PartLin[ Loop ] = ' ' then BreakAt := Loop ;
  43.       If BreakAt = 0 then   CrFlag := True   else
  44.          PartLin := Copy( PartLin, 1, BreakAt - 1 );
  45.    end{ yBreakit };
  46.  
  47. begin{ yPrnt }
  48.    LineLng := 81 ;
  49.    CrFlag  := False ;
  50.    CRAfter := False ;
  51.    While OutLin[ Length( OutLin )] = ' ' do
  52.       Delete( OutLin, Length( OutLin), 1);
  53.    While Length( OutLin ) > 0 do begin
  54.       If OutLin[ Length( OutLin )] = '^' then begin
  55.          CRAfter := True ;
  56.          Delete( OutLin, Length( OutLin),  1)
  57.       end{ If ^ };
  58.       PartLin := OutLin ;
  59.  
  60.       If wX + Length( OutLin ) + 1 > Linelng then yBreakit( PartLin );{}
  61.  
  62.       If Not CrFlag then begin
  63.          If wX > 1 then write( CON,' ');
  64.          write( CON, PartLin );
  65.          wX     := wX + Length( PartLin ) + 1;
  66.          Delete( OutLin, 1, Length(PartLin) + 1);
  67.       end{ If Not CrFlag } else begin
  68.          writeln( CON );
  69.          wX := 1;
  70.          crflag := false
  71.       end{ If not CR else };
  72.    end{ While };
  73.    If CrAfter then begin
  74.       writeln( CON );
  75.       wX := 1;
  76.       CrAfter := False ;
  77.    end{ If CrAfter };
  78. end{ yPrnt };
  79.  
  80. procedure yCaps( var wX : integer; var OutLin : Buffer );
  81. begin
  82.    OutLin[ 1 ] := upcase( OutLin[ 1 ]);
  83.    if OutLin[ Length( OutLin )] = '^' then begin
  84.       If OutLin[ Length( OutLin )-1] <> '.' then
  85.          Insert( '.', OutLin,Length( OutLin ));
  86.    end else begin
  87.       If OutLin[ Length( OutLin )] <> '.' then
  88.          OutLin := OutLin + '.';
  89.    end;
  90.    yPrnt( wX, OutLin );
  91. end{ yCaps };
  92.  
  93. procedure yPrntI( var wX: Integer ; Just, OutInt : Integer );
  94. var OutLin : Buffer ;
  95. begin
  96.    Str( OutInt:Just, OutLin);
  97.    yPrnt( wX, OutLin );
  98. end{ yPrntI };
  99.  
  100. { yPrnt.LIB
  101. *****************************************************************************}