alternative for isprinter() 
Author Message
 alternative for isprinter()

Somebody nows an alternative for isprinter()

Isprinter() just works on LPT1 and I need to print to LPT2 because
HPjetdirect printerserver is incapable working with LPT1

Thanks



Wed, 21 Aug 2002 03:00:00 GMT  
 alternative for isprinter()
The following example attempts to open the parallel port and a text
file and print the text file.  You may do some testing to just see what
error codes are displayed by Ferror() when fopen fails.  When fopen
fails, the handle returned is -1.

/*

   This works fine in an environment with a local printer.  It also
works
   under Novell with capture set on.  I don't know if it will work for
you,
   Doug, but give it a try.

   For the test I would recommend getting rid of DOS PRINT.
   In the Clipper code:
      replace IsPrinter()
      with    LLPrint( <filename>, "LPT2" )

   You may wish to increase the buffer size.  Keep in mind Clipper's max
   string length.

*/

Function LLPrint( cFileName, cPort )      // Example:  Main
( "TOCWK.PRG", "LPT1" )

   LOCAL nPoHandle, nFiHandle, nBytesRead, nBufLen := 4096, cBuffer

   WHILE .T.

      IF cFileName = NIL .OR. .NOT. FILE(cFileName)
         ALERT("File not found;" + cFileName)
         EXIT
      END

      nPoHandle = FOPEN(cPort, 1)

      IF cPort = NIL .OR. nPoHandle <= 0
         ALERT("Port not available;" + cPort)
         EXIT
      END

      nFiHandle = FOPEN(cFileName, 0)

      WHILE .T.

         cBuffer = SPACE(nBufLen)

         IF nBytesRead = 0
            EXIT
         END

         IF nBytesRead < nBufLen
            FWRITE(nPoHandle, SUBSTR(cBuffer, 1, nBytesRead))
         ELSE
            FWRITE(nPoHandle, cBuffer)
         END

      END

      FWRITE(nPoHandle, CHR(12))

      FCLOSE(nFiHandle)
      FCLOSE(nPoHandle)

      EXIT

   END

   RETURN NIL

// eof

/*
 a short test program for fopen - doesn't include a parallel port but
this can easily be added
*/

function main( cParm )

   LOCAL nParm, nHandle, I

   IF cParm = NIL
      nParm = 0
   ELSE
      nParm = VAL(cParm)
   ENDIF

   DO CASE

      CASE nParm = 2
         nHandle := FOPEN("asdf.pmm")
         IF FERROR() <> 0
            DispFerr( FERROR(), PROCNAME(), PROCLINE() )
         ENDIF

      CASE nParm = 3
         nHandle := FOPEN("\11111111\asdf.pmm")
         IF FERROR() <> 0
            DispFerr( FERROR(), PROCNAME(), PROCLINE() )
         ENDIF

      CASE nParm = 4
         I := 0
         DO WHILE .T.
            I ++
            nHandle := FCREATE(STRZERO(I,4) + ".PMM")
            IF FERROR() <> 0
               DispFerr( FERROR(), PROCNAME(), PROCLINE() )
            ENDIF
         ENDDO

      OTHERWISE
         ? "Didn't recognize this parameter"

   ENDCASE

   RETURN NIL

/*

  0                  Successful
  2                  File not found
  3                  Path not found
  4                  Too many files open
  5                  Access denied
  6                  Invalid handle
  8                  Insufficient memory
 15                 Invalid drive specified
 19                 Attempted to write to a write-protected
 21                 Drive not ready
 23                 Data CRC error
 29                 Write fault
 30                 Read fault
 32                 Sharing violation
 33                 Lock Violation

*/

// eof

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 21 Aug 2002 03:00:00 GMT  
 alternative for isprinter()

Quote:

>Somebody nows an alternative for isprinter()

>Isprinter() just works on LPT1 and I need to print to LPT2 because
>HPjetdirect printerserver is incapable working with LPT1

Look in the NanForum library from my site.

--

        Oasis WWW  http://www.the-oasis.net
         FTP Site  ftp://ftp.iag.net/pub/clipper
      Clipper FAQ  http://www.the-oasis.net/clipper.html
  Harbour Project  http://www.Harbour-Project.org

      Reality is the leading cause of stress
       among those who are in touch with it.



Wed, 21 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. IsPrinter() in Windows

2. Isprinter() with a serial printer

3. ISPRINTER() in 2000/xp

4. IsPrinter()

5. S'87 - isprinter() function

6. ISPRINTER Doen't Check for Disconnected Printer

7. what about ISPRINTER()

8. isprinter() for lpt2 & lpt3

9. Isprinter() function

10. IsPrinter on a Windows 95 NetWare ?

11. ISPRINTER FUNCTIOIN

12. Isprinter & CPMI.LIB

 

 
Powered by phpBB® Forum Software