How best to redirect printer temporarily? (AREV Specific)
At 29 APR 2002 03:17:31PM Michael Slack wrote:
I'm working on an application in AREV 3.12 on an NT network. Menu items that generate a report, in general, fist call a routine that allows the user to select the output destination (their default printer, the monitor, another printer or send it to an ASCII file). Once the routine is done redirecting the output, it then calls the report program. Once the report is done, the control is sent back to the printer redirection program and sets the users default printer as the current printer.
In testing a new report program, I'm finding that our redirection routine isn't working consitantly. Friday it worked fine and now on Monday it's not working the way I expect it to. In a breif glance thru our home grown printer redirection program I see that it's using SETPTR in part. Also, this home grown program uses options set on the menu item to determine if the output is to be Portrait or Landscape, Laser or Dot Matrix and the CPI. Then the program goes out to a Printers table to get the predefined HP Hex codes to set the printer to those settings.
Does anyone have a suggestion as to how best to redirect report output (either from a canned R/List statement or a program that uses the PRINT statment) and then redirect it to the users default printer when all is said and done? My belief is that our home grown printer redirection routine isn't as flexable or usable as it should be and as a result some of our reports aren't able to make full use of different printer settings. What is the best way to format a report output to a printer and then reset it to default one the report is done? I expect that our printer redirection program will need a good bit of a rewrite and some tightening up in places.
If you can point me in the right direction that would be a big help.
Thank you for your time.
Michael Slack
At 29 APR 2002 05:08PM Richard Hunt wrote:
Michael;
Lots of things to consider…
1) Output device; screen, printer, file.
A) If screen then I do these commands.1) @VIEW.MODE=12) CALL INIT.VIEW(REPORT.WIDTH)3) Do report.When report is done...1) @VIEW.MODE=0B) If printer then I do these commands.1) EXECUTE "SETPRINTER ":PRINTER.NUMBER2) PRINTER ON3) Do report.When report is done...1) @HFACTIVE="2) PRINTER OFF3) EXECUTE "SETPRINTER 1"4) EXECUTE "PDISK PRN (O S)"C) If file then I do these commands.1) EXECUTE "PDISK ":DOS.ID:" (O S)"2) PRINTER ON3) Do report.When report is done...1) @HFACTIVE="2) EXECUTE "SETPRINTER 1"3) EXECUTE "PDISK PRN (O S)"2) If using printer, what printer?
You could capture printer ports, and save "LPT1" for the local printer. Now to know what printer type you are printing to, you will have to make this unique for each user terminal. This is where a "PRINTERS" file (table) might just help out. In the file you could have the printer control codes for all the CPI's (character per inch) and LPI's (Lines per inch). Also I would strongly suggest you put these control codes in the report "HEADING", so that they set the printer for every page.3) I have made this a subroutine for me. I pass 3 arguments
A) DEVICE, the output device (S)creen, (P)rinter, (F)ile.B) PHRASE, a phrase of words for options.1) QUERY, ask user to select output type.2) ON, turn the output device on (start).3) OFF, turn the output device off (finished).4) WIDTH, the width in characters of the report.C) PRINTER.CODES, a string of printer control codes that I add to the report heading so that each page sets the printer.4) As the last prompt for my report, I call my subroutine to "QUERY" the user for the output device.
5) After selecting and sorting, and before setting the report heading, I call my subroutine to "ON" (redirect) the output device. I also include the report width so that the subroutine can return the proper printer control codes. I then prefix my report heading with those control codes.
5) After the report is finished, and just before ending the program, I call my subroutine to "OFF" (redirect) the output device.
6) If you are capturing your printer ports, they have to be captured the same way all the time. I mean that each printer must be assigned to the same "LPT#" port. Otherwise the wrong printer control codes will be sent to the wrong printer.
Well, thats how I do it. I'm lucky because my customers get printers that are HP and EPSON compatable, when it comes to printer control languages.