[comp.lang.pascal] The UNDERLINE SOLUTION announced yesterday does not work in a

J_SCHULL@acc.haverford.edu (Jonathan Schull) (09/07/90)

function embedded in a writeln statement, for reasons mentioned
in one of the postings--the function (which manipulated
TextColor and TextBackground) is evaluated and executed before
ANY of the writing happens.

The following trick (suggested by a list member whose name I've
lost) DOES work, but requires ANSI.SYS (Turbo's CRT unit is NOT
needed).

function UNDERLINE (s: string): string;
  begin
  UNDERLINE := #27 + '[4m' + s + #27 + '[0m';
end; {UNDERLINE}

begin
  writeln('This is ',UNDERLINE('underlined!'),' This isnt');
  writeln('It requires ANSI.SYS')
end.
===================================================================

One can also declare two constants, as follows

const Uon=#27 + '[4m';
const Uoff=#27 + '[0m';
begin
  writeln('This is another way of ',UON,'underlining',UOFF,' using constants.');
  writeln('It requires ANSI.SYS')
end.

I haven't tried implementing the writing-to-video-memory
approach (and probably won't....).

jrwsnsr@nmt.edu (Jonathan R. Watts) (09/09/90)

J_SCHULL@acc.haverford.edu (Jonathan Schull) mentions a way to set underline
using ANSI.SYS, and mentions that it does not require the CRT unit.  Actually,
it won't work if you use the CRT unit unless you disable CRT's default
behavior of writing directly to the screen.

  - Jonathan Watts

jrwsnsr@jupiter.nmt.edu (Internet address)