[comp.sys.ibm.pc.programmer] Sticky Problems with C on IBM-compatibles

psrc@pegasus.ATT.COM (Paul S. R. Chisholm) (02/18/90)

< Krasny Oktyabr:  the hunt is on, March 2, 1990 >

In article <492@bilver.UUCP>, alex@bilver.UUCP (Alex Matulich) writes:
> 1) Is there a faster way to display character strings than using puts()
>    or printf() without resorting to assembly language?

Have you tried the console video functions described in the first part
of chapter 8 of the (TC 2.0) User's Guide?

> 2) If I have a text screen set up like I want it, is it possible to save
>    it away somehow so I can display it anytime later by dumping it back
>    into the video memory?

Try gettext().

> 3) How do I display inverse, boldface, or multicolored text without
>    resorting to using ANSI.SYS?

Use the functions I've already mentioned, with textattr(), textcolor(),
and textbackground(), as appropriate.

> 4) The critical error handler gets invoked when the printer needs more
>    paper.  How do I tell if the printer is offline?  The computer hung up
>    last time I tried using fopen() to get a file handle to a printer that
>    was powered off.

I don't think it'll really hang; it *will* wait for many seconds,
giving the printer a chance to get on-line.  You'll need to replace the
critical error handler (using the setvect() function) with your own.
It should check everything you're interested in, and the rest should be
ignored or passed to the original handler.  Be sure to replace the
original when you're done!  Check the Norton or Duncan books for
details.

> 5) If a user of my software has a serial printer, how do I set up the
>    serial port parameters (baud rate, xon/xoff, databits, stopbits, etc)?

I think you're going to have to invoke interrupt 20, service 0 "by
hand".  (You can do this with the intr() functions, or one of the other
int*() functions.)  Norton and Duncan have the details.

> 6) I expected to find a function somewhere in the standard library that
>    would read the contents of a disk directory into a string array.

Try findfirst() and findnext().  They're not quite what you asked for,
but they provide the basics.

> 7) If my PATH environment variable is set up so that I can run one of my
>    programs from a directory different than the one containing my program,
>    how it possible for my program to determine the directory IT started
>    from?  Or does that information have to be hard-coded in my program?

DOS 3.0 and later generate enough information for the TC start-up code
to put the path name in argv[0].  In version 1.x and 2.x, your best bet
is to (yuchh) search the current directory, and then the path,
yourself.

> If you know the answers to at least one of the above questions, or if you
> know the title of a helpful book I can look up, PLEASE e-mail me a reply.

Try the second editions of either of these:  THE PETER NORTON
PROGRAMMER'S GUIDE TO THE IBM PC by (surprise) Peter Norton, or Ray
Duncan's ADVANCED MS-DOS.

>      ///  Alex Matulich
>     ///  Unicorn Research Corp, 4621 N Landmark Dr, Orlando, FL 32817
> \\\///  alex@bilver.UUCP    ...uunet!tarpit!bilver!alex
>  \XX/  From BitNet use: bilver!alex@uunet.uu.net

Paul S. R. Chisholm, AT&T Bell Laboratories
att!pegasus!psrc, psrc@pegasus.att.com, AT&T Mail !psrchisholm
I'm not speaking for the company, I'm just speaking my mind.

CMH117@psuvm.psu.edu (Charles Hannum) (02/19/90)

In article <4467@pegasus.ATT.COM>, psrc@pegasus.ATT.COM (Paul S. R. Chisholm)
says:
>
>DOS 3.0 and later generate enough information for the TC start-up code
>to put the path name in argv[0].  In version 1.x and 2.x, your best bet
>is to (yuchh) search the current directory, and then the path,
>yourself.

Use searchpath() ...


Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117@psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h@psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."

cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (02/27/90)

In article <4467@pegasus.ATT.COM> psrc@pegasus.ATT.COM (Paul S. R. Chisholm) writes:
$> 7) If my PATH environment variable is set up so that I can run one of my
$>    programs from a directory different than the one containing my program,
$>    how it possible for my program to determine the directory IT started
$>    from?  Or does that information have to be hard-coded in my program?
$DOS 3.0 and later generate enough information for the TC start-up code
$to put the path name in argv[0].  In version 1.x and 2.x, your best bet
$is to (yuchh) search the current directory, and then the path,
$yourself.

   Well, that really only applies to DOS 2 and above ... DOS 1 doesn't
have subdirectories, and I don't recall it having had an environment,
either, though I could be wrong.  Anyway, I don't think any current C
compilers have libraries that will work under DOS 1 anyway.

   BTW, in regard to the second edition of Duncan's book (_Advanced
MS-DOS_):  how significant are the differences between it and the
first edition?  I believe the second one covers DOS 3.3 (and 4?)
and EMS 4.0 ... any other major diffs?  Is it worth buying a copy of
the new edition?
-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
               I Think I'm Going Bald - Caress of Steel, Rush