home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / print.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-01-13  |  8.4 KB  |  240 lines

  1. /*
  2.  *        Name: PRINT REXX
  3.  *              a disposable filter for printing from
  4.  *              Pipelines-based applications such as CMS Gopher.
  5.  *              (disposable in that you can replace it with your own)
  6.  *      Author: Rick Troth, Rice University, Information Systems
  7.  *              Thanks to Jim Colten for two better versions of
  8.  *              "STANDARD".
  9.  *        Date: Spring 1992, 1993-Jan-07
  10.  *
  11.  *        Note: Address() returns garbage in a pipelines stage
  12.  */
  13.  
  14. dev = "00E"
  15. linecount = 55
  16. upcase = 0
  17.  
  18. Parse       Arg name '(' opts ')' .
  19. Parse Upper Var name fn ft fm .
  20. fn = Left(fn,8); ft = Left(ft,8)
  21.  
  22. fml = Length(fm)
  23. Select  /*  fml  */
  24.     When fml = 1 Then If Datatype(Left(fm1,1),'N') Then fm = ""
  25.     When fml = 2 Then Do
  26.         If Datatype(Left(fm,1),'N') Then fm = ""
  27.         If ^Datatype(Right(fm,1),'N') Then fm = ""
  28.         End  /*  When  ..  Do  */
  29.     Otherwise fm = ""
  30.     End  /*  Select  fm  */
  31.  
  32. If Words(name) = 2 | Words(name) = 3 Then
  33.     name = Left(fn,8) Left(ft,8) Left(fm,2)
  34.  
  35. 'CALLPIPE COMMAND QUERY CMSLEVEL | CHOP , | VAR CMSLEVEL'
  36. 'CALLPIPE CP      QUERY CPLEVEL  | CHOP , | VAR CPLEVEL'
  37. title = "File:" Left(fn,8) Left(ft,8) Left(fm,2) cmslevel '/' cplevel
  38.  
  39. cc = (ft = "LISTING"  | ft = "LIST3800" | ,
  40.       ft = "LISTCPDS" | ft = "LIST3820" | ft = "LIST38PP")
  41.  
  42. Do While opts ^= ""
  43.     Parse Var opts op opts; Upper op
  44.     Select  /*  op  */
  45.         When Abbrev("LINECOUNT",op,2) Then Do
  46.             Parse Var opts linecount opts
  47.             If linecount = "" Then linecount = 55
  48.             End  /*  When  ..  Do  */
  49.         When Abbrev("UPCASE",op,2)  Then upcase = 1
  50.         When Abbrev("CC",op,2)      Then cc = 1
  51.         When Abbrev("NOCC",op,4)    Then cc = 0
  52.         When Abbrev("TITLE",op,1)   Then Do
  53.             title = opts
  54.             opts = ""
  55.             End  /*  When  ..  Do  */
  56.         Otherwise Say "Unrecognized option" op
  57.         End  /*  Select  op  */
  58.     End  /*  Do  While  */
  59.  
  60. If cc Then 'CALLPIPE *: | ASATOMC | URO' dev
  61. /*    Else Call STANDARD      */
  62. Else Do Forever
  63.     'PEEKTO'
  64.     If rc ^= 0 Then Leave
  65.     'CALLPIPE *: | TAKE' linecount ,
  66.         '| SPEC .09. X2C 1  1-* NEXT' ,
  67.         '| PREFACE LITERAL' '19'x || title ,
  68.         '| PREFACE LITERAL' '89'x ,
  69.         '| URO' dev
  70.     If rc ^= 0 Then Leave
  71.     End  /*  Else  ..  Do  Forever  */
  72. prc = rc * (rc ^= 12)
  73.  
  74. /*  use  CP CLOSE,  so the user can  SPOOL dev CONT  if he wants to  */
  75. If fn = "" Then Parse Value Diag(08,'CLOSE' dev) With rs
  76.            Else Parse Value Diag(08,'CLOSE' dev 'NAME' fn ft) With rs
  77.  
  78. If rs ^= "" Then
  79.     'CALLPIPE VAR RS | SPLIT AT STRING "' || '15'x || '" | *:'
  80.  
  81. Return prc
  82.  
  83.  
  84.  
  85. /* ------------------------------------------------------------ STANDARD
  86.  *  Here is a version of STANDARD that loops once per page rather than
  87.  *  once per record.  It should work with most versions of Pipelines.
  88.  */
  89. STANDARD:
  90. header = '19'x || title
  91. 'PEEKTO'
  92. Do While rc = 0
  93.     'CALLPIPE *: | TAKE' linecount ,
  94.         '| SPEC .09. X2C 1  1-* NEXT' ,
  95.         '| PREFACE VAR HEADER' ,
  96.         '| PREFACE LITERAL' '89'x ,
  97.         '| URO' dev
  98.     'PEEKTO'
  99.     End  /*  Do  Forever*/
  100. Return
  101.  
  102.  
  103.  
  104. /* ------------------------------------------------------------ PRINTASA
  105.  */
  106. PRINTASA:
  107.  
  108. 'ADDPIPE *.OUTPUT: | URO' dev
  109.  
  110. 'PEEKTO LINE'
  111. Do While rc = 0
  112.     Parse Var line 1 byte 2 line
  113.     line = byte || line
  114.     'OUTPUT' line
  115.     'READTO'
  116.     'PEEKTO LINE'
  117.     End  /*  Do  While  */
  118.  
  119. Return
  120.  
  121.  
  122.  
  123. /*
  124.  
  125. OVersize
  126.     allows you to print:
  127.  
  128.     *  files that have records larger than the carriage size of the
  129.        virtual printer, and
  130.  
  131.     *  files that have a SPECIAL status of YES.
  132.  
  133.     When the OVERSIZE option is used, the CC option will be set as
  134.     a default.  This default setting of CC can be overridden by
  135.     specifying either the NOCC or the HEX option with the OVersize
  136.     option.
  137.  
  138.      If the file has a SPECIAL status of YES (and NOCC is not specified),
  139.      any records with a carriage control character of x'5A' will be
  140.      printed if all of the following conditions are true:
  141.         - the record length is not greater than 32767 bytes.
  142.         - a printer subsystem that handles the x'5A' carriage controller
  143.           (such as the 3820 or 3800-3/8) is utilized.
  144.         - a software package that handles such characters (such as PSF)
  145.           is utilized.
  146.      Otherwise, these records will not be printed.
  147.  
  148.      Other records that are larger than the virtual printer's carriage
  149.      size are printed, but are truncated to the carriage size (or
  150.      carriage size + 1 if CC is specified).
  151.  
  152.      (The SPECIAL status indicates whether or not the file contains records
  153.      with X'5A' carriage control characters.  See the CP QUERY command to
  154.      determine SPECIAL status of a file.)
  155.  
  156.     The OVERSIZE (and CC) option is assumed if the filetype is
  157.     LISTCPDS, LIST3820, or LIST38PP.  If OVERSIZE is not specified and
  158.     the file you want to print is larger than the virtual printer's
  159.     carriage size, the message "Records exceeds allowable maximum"
  160.     is displayed.
  161.  
  162. CC (HEADer)
  163.     interprets the first character of each record as a carriage
  164.     control character.  If the filetype is LISTING, LIST3800, or
  165.     LISTCPDS, the CC option is assumed.  If CC is in effect, the PRINT
  166.     command neither performs page ejects nor counts the number of
  167.     lines per page; these functions are controlled by the carriage
  168.     control characters in the file.  The LINECOUN option has no effect
  169.     if CC is in effect.
  170.  
  171.     HEADER creates a shortened header page with only the filename,
  172.     filetype, and filemode at the top of the page that follows the
  173.     standard header page.  The records in the file being printed begin
  174.     on a new page following both header pages.  The HEADER option can
  175.     only be used in conjunction with the CC option.  If the CC option
  176.     is not specified HEADER has no effect.
  177.  
  178. TRC
  179.     interprets the first data byte in each record as a TRC (Table Ref-
  180.     erence Character) byte.  The value of the TRC byte determines
  181.     which translate table the 3800 printer selects to print a record.
  182.     The value of the TRC byte corresponds to the order in which you
  183.     have loaded WCGMs (via the CHARS keyword of the SETPRT command).
  184.     Valid values for TRC are 0, 1, 2, and 3.  If an invalid value is
  185.     found, a TRC byte of 0 is assumed.  If the filetype is LIST3800,
  186.     TRC is assumed.
  187.  
  188. NOTRC
  189.     does not interpret the first data byte in each record as a TRC
  190.     byte.  NOTRC is the default.
  191.  
  192. MEMber    <*         >
  193.           <membername>
  194.     prints the members of macro or text libraries. This option may be
  195.     specified if the file is a simulated partitioned data set
  196.     (filetype MACLIB, TXTLIB, or LOADLIB).  If an asterisk (*) is
  197.     entered, all individual members of that library are printed. If a
  198.     membername is specified, only that member is printed.
  199.  
  200. HEX
  201.     prints the file in graphic hexadecimal format.  If HEX is speci-
  202.     fied, the options CC and UPCASE are ignored, even if specified,
  203.     and even if the filetype is LISTING, LIST3800, LISTCPDS, LIST3820,
  204.     or LIST38PP.  If both the OVersize and HEX options are specified,
  205.     the NOCC option will be in effect.
  206.  
  207.  */
  208.  
  209.  
  210.  
  211. /* -- Here is a version of STANDARD that does not loop, requires
  212.       pipes mod level 6 (for sync) */
  213. STANDARD2:
  214. header = '19'x || title
  215.  
  216.   'CALLPIPE (end \)',
  217.     '| literal' '89'x,                /* page eject record?          */
  218.     '| append var header',            /* page header record          */
  219.     '| spec 1-* 1',                   /* simulate BLOCK LINEND by    */
  220.     '       .15. x2c next',           /*   adding linend chars & join*/
  221.     '| join *',                       /*     both recs into 1 rec    */
  222.     '| dup *',                        /* make an endless supply      */
  223.     ,
  224.     '| a: sync',                      /* 2 streams marching together */
  225.     '| b: faninany',                  /* combine the streams         */
  226.     ,
  227.     '| deblock linend',               /* deblock into separate recs  */
  228.     '| uro' dev,                      /* print it                    */
  229.     ,
  230.     '\ *:',                           /* incoming records            */
  231.     '| spec .09. x2c 1',              /* add charriage control and   */
  232.     '       1-* next',                /*  simulate BLOCK LINEND by   */
  233.     '       .15. x2c next',           /*    adding linend chars &    */
  234.     '| join' linecount-1,     /* join all recs for a page into 1 rec */
  235.     '| a:',                           /* send through sync           */
  236.     '| b:'        /* sync sends them back, now send them to faninany */
  237.  
  238. Return
  239.  
  240.