[comp.lang.pascal] Just for kicks

mg2n+@andrew.cmu.edu (Martin G. Greenberg) (05/20/91)

Has anyone else seen/experienced this problem?

I wrote a program (for commercial reasons) which needs to download
soft fonts to a laser printer which is attached to the computer. To
do this I did the sensible thing and used the following sequence of
commands along with a WRITELN or two to send the appropriate control
codes.

    SwapVectors;
    Exec (GetEnv ('COMSPEC'), '/C COPY FONT1.FOO PRN > NUL')
    SwapVectors;
Now, the other developers and I have had 4 computers hooked up to three
different printers and we've never had a problem. On the machines of
50% of our customers, the download will not work. To this day, I have never
been able to duplicate the problem.

We finally got ticked off and sent the whole shebang off to Hewlett Packard
(the software is designed for the LaserJet 2 since that is what our market
uses almost exclusively) and said "any ideas?". The tech at HP tried the
code on the machines in the office and it failed miserably, yet when she
tried it on her machine at home, it worked flawlessly. HP at this point said,
"It's Borland's fault" (the code was written using TP 5.0 & 5.5).

We have yet to hear from anyone a satifactory explanation.
Can any of you make any suggestions?

                                     MGG

bb16@prism.gatech.EDU (Scott Bostater) (05/20/91)

In article <4cBo0AK00Vpg06BUV4@andrew.cmu.edu> mg2n+@andrew.cmu.edu (Martin G. Greenberg) writes:
>Has anyone else seen/experienced this problem?
>
>I wrote a program (for commercial reasons) which needs to download
>soft fonts to a laser printer which is attached to the computer. To
>do this I did the sensible thing and used the following sequence of
>commands along with a WRITELN or two to send the appropriate control
>codes.

I've written a similar routine for work myself.  Why are you using WRITELN?
Are you sure you want the extra CR+LF sent to the printer?  PCL in general
will normally ignore those characters so at best you're doing no harm, at worst
you're corrupting the data.

>
>    SwapVectors;
>    Exec (GetEnv ('COMSPEC'), '/C COPY FONT1.FOO PRN > NUL')
>    SwapVectors;

Off the top of my head try:
    
     Exec( GetnEnv('COMSPEC'), '/C copy/b font1.foo prn > nul');

This makes sure that ^Z's don't mess up the copy command. (Or are you sure that
font1.foo doesn't have a $1a in it anywhere? :-)

The approach that I took differs signifigantly.  I read the data in and sent it
to the printer directly because I had to send over a 19200 baud serial line.
I later re-wrote the program to go over a parallel line.  This method gives
you more control over what gets sent.

Program LJ_Example;
uses printer;

const
  ESC = #27;

...
Procedure DownloadFont( FontID: Integer;
                        FontFile: String);
var
  F: File of Char;
  c: Char;

Begin
  Assign( f, FontFile);
  Reset(f);

  Write(lst, ESC+"*c", FontID, "D");  { tell printer data is a downloadable
                                        softfont }
  While Not Eof(f) do
   Begin
    read(f,c);
    write(lst,c);
   End; { While }

  Close(f);
End; { Procedure DownloadFont }
...


[stuff deleted]

>We finally got ticked off and sent the whole shebang off to Hewlett Packard
>(the software is designed for the LaserJet 2 since that is what our market
>uses almost exclusively) and said "any ideas?". The tech at HP tried the
>code on the machines in the office and it failed miserably, yet when she
>tried it on her machine at home, it worked flawlessly. HP at this point said,
>"It's Borland's fault" (the code was written using TP 5.0 & 5.5).

Sounds like a DOS bug to me.  If you're using the EXEC command to call the copy
command.  Is there any correlation between DOS versions and/or IBM-DOS vs
MS-DOS?  It sounds to me like sometimes the ^Z's are causing problems and 
sometimes they aren't  (at least off the top of my head :-)

-- 
Scott Bostater      Georgia Tech Research Institute - Radar Systems Analysis
"My soul finds rest in God alone; my salvation comes from Him"  -Ps 62.1
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!bb16
Internet: bb16@prism.gatech.edu

mg2n+@andrew.cmu.edu (Martin G. Greenberg) (05/22/91)

So far I have gotten a number of suggestions/comments including:

    1) You need the "/B" to tell DOS that its a binary file
    2) Make sure the printer is hooked up right, turned on, etc.
    3) Make sure there is a "Files = nnn" in the CONFIG.SYS file.
    4) Check the available memory (i.e. $M directive problems)
    5) Path length exceeding maximum

Unfortunately, all these have been checked repeatedly (the lack of
a "/B" was a oversight in the post and is present in the code) or
do not apply due to the fact that the installation routine takes
care of directory/path setup.

Further ideas?

                                           MGG

dave@tygra.Michigan.COM (David Conrad) (05/27/91)

In article <4cBo0AK00Vpg06BUV4@andrew.cmu.edu> mg2n+@andrew.cmu.edu (Martin G. Greenberg) writes:
>Has anyone else seen/experienced this problem?
>
>    SwapVectors;
>    Exec (GetEnv ('COMSPEC'), '/C COPY FONT1.FOO PRN > NUL')
>    SwapVectors;
>
>[works part of the time]
>
>We have yet to hear from anyone a satifactory explanation.
>Can any of you make any suggestions?
>
>                                     MGG

Whether or not this code will succeed depends on the amount of free memory.
Are you checking the DosErrorCode when you return?  Perhaps some of the
users are suffering from RAM-cram and DOS can't load another copy of
COMMAND.COM.  You could easily build the copy functionality into your
application, just Use Printer and open the font file as a file of char
and read through it, Write (lst,...) the whole thing.

If memory isn't your problem then I must admit, I'm without a clue.
--
David Conrad
dave@michigan.com
-- 
=  CAT-TALK Conferencing Network, Computer Conferencing and File Archive  =
-  1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new'    - 
=  as a login id.  AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET")        =
   E-MAIL Address: dave@Michigan.COM

dave@tygra.Michigan.COM (David Conrad) (05/27/91)

In article <McCOVWO00VpaMJi0cu@andrew.cmu.edu> mg2n+@andrew.cmu.edu (Martin G. Greenberg) writes:
>So far I have gotten a number of suggestions/comments including:
>
>    1) You need the "/B" to tell DOS that its a binary file
>    2) Make sure the printer is hooked up right, turned on, etc.
>    3) Make sure there is a "Files = nnn" in the CONFIG.SYS file.
>    4) Check the available memory (i.e. $M directive problems)
                                         ~~~~~~~~~~~~~~~~~~~~~
>    5) Path length exceeding maximum
>
>Unfortunately, all these have been checked repeatedly (the lack of
>a "/B" was a oversight in the post and is present in the code) or
>do not apply due to the fact that the installation routine takes
>care of directory/path setup.
>
>Further ideas?
>
>                                           MGG

Check the available DOS! memory.  Is there enough memory left over for
DOS to start up another COMMAND.COM?  If there isn't, it won't work.
Let's say your program uses 200k of code+data and 100k of heap, so 300k
altogether.  If there's only 301k of memory available before your program
runs then it isn't going to work.  If there's 500k free to begin with,
then it will.  Even though you may have, say, {$M 16384,65536,131072},
DOS may still not have sufficient memory to perform the copy.
--
David Conrad, dave@michigan.com
-- 
=  CAT-TALK Conferencing Network, Computer Conferencing and File Archive  =
-  1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new'    - 
=  as a login id.  AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET")        =
   E-MAIL Address: dave@Michigan.COM