Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

xprint code used to test a printers capabilities

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PBCC xprint code used to test a printers capabilities

    i did this so you did not have too.
    that is what this section of the forum is all about now isn't it.

    a program to test the actions of using the XPRINT SET DUPLEX function on windows printers and/or a windows printer driver assigned to the printer.

    this program should be self instructive and if not if anybody wants to reword, add or delete from it, please do because my english is the pitts.

    The printer tested should support duplexing, that is what this program is about.

    You should set the duplexing mode to OFF in the windows printer driver before running this program and if in your printer's duplex settings, actually on the physical printer, is set to ON, you should change the printer's duplex setting to OFF as well.


    i am also going to highjack a thread already written about concerning duplex problems.
    see
    User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.


    i do not think there will be much discussion of this code below, if you want ot change it, go ahead and make my day, or even gui it, but please post your code if you do.



    code is written in PB compiler PBCC 5.02

    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "win32api.inc"
    
    
    FUNCTION PBMAIN () AS LONG
       LOCAL sdatetime AS STRING
       LOCAL nduplex AS LONG
       LOCAL sprintername AS STRING
       LOCAL sprinterdriver AS STRING
       LOCAL regpath AS STRING
       LOCAL shost AS STRING
       LOCAL suser AS STRING
       LOCAL sdomain AS STRING
    
       LOCAL objshell AS DISPATCH
       LOCAL vRes AS VARIANT
       LOCAL vVar AS VARIANT
       SET objshell = NEW DISPATCH IN "WScript.Shell"
    
       shost = ENVIRON$("COMPUTERNAME")
       suser = ENVIRON$("USERNAME")
       sdomain = EXTRACT$(ENVIRON$("USERDOMAIN"), ".")
       sdatetime=DATE$+"  "+TIME$
    
    
    
    
    
       STDOUT "This program test a Powerbasic compiler function XPRINT SET DUPLEX"
       STDOUT "To see if the function is able to change the duplex printing"
       STDOUT "      characteristics of a printer with duplex capablilites."
       STDOUT "You need to choose a printer that has duplex printing capablilities."
    
       STDOUT "Four pages should print, Page A, Page B, Page C, and Page D"
       STDOUT "If this function works correctly with the printer,"
       STDOUT "  only 3 sheets of papaer will print. Page B should be on the
       STDOUT "  back of sheet of paper for Page A, and Page C and Page D"
       STDOUT "  should be printed on one sheet of paper each."
       STDOUT ""
       STDOUT "To do a thorough test, before running this program or now."
       STDOUT "  From the printer properties window using the windows operating system."
       STDOUT "  Find where you can change the duplex printing mode."
       STDOUT "  Note your setting before making any changes for this program,"
       STDOUT "  so that you can change back to your original setting."
       STDOUT "  Set the duplex mode to OFF. Then run this program."
       STDOUT "  Then changed the setting to ON. Then run this program."
       STDOUT "  Change your duplex mode back to the original settings.
       STDOUT ""
       STDOUT "press any key to choose a printer and print the test pages."
       WAITKEY$
    
    
    REM ' choose a printer
       XPRINT ATTACH CHOOSE , "Testing PB XPRINT Duplex function"
       sprintername=XPRINT$
       IF TRIM$(sprintername)="" THEN XPRINT CANCEL:XPRINT CLOSE:EXIT FUNCTION
    
    
    regPath = "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\" & sprintername
         vVar = regPath & "\Printer Driver"
         vRes = "" : OBJECT CALL objShell.RegRead(vVar) TO vRes
         sprinterdriver = VARIANT$(vRes)
    
        sHost = ENVIRON$("COMPUTERNAME")
        sDomain = EXTRACT$(ENVIRON$("USERDOMAIN"), ".")
    
    
    
    REM ' print the test pages
        XPRINT SET DUPLEX 2
        XPRINT "Page A"
        XPRINT ""
        XPRINT "Testing Pb compiler function XPRINT SET DUPLEX with this printer"
        XPRINT "This should be side 1 (front)  sheet paper 1 of 3"
        XPRINT "The function processed was XPRINT SET DUPLEX 2 just before printing page A"
        XPRINT ""
        XPRINT ""
        XPRINT "Windows info:"
        XPRINT "  date and time   = "+sdatetime
        XPRINT "  computer name   = "+shost
        XPRINT "  user name       = "+suser
        XPRINT "  computer domain = "+sdomain
        XPRINT "  printer  name   = "+sprintername
        XPRINT "  printer driver  = "+sprinterdriver
        XPRINT ""
        XPRINT ""
        XPRINT "This program was designed to test the printing actions of duplex printers."
        XPRINT "This program will print 4 pages; Page A, Page B, Page C, and Page D."
        XPRINT "Page A and Page B should be on one single sheet of paper, with Page B being"
        XPRINT "   on the back of the sheet, then Page C and Page D being printed on a single
        XPRINT "   sheet of paper each. So you should get 4 pages on 3 sheets of paper."
        XPRINT ""
        XPRINT "Some printers or windows printer drivers do not work properly while"
        XPRINT "   printing in duplex mode."
        XPRINT ""
        XPRINT "It is custom for a program to be able to change the duplex printing mode"
        XPRINT "   of a printer thru the windows printer driver used for a printer if that"
        XPRINT "   printer supports duplex printing."
        XPRINT ""
        XPRINT "If you did not get the desired results of printing you wanted."
        XPRINT "Most likely it is because your printer does not support duplex printing or"
        XPRINT "   your printer driver does support duplex printing and the windows printer driver"
        XPRINT "   you are using with this printer is defective or the printer driver may"
        XPRINT "   be for another printer and not this printer."
        XPRINT "The word defective refers to when the windows printer driver will not allow"
        XPRINT "   software to make changes to the printer thru the windows printer driver."
        XPRINT ""
        XPRINT "If you are using the correct windows driver, you may want to find a newer"
        XPRINT "   windows printer driver for the specific printer or an older one if it"
        XPRINT "   works for you, or even search for a compatible windows printer driver for the"
        XPRINT "   specific printer you are using."
        XPRINT ""
        XPRINT "Probably all other programs you print with will perform in the same manner that"
        XPRINT "   this program is doing. Meaning not letting software make the proper duplex"
        XPRINT "   setting."
        XPRINT ""
        XPRINT "Your only option left to correct the way in which your printer is handling"
        XPRINT "   duplex printing,  if you do not like the way it is now, is to make"
        XPRINT "   changes to the setting your windows printer driver for duplex printing"
        XPRINT "   an hope that solves your problems manually. Good luck with it."
    
    
        XPRINT FORMFEED
    
        XPRINT "Page B"
        XPRINT ""
        XPRINT "Testing Pb compiler function XPRINT SET DUPLEX with this printer"
        XPRINT "This should be side 2 (back)   sheet paper page 1 of 3"
        XPRINT "The function processed was XPRINT SET DUPLEX 2 just before printing page A"
        XPRINT ""
        XPRINT ""
        XPRINT "Windows info:"
        XPRINT "  date and time   = "+sdatetime
        XPRINT "  computer name   = "+shost
        XPRINT "  user name       = "+suser
        XPRINT "  computer domain = "+sdomain
        XPRINT "  printer  name   = "+sprintername
        XPRINT "  printer driver  = "+sprinterdriver
        XPRINT FORMFEED
    
        XPRINT SET DUPLEX 1
        XPRINT "Page C"
        XPRINT ""
        XPRINT "Testing Pb compiler function XPRINT SET DUPLEX with this printer"
        XPRINT "This should be side 1 (front)  sheet paper 2 of 3"
        XPRINT "The function processed was XPRINT SET DUPLEX 1 just before printing page C"
        XPRINT ""
        XPRINT ""
        XPRINT "Windows info:"
        XPRINT "  date and time   = "+sdatetime
        XPRINT "  computer name   = "+shost
        XPRINT "  user name       = "+suser
        XPRINT "  computer domain = "+sdomain
        XPRINT "  printer  name   = "+sprintername
        XPRINT "  printer driver  = "+sprinterdriver
        XPRINT FORMFEED
    
        XPRINT "Page D"
        XPRINT ""
        XPRINT "Testing Pb compiler function XPRINT SET DUPLEX with this printer"
        XPRINT "This should be side 1 (front)  sheet paper 3 of 3"
        XPRINT "The function processed was XPRINT SET DUPLEX 1 just before printing page D"
        XPRINT ""
        XPRINT ""
        XPRINT "Windows info:"
        XPRINT "  date and time   = "+sdatetime
        XPRINT "  computer name   = "+shost
        XPRINT "  user name       = "+suser
        XPRINT "  computer domain = "+sdomain
        XPRINT "  printer  name   = "+sprintername
        XPRINT "  printer driver  = "+sprinterdriver
        XPRINT FORMFEED
    
        XPRINT CLOSE
    
    
    END FUNCTION
    Attached Files
    Last edited by Paul Purvis; 24 Oct 2009, 10:56 PM.
    p purvis

  • #2
    I changed the title of this thread for purposes of future use.
    I am hoping in the future others will put code in this thread to test a printers capabilities by use of the XPRINT commands or any other useful code to test a printer.
    Maybe we can have one place to find software and/or code without looking all over the forum for code dealing with in this specific area.
    It is better to test a printers abilities up front than to find problems we might be faced with in the future and code to alter the printers capabilities.

    You should only place code here and describe what it does and if making any corrections to your code, just replace and make a notation of an update.
    This is just a idea folks that may work.
    Last edited by Paul Purvis; 24 Oct 2009, 11:10 PM.
    p purvis

    Comment

    Working...
    X