arranging-text-in-vertical-columns.rex

Pipelines v2.1

 

.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10...

Home

     **** Top of file ****
   1
   2 /* The following pipeline reads the file: winston.txt; splits each record into individual words
   3    and selects the first 150. Using this list of 150 words, it builds an output which consists of
   4    three equal columns of 50 words, 30 characters wide. */
   5
   6 Address Rxpipe
   7
   8 'pipe (priority 2 endchar ?)',
   9      '< &installdrive:\&installpath\examples\input\winston.txt',
  10      '| split',                      /* Split each record into individual words. */
  11      '| strip',                      /* Trim whitespace. */
  12      '| locate',                     /* Discard blank records. */
  13      '| take 150',                   /* Select only the first 150 words. */
  14      '| specs recno 1 1-* nw',       /* Insert record number in column 1. */
  15      '| a: drop 50',                 /* Route away the first 50 records. */
  16      '| b: drop 50',                 /* Route away the next 50 records. */
  17      '| c: specs select 1 1-* 1',    /* Read a record from each of the three input streams.. */
  18                 'select 2 1-* 30',   /* ..and build a single output record.. */
  19                 'select 0 1-* 60',   /* ..comprising three columns. */
  20      '| cons',                       /* Display on the console. */
  21      '?',
  22      'a:',
  23      '| elastic',                    /* Buffer as necessary, the first 50 records. */
  24      '| c:',                         /* Route back to main pipeline. */
  25      '?',
  26      'b:',
  27      '| elastic',                    /* Buffer as necessary, the next 50 records. */
  28      '| c:'                          /* Route back to main pipeline. */
  29
  30 Say 'Hit Enter to close..'
  31 Parse Pull
  32
  33 Exit 0
     **** End of file ****
 

Console output

 
.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10...
   1          1 It                        51 from                      101 about
   2          2 was                       52 entering                  102 forty-five,
   3          3 a                         53 along                     103 with
   4          4 bright                    54 with                      104 a
   5          5 cold                      55 him.                      105 heavy
   6          6 day                       56 The                       106 black
   7          7 in                        57 hallway                   107 moustache
   8          8 April,                    58 smelt                     108 and
   9          9 and                       59 of                        109 ruggedly
  10         10 the                       60 boiled                    110 handsome
  11         11 clocks                    61 cabbage                   111 features.
  12         12 were                      62 and                       112 Winston
  13         13 striking                  63 old                       113 made
  14         14 thirteen.                 64 rag                       114 for
  15         15 Winston                   65 mats.                     115 the
  16         16 Smith,                    66 At                        116 stairs.
  17         17 his                       67 one                       117 It
  18         18 chin                      68 end                       118 was
  19         19 nuzzled                   69 of                        119 no
  20         20 into                      70 it                        120 use
  21         21 his                       71 a                         121 trying
  22         22 breast                    72 coloured                  122 the
  23         23 in                        73 poster,                   123 lift.
  24         24 an                        74 too                       124 Even
  25         25 effort                    75 large                     125 at
  26         26 to                        76 for                       126 the
  27         27 escape                    77 indoor                    127 best
  28         28 the                       78 display,                  128 of
  29         29 vile                      79 has                       129 times
  30         30 wind,                     80 been                      130 it
  31         31 slipped                   81 tacked                    131 was
  32         32 quickly                   82 to                        132 seldom
  33         33 through                   83 the                       133 working,
  34         34 the                       84 wall.                     134 and
  35         35 glass                     85 It                        135 at
  36         36 doors                     86 depicted                  136 present
  37         37 of                        87 simply                    137 the
  38         38 Victory                   88 an                        138 electric
  39         39 Mansions,                 89 enormous                  139 current
  40         40 though                    90 face,                     140 was
  41         41 not                       91 more                      141 cut
  42         42 quickly                   92 than                      142 off
  43         43 enough                    93 a                         143 during
  44         44 to                        94 metre                     144 daylight
  45         45 prevent                   95 wide:                     145 hours.
  46         46 a                         96 the                       146 It
  47         47 swirl                     97 face                      147 was
  48         48 of                        98 of                        148 part
  49         49 gritty                    99 a                         149 of
  50         50 dust                     100 man                       150 the
  51 Hit Enter to close..