[comp.lang.pascal] It would be convenient to have a TP UNDERLINE string function

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

that would let you write lines like,

WRITELN('I want to underline ',UNDERLINE('this phrase,'),' not this one');

The function would access WhereX and WhereY, set the text
attributes at the appropriate locations [BUT WHERE and HOW??????], 
and then return the string argument unchanged, to be serviced by
the writeln statement.

Does anyone know the appropriate magic?

bobb@vice.ICO.TEK.COM (Bob Beauchaine) (09/05/90)

In article <24397@adm.BRL.MIL> J_SCHULL@acc.haverford.edu (Jonathan Schull) writes:
>
>that would let you write lines like,
>
>WRITELN('I want to underline ',UNDERLINE('this phrase,'),' not this one');
>
>The function would access WhereX and WhereY, set the text
>attributes at the appropriate locations [BUT WHERE and HOW??????], 
>and then return the string argument unchanged, to be serviced by
>the writeln statement.
>
>Does anyone know the appropriate magic?


 Unless you're going to use EGA or VGA and create your own internal 
 font, you've got an impossible task.  The standard IBM character set
 is the default for all text modes, and doesn't allow for underlined
 characters.  There are ways to do what you want (with the appropriate
 monitor), but nothing as simple as you seem to think is possible.

 Sorry,

 Bob Beauchaine

ts@uwasa.fi (Timo Salmi LASK) (09/05/90)

In article <24397@adm.BRL.MIL> J_SCHULL@acc.haverford.edu (Jonathan Schull) writes:
>that would let you write lines like,
>WRITELN('I want to underline ',UNDERLINE('this phrase,'),' not this one');
>
>Does anyone know the appropriate magic?

Yes, sure.  And the magic is called the graphics mode.  

As it happens I've just written a TP program demonstrating (among
other graphics features) underlining text.  In fact underlining in
graphics is easy, programming a proper writeln substitute was much
more complicated, because it involved the problem of making the
graphics screen scroll in the same way as writeln scrolls in the
text mode.  - The demonstration will be released in the near future
for anynymous ftp from chyde.uwasa.fi. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

John G. Spragge <SPRAGGEJ@QUCDN.QueensU.CA> (09/05/90)

In article <5727@vice.ICO.TEK.COM>, bobb@vice.ICO.TEK.COM (Bob Beauchaine) says:
> Unless you're going to use EGA or VGA and create your own internal
> font, you've got an impossible task.  The standard IBM character set
> is the default for all text modes, and doesn't allow for underlined
> characters.  There are ways to do what you want (with the appropriate
> monitor), but nothing as simple as you seem to think is possible.
>
> Sorry,
>
> Bob Beauchaine

This is certainly true in graphics mode, but there are systems in
which this is not the case; an underline is provided as part of the
standard text attributes. In this case, setting the text colour to
blue (1) and the background to white (15) had the effect of producing
an underline. Whether this would work on all (nongraphic) monitors
of this type, I have no idea. But if your monitor/card DOES display
underlined text, getting it is simply a matter of setting the
appropriate text attribute bit, which in TURBO Pascal is a matter of
using the TEXTCOLOR and TEXTBACKGROUND routines.
-------

disclaimer: Queen's University merely supplies me with computer services, and
            they are responsible for neither my opinions or my ignorance.

John G. Spragge

decomyn@penguin.uss.tek.com (09/06/90)

In article <5727@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Bob Beauchaine) writes:
> Unless you're going to use EGA or VGA and create your own internal 
> font, you've got an impossible task.  The standard IBM character set
> is the default for all text modes, and doesn't allow for underlined
> characters. 

Ah, I see you haven't worked in monochrome recently.  Setting the background/
foreground attributes correctly will result in underlined text on a monochrome
card / display.  

True, the color cards will not do this.  Personally, I think it is a flaw in
the color cards.

Brendt Hess

ts@uwasa.fi (Timo Salmi LASK) (09/06/90)

In article <6512@tekgen.BV.TEK.COM> decomyn@penguin.uss.tek.com (Vergil William de Comyn) writes:
>In article <5727@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Bob Beauchaine) writes:
>> Unless you're going to use EGA or VGA and create your own internal 
>> font, you've got an impossible task.  The standard IBM character set
>> is the default for all text modes, and doesn't allow for underlined
>> characters. 
>
>Ah, I see you haven't worked in monochrome recently.  Setting the background/
>foreground attributes correctly will result in underlined text on a monochrome
>card / display.  

Ah, I see that you are merrily confusing Turbo Pascal features and
video card conventions.  The fact that monochorome monitors display
certain attributes by underlining has, I my opinion, very little to
do with generic underlining of text using Turbo Pascal.  The
solution shouldn't be dependent on (obsolete at that) display type. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

peter@cs.umu.se (Peter Lundberg) (09/10/90)

In article <1990Sep5.163924.2864@uwasa.fi> ts@uwasa.fi (Timo Salmi LASK) writes:
>In article <24397@adm.BRL.MIL> J_SCHULL@acc.haverford.edu (Jonathan Schull) writes:
>>that would let you write lines like,
>>WRITELN('I want to underline ',UNDERLINE('this phrase,'),' not this one');
>>
>>Does anyone know the appropriate magic?
>
>Yes, sure.  And the magic is called the graphics mode.  
>
There is absolutetly no need to do this in graphics mode, it's much easier
to write the string directly to memory, setting the attribute byte to it's
appropriate value. And it's a heck of a lot faster to!

pl
(peter@cs.umu.se)

eli@smectos.gang.umass.edu (Eli Brandt) (09/11/90)

In article <6512@tekgen.BV.TEK.COM> decomyn@penguin.uss.tek.com (Vergil William de Comyn) writes:
>In article <5727@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Bob Beauchaine) writes:
>> Unless you're going to use EGA or VGA and create your own internal 
>> font, you've got an impossible task.  The standard IBM character set
>> is the default for all text modes, and doesn't allow for underlined
>> characters. 
>
>Ah, I see you haven't worked in monochrome recently.  Setting the background/
>foreground attributes correctly will result in underlined text on a monochrome
>card / display.  
>
>True, the color cards will not do this.  Personally, I think it is a flaw in
>the color cards.
>
>Brendt Hess

As the original poster alluded to, it's possible to set up an underlined font
as your alternate font and then tell the video card that you want to treat the
intensity bit as the font-select bit.  Of course, you lose 8 of your 16 colors.
This is obviously only possible on EGA+ video.  To create your underlined font,
you could simply pull the current font from the A000 block (unprotecting it 
first), logical-OR everything with 64 (I *think* that's on the bottom), and
load it as the alternate font.  See a BIOS reference for help.


Disclaimer: hell, I'm not even a student at UMASS, much less a USENET liason
            or something.

ts@uwasa.fi (Timo Salmi LASK) (09/11/90)

In article <1990Sep10.144853.5157@cs.umu.se> peter@cs.umu.se (Peter Lundberg) writes:
>In article <1990Sep5.163924.2864@uwasa.fi> ts@uwasa.fi (Timo Salmi LASK) writes:
>>In article <24397@adm.BRL.MIL> J_SCHULL@acc.haverford.edu (Jonathan Schull) writes:
>>>that would let you write lines like,
>>>WRITELN('I want to underline ',UNDERLINE('this phrase,'),' not this one');
>>>Does anyone know the appropriate magic?
>>Yes, sure.  And the magic is called the graphics mode.  
>>
>There is absolutetly no need to do this in graphics mode, it's much easier
>to write the string directly to memory, setting the attribute byte to it's
>appropriate value. And it's a heck of a lot faster to!

Ah, the there is a catch in your statement.  Unless you have an
"appropriate" graphics adapter there is no "appropriate" value for
the attribute byte.  Seriously, this solution is not general.  The
fastest kludge is probably using the ansi.sys trick suggested by
several posters.  Else hercules text mode simulation (not always
available, mind you) by setting your appropriate attribute byte, or
back to the general graphics solution. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

bobb@vice.ICO.TEK.COM (Bob Beauchaine) (09/11/90)

In article <1990Sep10.144853.5157@cs.umu.se> peter@cs.umu.se (Peter Lundberg) writes:
>In article <1990Sep5.163924.2864@uwasa.fi> ts@uwasa.fi (Timo Salmi LASK) writes:
>>In article <24397@adm.BRL.MIL> J_SCHULL@acc.haverford.edu (Jonathan Schull) writes:
>>>that would let you write lines like,
>>>WRITELN('I want to underline ',UNDERLINE('this phrase,'),' not this one');
>>>
>>>Does anyone know the appropriate magic?
>>
>>Yes, sure.  And the magic is called the graphics mode.  
>>
>There is absolutetly no need to do this in graphics mode, it's much easier
>to write the string directly to memory, setting the attribute byte to it's
>appropriate value. And it's a heck of a lot faster to!
>
>pl
>(peter@cs.umu.se)


 Can we lay this issue to rest once and for all?  As the original responder
 to this post, and subsequently having my repsonse thoroughly shelled, here
 is the bottom line:

 Yes, *some* monitors allow underlining by simple attribute setting.  Most,
 however, do not, including those that are fast becoming the "standards".
 No color monitor allows simple underlining.  If you are looking for a 
 portable method for underlining characters in text mode, one that will 
 work on the majority of monitors, YOU CAN'T DO IT IN TURBO PASCAL.  In fact,
 you can't do it on most IBM's or clones.  End of discussion.

 (Sorry, suffering from an ithcy flame finger today).

 Bob Beauchaine

anandm@walt.cc.utexas.edu (Anand Mandapati) (09/15/90)

I have and am working on text fonts on the EGA/VGA system.  Currently, I am
working on the italicize routines for any size font.  But, in text mode the
underline function is very easy to do.  I would post the code here, but I    
don't have it with me now.  The basic way to do it, is to load the text font
into memory using INT 10, FUNC 30 to first find the segment and offset of the
standard 8x14 or 8x16 font.  Then, for each letter, using a for-do loop,
you would just turn the bits of the last scan line(14 or 16) on, thereby 
underlining all the letters.  Actually, the easiest way to do it is to find
the memory location of the font, copy it into an array of bytes, modify it,
and then load the font back using INT 10, FUNC 10.  

Anand "I also go by Big Brother" Mandapati

ts@uwasa.fi (Timo Salmi LASK) (09/15/90)

In article <37202@ut-emx> anandm@walt.cc.utexas.edu (Anand Mandapati) writes:
>underlining all the letters.  Actually, the easiest way to do it is to find
>the memory location of the font, copy it into an array of bytes, modify it,
>and then load the font back using INT 10, FUNC 10.  

One minor detail.  How will you treat the upper part of the ascii
table?  My recall may be entirely wrong, but isn't it located at a
separate memory address?

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun