home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lsmt213c.zip / qprint.cmd < prev    next >
OS/2 REXX Batch file  |  1999-12-16  |  6KB  |  166 lines

  1. /*---------------------------------------------------------------------------*\
  2. |  Query Printers Settings                    (C) Alain Rykaert - MAR96-DEC97 |
  3. \*---------------------------------------------------------------------------*/
  4.     Version = '1.11'
  5.     Say '* QPRINT Version' Version
  6.  
  7.  /*========================================================================*/
  8.     ColName.0  = 13                    ; ColLength.0  = ColName.0
  9.     ColName.1  = 'COL'                 ; ColLength.1  = 3
  10.     ColName.2  = 'TITLE'               ; ColLength.2  = 10
  11.     ColName.3  = 'LOCATION'            ; ColLength.3  = 19
  12.     ColName.4  = 'OBJECTID'            ; ColLength.4  = 15
  13.     ColName.5  = 'QUEUENAME'           ; ColLength.5  = 10
  14.     ColName.6  = 'PORTNAME'            ; ColLength.6  = 20
  15.     ColName.7  = 'PRINTDRIVER'         ; ColLength.7  = 35
  16.     ColName.8  = 'SEPARATORFILE'       ; ColLength.8  = 25
  17.     ColName.9  = 'OUTPUTTOFILE'        ; ColLength.9  = 12
  18.     ColName.10 = 'DEFAULTVIEW'         ; ColLength.10 = 11
  19.     ColName.11 = 'JODIALOBEFOREPRINT'  ; ColLength.11 = 18
  20.     ColName.12 = 'QUEUEDRIVER'         ; ColLength.12 = 11
  21.     ColName.13 = 'PRINTWHILESPOOLING'  ; ColLength.13 = 18
  22.  
  23.     PrinterFolderObject = '<WP_PRINTERSFOLDER>'
  24.     PrintwhileSpooling  = 'YES'                     /* specify your default*/
  25.  /*========================================================================*/
  26.  
  27.     Call Init                                 /* init DLL's and other stuff*/
  28.  
  29.     Parse Upper Arg ServerName
  30.  
  31.     If ServerName = ''
  32.       Then Do
  33.              Say '*'
  34.              Say '* Usage: QPRINT {*} {ServerName}'
  35.              Say '*'
  36.              Say '* Sample: QPRINT \\BEDDC2'
  37.              Say '*'
  38.              Exit X2D('1600')
  39.            End
  40.       Else Nop
  41.  
  42.     If ServerName = '*'
  43.       Then Do
  44.              RC = NetGetInfo(350, 'WKSTAINFO','')
  45.              If RC = 0
  46.                Then ServerName = WkstaInfo.ComputerName
  47.                Else Call ChkError RC
  48.            End
  49.       Else ServerName = ServerName
  50.  
  51.     ServerName = Strip(ServerName,'L','\')
  52.  
  53.     Say '* Server Name:' '\\'ServerName
  54.  
  55.     Say '* Getting all queues on \\'ServerName
  56.  
  57.     Title = ''                                           /* Building banner*/
  58.     Do i = 1 to ColName.0
  59.       Title = Title || Left(ColName.i, ColLength.i) || ';'
  60.     End
  61.     Say Title
  62.  
  63.     RC = RxSplEnumQueue('\\'ServerName, Queues)   /* get queues from server*/
  64.     If RC = 0
  65.       Then Nop
  66.       Else Call ChkError RC
  67.  
  68.     If Queues.Count > 0                        /* if a queue exist continue*/
  69.      Then Do i = 1 to Queues.Count
  70.             Queues.i.Name = Translate(Queues.i.Name)
  71.             Call RxSplQueryDevice '\\'ServerName, Details, Queues.i.Printers
  72.  
  73.             If Pos(',', Details.Drivers) > 0  /* check for multiple drivers*/
  74.               Then Do
  75.                      PrintDrivers = Details.Drivers
  76.                      j = 0
  77.                      Do While PrintDrivers <> ''
  78.                        j = j + 1
  79.                        Parse Value PrintDrivers With PrintDriver.j ',' PrintDrivers
  80.                      End
  81.                      PrintDriver.0 = j
  82.                    End
  83.               Else Do
  84.                      PrintDriver.0 = 1
  85.                      PrintDriver.1 = Strip(Details.Drivers)
  86.                    End
  87.  
  88.             If Queues.i.Sepfile = 'No separator file'
  89.               Then Queues.i.Sepfile = ''       /* check for empty separator*/
  90.               Else Nop
  91.  
  92.             Say Left('',                       ColLength.1)  || ';' ||,
  93.                 Left(Queues.i.Name,            ColLength.2)  || ';' ||,
  94.                 Left(PrinterFolderObject,      ColLength.3)  || ';' ||,
  95.                 Left('<WPPO_'Queues.i.Name'>', ColLength.4)  || ';' ||,
  96.                 Left(Queues.i.Name,            ColLength.5)  || ';' ||,
  97.                 Left(Details.LogAddr,          ColLength.6)  || ';' ||,
  98.                 Left(PrintDriver.1,            ColLength.7)  || ';' ||,
  99.                 Left(Queues.i.SepFile,         ColLength.8)  || ';' ||,
  100.                 Left('NO',                     ColLength.9)  || ';' ||,
  101.                 Left('ICON',                   ColLength.10) || ';' ||,
  102.                 Left('NO',                     ColLength.11) || ';' ||,
  103.                 Left('PMPRINT',                ColLength.12) || ';' ||,
  104.                 Left(PrintwhileSpooling,       ColLength.13)
  105.  
  106.                 If PrintDriver.0 > 0       /* if multiple drivers installed*/
  107.                   Then Do j = 2 to PrintDriver.0
  108.                          Say Left('*', ColLength.1) || ';',
  109.                              Left('', 2+ColLength.2+ColLength.3+ColLength.4+ColLength.5+ColLength.6),
  110.                              ';' || PrintDriver.j
  111.                        End
  112.                   Else Nop
  113.  
  114.           End
  115.       Else Say '  -none-'
  116.  
  117.     Exit X2D('FE00')
  118.  
  119.  INIT:/* --------------------------------------------------------------------*/
  120.  
  121.    '@echo off'
  122.     ESC = '1B'x
  123.     BootDrive = Left(Value('COMSPEC',,'OS2ENVIRONMENT'),2)
  124.  
  125.     If RxFuncQuery('SysLoadFuncs')
  126.       Then Do
  127.              Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
  128.              Call SysLoadFuncs
  129.            End
  130.       Else Nop
  131.  
  132.     LSRDrive = ''                      /* Check for Lan Server Drive Letter*/
  133.     PPath = Value('PATH',,'OS2ENVIRONMENT')
  134.     Do While PPath <> ''
  135.       Parse Upper Value PPath With Begin ';' PPath
  136.       If SubStr(Begin,4) = 'IBMLAN\NETPROG'
  137.         Then LSRDrive = Left(Begin,2)
  138.         Else Nop
  139.     End
  140.  
  141.     If Stream(LSRDrive'\ibmlan\netlib\lsrxut.dll', 'C', 'Query Exists') <> ''
  142.       Then Do
  143.              If RxFuncQuery('LoadLSRXUTFuncs')
  144.                Then Do
  145.                       Call RxFuncAdd LoadLsRxutFuncs, LSRxut, LoadLsRxutFuncs
  146.                       Call LoadLsRxutFuncs
  147.                     End
  148.                Else Nop
  149.            End
  150.       Else Do
  151.              Say '* Could not find:' LSRDrive'\IBMLAN\NETLIB\LSRXUT.DLL' '07'x
  152.              Exit X2D('0800')
  153.            End
  154.  
  155.     Return
  156.  
  157.  CHKERROR:/* ----------------------------------------------------------------*/
  158.  
  159.     Parse Arg RCode
  160.  
  161.     Say '* Error:' RCode
  162.     Exit X2D('1600')
  163.  
  164.     Return
  165.  
  166.