May 7, 2001

===================================================================
>From the Edge: Automating Printer Selections
Section:                New CVAL, GETVAL and #LIST Commands
Platform:               R:BASE 2000 (ver 6.5++) for Windows
Build:                  1.840JxRT03 and Higher ... 
===================================================================

With the introduction of new CVAL and #LIST commands in R:BASE 2000 
(ver 6.5++) for Windows, here is how you can automate the printer 
selection before printing any REPORTS or SELECT output options!

Easy Steps: 

01. Set R:BASE 2000 for Windows Environment
02. Get Database QUOTE Setting 
03. Pre-Define All Required Variables
04. Find Windows Default Printer
05. Get List of All Windows Installed Printers 
06. Determine the number of lines to be displayed in CHOOSE window
07. Give user the option to select printer from the list 
08. Change Printer Accordingly
09. Send Output to the Selected Printer
10. Switch back to the Windows Default Printer

Sample Code:

-- AutoPRN.RMD - Automating Printer Selections
-- Running R:BASE Your Way!

-- 01. Set R:BASE 2000 for Windows Environment
   CLEAR ALL VAR
   SET CAPTION ' '
   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 vTempPrinter TEXT = NULL

-- 04. Find Windows Default Printer
   SET VAR vWinDefaultPrinter = (CVAL('CurrentPrinter'))
   SET VAR vWinDefaultPrinter = (.vQuote+.vWinDefaultPrinter+.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 vTempPrinter FROM #LIST .vPrinterList AT CENTER CENTER +
   CHKBOX 1 TITLE 'Select Printer' +
   CAPTION 'Currently Available Printers' +
   LINES .vLines FORMATTED
   IF vTempPrinter = NULL OR vTempPrinter = '[Esc]' THEN
        PAUSE 2 USING 'No Printer Selected!'
       GOTO Done
   ENDIF
   SET VAR vTempPrinter = (.vQuote+.vTempPrinter+.vQuote)

-- 08. Change Printer Accordingly
   PRNSETUP &vTempPrinter 

-- 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 &vWinDefaultPrinter

LABEL Done
   CLEAR ALL VAR
   QUIT TO MainMenu.RMD

Feel free to make any adjustment(s) accordingly!

Stay tuned for more ... 

Very Best Regards,

Razzak.


===================================-============================
R:BASE Developers's Conference: http://www.rbase.com/conference 
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