1. Printing Help

Some type ago I wrote a print utility that uses wPuts. I'm revisiting it now
because it is ungodly slow. It takes at least a minute to print one(1) full
page... totally useless for a real application. I have another OS which prints to
the same printer (hp890C) which is about 10 times faster. This routine below is
printing from a list box. Any help would be appreciated....I've no clue how to
fix the slowness.

procedure processPrint()

integer charsPerLine, linesPerPage
sequence fontSize, printerSize, stars
    stars = rpt(80,'*')

    prtOptions = getPrinter()
    if len(prtOptions)> 0 then
        printerFont = 12 -- start big
        charsPerLine = 0 -- init
        printerSize = getExtent( Printer ) -- get the size of a printer page
        while charsPerLine< rptWidth do
            setFont( Printer, "Courier New", printerFont, Normal )
            fontSize = getFontSize( Printer ) -- get the font metrics
            charsPerLine = floor(printerSize[1]/fontSize[1])
            printerFont -= 1
        end while
        if charsPerLine>rptWidth then
            ptab = space(floor((charsPerLine - rptWidth)/2))
        else
            ptab = ""
        end if
        linesPerPage = floor(printerSize[2]/fontSize[2])

        for j = 1 to prtOptions[3] do -- copies
            tmp = startDoc(rptName&sprintf("C%d",j))
            tmp = startPage()
            line = 0
            pageNbr =1
            if pageNbr>=prtOptions[1] and pageNbr<=prtOptions[2] then
                printFlag = 1
            else
                printFlag = 0
            end if
            pageNbr +=1
            for i = 1 to lnCount do
                tmp = getItem(idList,i)
                if sch(1,tmp,"*****") = 0 then
                    if i = pageTable[pageNbr] then
                        line = 0
                        if printFlag = 1 then
                            temp = endPage()
                        end if
if pageNbr>=prtOptions[1] and pageNbr<=prtOptions[2]
                        then
                            printFlag = 1
                            temp = startPage()
                            setPosition(Printer,0,line*(fontSize[2])+5)
                            wPuts(Printer,ptab&tmp)
                            line += 1
                        else
                            printFlag = 0
                        end if
                        pageNbr +=1
                        setText(sb,"Printing Page "&sprintf("%d ",{pageNbr}))
                    else
                        if printFlag=1 then
                            setPosition(Printer,0,line*(fontSize[2]-6))
---<<<<<<<<<<<< THE -6 matches theos with 12
                            fontsize
                            wPuts(Printer,ptab&tmp)
                            line += 1
                        end if
                    end if
                else
                    --tmp = startPage()
                end if
            end for
            if printFlag = 1 then
                temp = endPage()
            end if
            temp = endDoc()
        end for
        releasePrinter()
    end if
    figureLocation(0,0,"")
    setFocus(idList)

end procedure


new topic     » topic index » view message » categorize

2. Re: Printing Help

As a side note here, the crimson editor will print the same file in about 5-10
seconds.

new topic     » goto parent     » topic index » view message » categorize

3. Printing Help

I'm trying to open and print to a network printer like this

dosFn = open("IP_192.168.1.52", "w") -- a windows port
    prtFn = open(args[3], "r")
    if dosFn !=0 then
    	tmp = gets(prtFn)
        while not atom(tmp) do
        	if find("+p", tmp) then
        		puts(dosFn, 12)
        	else
	            puts(dosFn,tmp)
	        end if
	        --puts(1, tmp)
            tmp = gets(prtFn)
        end while
        close(dosFn)
    end if


However the program works fine but prints to a file of that name and not
to the port where the printer is attached.

What have I done wrong, or can I not do this.

I have working routines using win32 but for this application I wanted to print
directly to the printer.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Printing Help

George Walters wrote:
> 
> 
> I'm trying to open and print to a network printer like this
> 
> }}}
<eucode>
>     dosFn = open("IP_192.168.1.52", "w") -- a windows port
>     prtFn = open(args[3], "r")
>     if dosFn !=0 then
>     	tmp = gets(prtFn)
>         while not atom(tmp) do
>         	if find("+p", tmp) then
>         		puts(dosFn, 12)
>         	else
> 	            puts(dosFn,tmp)
> 	        end if
> 	        --puts(1, tmp)
>             tmp = gets(prtFn)
>         end while
>         close(dosFn)
>     end if
> </eucode>
{{{

> 
> However the program works fine but prints to a file of that name and not
> to the port where the printer is attached.
> 
> What have I done wrong, or can I not do this.
> 
> I have working routines using win32 but for this application I wanted to print
> directly to the printer.

I don't think you can open an IP that way, you probably have to use some kind of
networking library.

But the main reason I replied is that open() will return -1, not 0, if it fails.
--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
j.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Printing Help

Open a windows console, and type lpr /?

and

print /?

Chris

http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » goto parent     » topic index » view message » categorize

6. Re: Printing Help

There is also a win32 version of enscript out there, which produces nicer
looking ascii printout.


http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » goto parent     » topic index » view message » categorize

7. Re: Printing Help

Jason Gade wrote:
> 
> George Walters wrote:
> > 
> > 
> > I'm trying to open and print to a network printer like this
> > 
> > }}}
<eucode>
> >     dosFn = open("IP_192.168.1.52", "w") -- a windows port
> >     prtFn = open(args[3], "r")
> >     if dosFn !=0 then
> >     	tmp = gets(prtFn)
> >         while not atom(tmp) do
> >         	if find("+p", tmp) then
> >         		puts(dosFn, 12)
> >         	else
> > 	            puts(dosFn,tmp)
> > 	        end if
> > 	        --puts(1, tmp)
> >             tmp = gets(prtFn)
> >         end while
> >         close(dosFn)
> >     end if
> > </eucode>
{{{

> > 
> > However the program works fine but prints to a file of that name and not
> > to the port where the printer is attached.
> > 
> > What have I done wrong, or can I not do this.
> > 
> > I have working routines using win32 but for this application I wanted to
> > print
> > directly to the printer.
> 
> I don't think you can open an IP that way, you probably have to use some kind
> of networking library.
> 
> But the main reason I replied is that open() will return -1, not 0, if it
> fails.
> --
> "Any programming problem can be solved by adding a level of indirection."
> --anonymous
> "Any performance problem can be solved by removing a level of indirection."
> --M. Haertel
> j.

But with a little googling and experimenting, I found that you can print a file
with the following line (just make sure the printer you want is set as the
default printer)

system("start /min /normal notepad.exe /p " & args[3],2)



--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
j.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Printing Help

Interesting, thanks....

new topic     » goto parent     » topic index » view message » categorize

9. Re: Printing Help

George Walters wrote:

> dosFn = open("IP_192.168.1.52", "w") -- a windows port

Is feeding an IP address string into the first argument of open() actually
valid? That would be pretty awkward if it did work.


Regards,
Vincent

new topic     » goto parent     » topic index » view message » categorize

10. Re: Printing Help

If you look at the available ports for printers to use it is a legitimate port.
It is installed by windows when you install a printer that uses a print
server on the network. It functions just like LPT1 etc when printing to them
from windows. I just assumed it would work with Euphoria does for printing to
LPT1
but apparently I'm wrong.

Look at start>settings>printers then menu file > server properties and the
the ports tab. IF you have a network printer then the IP_xx.xx.xx.xx is in 
the list. Apparently it's just another port but not a "Printer" port.

new topic     » goto parent     » topic index » view message » categorize

11. Re: Printing Help

Vincent wrote:
> 
> George Walters wrote:
> 
> > dosFn = open("IP_192.168.1.52", "w") -- a windows port
> 
> Is feeding an IP address string into the first argument of open() actually
> valid?
> That would be pretty awkward if it did work.
> 
> 
> Regards,
> Vincent

Actually, it would be pretty cool. But it doesn't work that way.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
j.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu