October 5, 2001 

================================================================
>From the Edge: Enhancing and Automating PRNSETUP Options
                        (A comprehensive look) 
Section:                New CVAL Functions
Chapter:                Running R:BASE Your Way! 
Platform:               R:BASE 2000 (ver 6.5++) for Windows
Build:                  1.843xRT03 and Higher 
================================================================

Many new CVAL functions were introduced with the release of 
R:BASE 2000 (ver 6.5++) for Windows on June 15, 2001. 

To add more value, a new (CVAL('WindowsPrinter')) function has 
been introduced in R:BASE 2000 (version 6.5++) for Windows, 
In-Line Patch-1, Build:1.843xRT03, to be released soon. 

Now, you can enhance and completely automate PRNSETUP options! 

First, let's gather all related PRNSETUP options along with 
any associated CVAL Functions and Enhanced CHOOSE parameters 
to automate PRNSETUP options.

Commands:       
                PRNSETUP
                Parameters:     PRNSETUP 'Printer Name'
                                PRNSETUP 'Paper Size'
                                PRNSETUP 'Paper Source'
                                PRNSETUP 'Orientation'
                                PRNSETUP COPY n

                For details on each parameter above, please 
                check PRNSETUP topic on http://www.RSyntax.com

                CHOOSE
                Parameters:     #LIST

CVAL Functions:
                (CVAL('Printers'))
                (CVAL('WindowsPrinter'))
                (CVAL('CurrentPrinter'))


(CVAL('Printers')) 
Returns the list of all installed printers on local workstation

(CVAL('WindowsPrinter'))
Returns the name of windows default printer

(CVAL('CurrentPrinter'))
Returns the name of selected windows printer for current R:BASE 
session using PRNSETUP 'Printer Name' command. If no PRNSETUP 
'Printer Name' command was issued, then, R:BASE for Windows 
will default to the windows default printer. 

Following examples will explain different ways to enhance and 
automate PRNSETUP options: 

Example 01:

Among various types of installed printers on your local 
workstation, if you need to print two copies of legal size 
reports from the lower tray of your HP Laserjet 4 printer, 
here's what you need do at the R> prompt or in a command 
file:
 
PRNSETUP 'HP Laserjet 4'
PRNSETUP 'LEGAL'
PRNSETUP 'LOWER'
PRNSETUP COPY 2

OUTP PRINTER
PRINT ReportName WHERE ... ORDER BY ...
OUTP SCREEN

Example 02:

In your customized application, if you would like to create 
a PDF version of any report, for example, using Adobe Acrobat 
PDFWriter printer driver (if installed), and then after 
creating the PDF file want to switch back to the windows 
default printer, here's what you would do:

SET VAR vWinPrinter = (CVAL('WindowsPrinter'))

PRNSETUP 'Acrobat PDFWriter' 

OUTP PRINTER
PRINT ReportName WHERE ... ORDER BY ...
OUTP SCREEN

PRNSETUP .vWinPrinter

Example 03:

If you would like to give your users the option to choose 
from a list of all installed printers on local workstations, 
pick appropriate printer and then switch back to windows 
default printer, here's how:

-- AutoPRN.RMD - Automating Printer Selections (10 Steps)

-- 01. Set R:BASE 2000 for Windows Environment
   CLEAR ALL VAR
   SET CAPTION ' '
   SET AUTODROP OFF 
   SET RBGSIZE CENTER CENTER 800 600
   CLS
   PAUSE 3 USING 'Please Wait ...' AT 16 30

-- 02. Get Database QUOTE Setting 
   SET VAR vQuoteName TEXT = QUOTE
   SET VAR vQuote = (CVAL(.vQuoteName)) 

-- 03. Pre-Define All Required Variables
   SET VAR vWinDefaultPrinter TEXT = NULL
   SET VAR vPrinterList TEXT = NULL
   SET VAR vLines INTEGER = 1
   SET VAR vCurrPrinter TEXT = NULL

-- 04. Find Windows Default Printer 
   SET VAR vWinPrinter = (CVAL('WindowsPrinter'))
   SET VAR vWinPrinter = (.vQuote+.vWinPrinter+.vQuote)

-- 05. Get List of All Windows Installed Printers 
   SET VAR vPrinterList = (CVAL('Printers')) 

-- 06. Determine the number of lines to be displayed in CHOOSE window
    WHILE (SSUB(.vPrinterList, .vLines)) IS NOT NULL THEN
          SET VAR vLines = (.vLines+1)
    ENDWHILE
    IF vLines > 20 THEN
       SET VAR vLines = 20
    ELSE
       SET VAR vLines = (.vLines -1)
    ENDIF

-- 07. Give user the option to select printer from the list 
   CLS
   CHOOSE vCurrPrinter FROM #LIST .vPrinterList AT CENTER CENTER +
   CHKBOX 1 TITLE 'Select Printer' +
   CAPTION 'Currently Available Printers' +
   LINES .vLines FORMATTED
   IF vCurrPrinter IS NULL OR vCurrPrinter = '[Esc]' THEN
      PAUSE 2 USING 'No Printer Selected!'
      GOTO Done
   ENDIF
   SET VAR vCurrPrinter = (.vQuote+.vCurrPrinter+.vQuote)

-- 08. Change Printer Accordingly
   PRNSETUP &vCurrPrinter 

-- 09. Send Output to the Selected Printer 
   OUTP PRINTER
   PRINT ReportName WHERE ... ORDER BY ... 
   OUTP SCREEN

   -- or

   SET VAR vRBGLines = (CVAL('LINES'))
   SET LINES 0
   OUTP PRINTER
   SELECT ColName1=10, ColName2=16, ColName3=20=S + 
   FROM TableName WHERE ... ORDER BY ... 
   OUTP SCREEN
   SET LINES .vRBGLines

-- 10. Switch back to the Windows Default Printer
   PRNSETUP &vWinPrinter

LABEL Done
CLEAR ALL VAR
QUIT TO MainMenu.RMD
RETURN


Example 04:

In your application, if you would always like to display 
both default printer for R:BASE session as well as windows 
default printer, then, you can use the following options: 

SET VAR vCurrPrinter = (CVAL('CurrentPrinter'))
SET VAR vWinPrinter = (CVAL('WindowsPrinter'))

Once defined, you may display these variables as CAPTION or 
variable objects in R:BASE forms. 

Now just imagine the various possibilities of using the POWER 
and Flexibility of R:BASE 2000 (version 6.5++) for Windows. 

You're ONLY limited by your imagination! 

Stay tuned for more ....

Very Best Regards,

Razzak.


===================================-============================
Official R:BASE List Server:    mailto:[EMAIL PROTECTED]
RBTI Events/Training:        http://www.rbase2000.com/events
R:DCC Members:               http://www.rbase2000.com/rdcc
================================================================
R:BASE, Oterro & R:Tango are registered trademarks of RBTI.
==================================-=============================

Reply via email to