Get a list of all printers

[Autolink] Menu

(see also Add new LPT Ports)

 
/* captured from a message in a public IBM forum                      */

/**********************************************************************/
/*                                                                    */
/* List all printers                                                  */
/*                                                                    */
/* Written by: Georg Haschek (see EMail Addresses)                    */
/*                                                                    */
/* Description: Print a list of all printers to the display           */
/*                                                                    */
/**********************************************************************/

  if RxFuncQuery( "SysLoadFuncs" ) then
  do
    Call RxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs"
    Call SysLoadFuncs
  end /* if rxFuncQuery( ... */

  call SysIni "BOTH", "PM_SPOOLER_PRINTER", "ALL:", "printers"
  parse value SysIni( "BOTH", "PM_SPOOLER" , "PRINTER" ) with default ";" .

  default = strip( default )
  maxlen = 8

  do i = 1 to printers.0
    val = printers.i
    parse value SysIni( "BOTH", "PM_SPOOLER_PRINTER_DESCR", val ) ,
                          With printerd.val ";" .
    printerd.val = space( translate( printerd.val,"  ","0d0a"x ) )
    if val == default then
      printerd.val = printerd.val "[default]"
    maxlen = max( maxlen ,length( printerd.val ) )
  end /* do i = 1 to printers.0 */

  title =  "Name"||Copies( " ",maxlen-4 ) "Port     Queue    Printer driver"
  say title
  say copies( "-", length( title ) )

  do i = 1 to printers.0
    val = printers.i
    parse value SysIni( "BOTH", "PM_SPOOLER_PRINTER", val ) ,
                          With port ";" driver ";" Queue ";" .
    say left( printerd.val,maxlen ) left( strip( port ),8 ) ,
        left( strip( queue ),8) strip( driver )
  end /* do i = 1 to printers.0 */

exit 0


[Back: Get the desktop directory]
[Next: Changing the Lockup page entry]